Increase SPI Speed on LPC. Color and Classic UI for MKS SGEN L. (#19945)

This commit is contained in:
Victor Oliveira 2020-11-01 23:15:06 -03:00 committed by Scott Lahteine
parent e335e74379
commit 3c512648da
4 changed files with 65 additions and 11 deletions

View file

@ -357,8 +357,8 @@ void SPIClass::setDataSize(uint32_t ds) {
void SPIClass::updateSettings() { void SPIClass::updateSettings() {
//SSP_DeInit(_currentSetting->spi_d); //todo: need force de init?! //SSP_DeInit(_currentSetting->spi_d); //todo: need force de init?!
// divide PCLK by 2 for SSP0 // Divide PCLK by 2 for SSP0
CLKPWR_SetPCLKDiv(_currentSetting->spi_d == LPC_SSP0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2); //CLKPWR_SetPCLKDiv(_currentSetting->spi_d == LPC_SSP0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2);
SSP_CFG_Type HW_SPI_init; // data structure to hold init values SSP_CFG_Type HW_SPI_init; // data structure to hold init values
SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode

View file

@ -37,13 +37,14 @@
#define DATA_SIZE_8BIT SSP_DATABIT_8 #define DATA_SIZE_8BIT SSP_DATABIT_8
#define DATA_SIZE_16BIT SSP_DATABIT_16 #define DATA_SIZE_16BIT SSP_DATABIT_16
#define SPI_CLOCK_DIV2 8333333 //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED #define SPI_CLOCK_MAX_TFT 30000000UL
#define SPI_CLOCK_DIV4 4166667 //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED #define SPI_CLOCK_DIV2 8333333 //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
#define SPI_CLOCK_DIV8 2083333 //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED #define SPI_CLOCK_DIV4 4166667 //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED
#define SPI_CLOCK_DIV16 1000000 //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED #define SPI_CLOCK_DIV8 2083333 //(SCR: 11) desired: 2,000,000 actual: 2,083,333 +4.2% SPI_QUARTER_SPEED
#define SPI_CLOCK_DIV32 500000 //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5 #define SPI_CLOCK_DIV16 1000000 //(SCR: 24) desired: 1,000,000 actual: 1,000,000 SPI_EIGHTH_SPEED
#define SPI_CLOCK_DIV64 250000 //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6 #define SPI_CLOCK_DIV32 500000 //(SCR: 49) desired: 500,000 actual: 500,000 SPI_SPEED_5
#define SPI_CLOCK_DIV128 125000 //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h #define SPI_CLOCK_DIV64 250000 //(SCR: 99) desired: 250,000 actual: 250,000 SPI_SPEED_6
#define SPI_CLOCK_DIV128 125000 //(SCR:199) desired: 125,000 actual: 125,000 Default from HAL.h
#define SPI_CLOCK_MAX SPI_CLOCK_DIV2 #define SPI_CLOCK_MAX SPI_CLOCK_DIV2

View file

@ -89,7 +89,7 @@ void TFT_SPI::Init() {
#elif TFT_MISO_PIN == BOARD_SPI2_MISO_PIN #elif TFT_MISO_PIN == BOARD_SPI2_MISO_PIN
SPIx.setModule(2); SPIx.setModule(2);
#endif #endif
SPIx.setClock(SPI_CLOCK_MAX); SPIx.setClock(SPI_CLOCK_MAX_TFT);
SPIx.setBitOrder(MSBFIRST); SPIx.setBitOrder(MSBFIRST);
SPIx.setDataMode(SPI_MODE0); SPIx.setDataMode(SPI_MODE0);
} }
@ -125,7 +125,7 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) {
} }
DataTransferEnd(); DataTransferEnd();
SPIx.setClock(SPI_CLOCK_MAX); SPIx.setClock(SPI_CLOCK_MAX_TFT);
#endif #endif
return data >> 7; return data >> 7;

View file

@ -249,6 +249,59 @@
#define LCD_PINS_ENABLE P1_22 #define LCD_PINS_ENABLE P1_22
#define LCD_PINS_D4 P0_17 #define LCD_PINS_D4 P0_17
#elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI
#define TFT_CS_PIN P1_00
#define TFT_A0_PIN P1_22
#define TFT_DC_PIN P1_22
#define TFT_MISO_PIN P0_08
#define TFT_BACKLIGHT_PIN P0_18
#define TFT_RESET_PIN P0_16
#define LCD_USE_DMA_SPI
#define TOUCH_INT_PIN P0_17
#define TOUCH_CS_PIN P0_15
#define TOUCH_BUTTONS_HW_SPI
#define TOUCH_BUTTONS_HW_SPI_DEVICE 2
// Disable any LCD related PINs config
#define LCD_PINS_ENABLE -1
#define LCD_PINS_RS -1
// XPT2046 Touch Screen calibration
#if ENABLED(TFT_CLASSIC_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -11386
#endif
#ifndef XPT2046_Y_CALIBRATION
#define XPT2046_Y_CALIBRATION 8684
#endif
#ifndef XPT2046_X_OFFSET
#define XPT2046_X_OFFSET 689
#endif
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET -273
#endif
#elif ENABLED(TFT_COLOR_UI)
#ifndef XPT2046_X_CALIBRATION
#define XPT2046_X_CALIBRATION -16741
#endif
#ifndef XPT2046_Y_CALIBRATION
#define XPT2046_Y_CALIBRATION 11258
#endif
#ifndef XPT2046_X_OFFSET
#define XPT2046_X_OFFSET 1024
#endif
#ifndef XPT2046_Y_OFFSET
#define XPT2046_Y_OFFSET -367
#endif
#define TFT_BUFFER_SIZE 2400
#endif
#define BTN_EN1 P3_25
#define BTN_EN2 P3_26
#elif IS_TFTGLCD_PANEL #elif IS_TFTGLCD_PANEL
#undef BEEPER_PIN #undef BEEPER_PIN