Browse Source

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

Victor Oliveira 3 years ago
parent
commit
5deca5a18f
No account linked to committer's email address

+ 2
- 2
Marlin/src/HAL/LPC1768/HAL_SPI.cpp View File

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

+ 8
- 7
Marlin/src/HAL/LPC1768/include/SPI.h View File

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

+ 2
- 2
Marlin/src/HAL/LPC1768/tft/tft_spi.cpp View File

@@ -89,7 +89,7 @@ void TFT_SPI::Init() {
89 89
   #elif TFT_MISO_PIN == BOARD_SPI2_MISO_PIN
90 90
     SPIx.setModule(2);
91 91
   #endif
92
-  SPIx.setClock(SPI_CLOCK_MAX);
92
+  SPIx.setClock(SPI_CLOCK_MAX_TFT);
93 93
   SPIx.setBitOrder(MSBFIRST);
94 94
   SPIx.setDataMode(SPI_MODE0);
95 95
 }
@@ -125,7 +125,7 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) {
125 125
     }
126 126
 
127 127
     DataTransferEnd();
128
-    SPIx.setClock(SPI_CLOCK_MAX);
128
+    SPIx.setClock(SPI_CLOCK_MAX_TFT);
129 129
   #endif
130 130
 
131 131
   return data >> 7;

+ 53
- 0
Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h View File

@@ -249,6 +249,59 @@
249 249
     #define LCD_PINS_ENABLE                P1_22
250 250
     #define LCD_PINS_D4                    P0_17
251 251
 
252
+  #elif HAS_SPI_TFT                               // Config for Classic UI (emulated DOGM) and Color UI
253
+    #define TFT_CS_PIN                     P1_00
254
+    #define TFT_A0_PIN                     P1_22
255
+    #define TFT_DC_PIN                     P1_22
256
+    #define TFT_MISO_PIN                   P0_08
257
+    #define TFT_BACKLIGHT_PIN              P0_18
258
+    #define TFT_RESET_PIN                  P0_16
259
+
260
+    #define LCD_USE_DMA_SPI
261
+
262
+    #define TOUCH_INT_PIN                  P0_17
263
+    #define TOUCH_CS_PIN                   P0_15
264
+    #define TOUCH_BUTTONS_HW_SPI
265
+    #define TOUCH_BUTTONS_HW_SPI_DEVICE        2
266
+
267
+    // Disable any LCD related PINs config
268
+    #define LCD_PINS_ENABLE                -1
269
+    #define LCD_PINS_RS                    -1
270
+
271
+    // XPT2046 Touch Screen calibration
272
+    #if ENABLED(TFT_CLASSIC_UI)
273
+      #ifndef XPT2046_X_CALIBRATION
274
+        #define XPT2046_X_CALIBRATION     -11386
275
+      #endif
276
+      #ifndef XPT2046_Y_CALIBRATION
277
+        #define XPT2046_Y_CALIBRATION       8684
278
+      #endif
279
+      #ifndef XPT2046_X_OFFSET
280
+        #define XPT2046_X_OFFSET             689
281
+      #endif
282
+      #ifndef XPT2046_Y_OFFSET
283
+        #define XPT2046_Y_OFFSET            -273
284
+      #endif
285
+    #elif ENABLED(TFT_COLOR_UI)
286
+      #ifndef XPT2046_X_CALIBRATION
287
+        #define XPT2046_X_CALIBRATION     -16741
288
+      #endif
289
+      #ifndef XPT2046_Y_CALIBRATION
290
+        #define XPT2046_Y_CALIBRATION      11258
291
+      #endif
292
+      #ifndef XPT2046_X_OFFSET
293
+        #define XPT2046_X_OFFSET            1024
294
+      #endif
295
+      #ifndef XPT2046_Y_OFFSET
296
+        #define XPT2046_Y_OFFSET            -367
297
+      #endif
298
+
299
+      #define TFT_BUFFER_SIZE               2400
300
+    #endif
301
+
302
+    #define BTN_EN1                        P3_25
303
+    #define BTN_EN2                        P3_26
304
+
252 305
   #elif IS_TFTGLCD_PANEL
253 306
 
254 307
     #undef BEEPER_PIN

Loading…
Cancel
Save