Browse Source

LVGL and Classic UI for STM32 (#20552)

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

+ 0
- 1
Marlin/src/HAL/STM32/HAL_SPI.cpp View File

@@ -157,7 +157,6 @@ static SPISettings spiConfig;
157 157
       SPI.setMISO(MISO_PIN);
158 158
       SPI.setMOSI(MOSI_PIN);
159 159
       SPI.setSCLK(SCK_PIN);
160
-      SPI.setSSEL(SS_PIN);
161 160
     #endif
162 161
 
163 162
     SPI.begin();

+ 8
- 4
Marlin/src/HAL/STM32/MarlinSPI.cpp View File

@@ -60,7 +60,6 @@ void MarlinSPI::setupDma(SPI_HandleTypeDef &_spiHandle, DMA_HandleTypeDef &_dmaH
60 60
     _dmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
61 61
   }
62 62
   #ifdef STM32F4xx
63
-    _dmaHandle.Init.Channel = DMA_CHANNEL_3;
64 63
     _dmaHandle.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
65 64
   #endif
66 65
 
@@ -73,7 +72,8 @@ void MarlinSPI::setupDma(SPI_HandleTypeDef &_spiHandle, DMA_HandleTypeDef &_dmaH
73 72
         _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA1_Channel3 : DMA1_Channel2;
74 73
       #elif defined(STM32F4xx)
75 74
         __HAL_RCC_DMA2_CLK_ENABLE();
76
-        _dmaHandle.Instance = DMA2_Stream3;
75
+        _dmaHandle.Init.Channel = DMA_CHANNEL_3;
76
+        _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA2_Stream3 : DMA2_Stream0;
77 77
       #endif
78 78
     }
79 79
   #endif
@@ -83,7 +83,9 @@ void MarlinSPI::setupDma(SPI_HandleTypeDef &_spiHandle, DMA_HandleTypeDef &_dmaH
83 83
         __HAL_RCC_DMA1_CLK_ENABLE();
84 84
         _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA1_Channel5 : DMA1_Channel4;
85 85
       #elif defined(STM32F4xx)
86
-        //TODO: f4 dma config
86
+        __HAL_RCC_DMA1_CLK_ENABLE();
87
+        _dmaHandle.Init.Channel = DMA_CHANNEL_0;
88
+        _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA1_Stream4 : DMA1_Stream3;
87 89
       #endif
88 90
     }
89 91
   #endif
@@ -93,7 +95,9 @@ void MarlinSPI::setupDma(SPI_HandleTypeDef &_spiHandle, DMA_HandleTypeDef &_dmaH
93 95
         __HAL_RCC_DMA2_CLK_ENABLE();
94 96
         _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA2_Channel2 : DMA2_Channel1;
95 97
       #elif defined(STM32F4xx)
96
-        //TODO: f4 dma config
98
+        __HAL_RCC_DMA1_CLK_ENABLE();
99
+        _dmaHandle.Init.Channel = DMA_CHANNEL_0;
100
+        _dmaHandle.Instance = (direction == DMA_MEMORY_TO_PERIPH) ? DMA1_Stream5 : DMA1_Stream2;
97 101
       #endif
98 102
     }
99 103
   #endif

+ 14
- 16
Marlin/src/HAL/STM32/tft/tft_fsmc.cpp View File

@@ -154,29 +154,27 @@ uint32_t TFT_FSMC::ReadID(tft_data_t Reg) {
154 154
 }
155 155
 
156 156
 bool TFT_FSMC::isBusy() {
157
-  if (__IS_DMA_ENABLED(&DMAtx))
157
+  #if defined(STM32F1xx)
158
+    volatile bool dmaEnabled = (DMAtx.Instance->CCR & DMA_CCR_EN) != RESET;
159
+  #elif defined(STM32F4xx)
160
+    volatile bool dmaEnabled = DMAtx.Instance->CR & DMA_SxCR_EN;
161
+  #endif
162
+  if (dmaEnabled) {
158 163
     if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) != 0 || __HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) != 0)
159 164
       Abort();
160
-  return __IS_DMA_ENABLED(&DMAtx);
165
+  }
166
+  else
167
+    Abort();
168
+  return dmaEnabled;
161 169
 }
162 170
 
163 171
 void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) {
164 172
   DMAtx.Init.PeriphInc = MemoryIncrease;
165 173
   HAL_DMA_Init(&DMAtx);
166
-
167
-  __HAL_DMA_CLEAR_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx));
168
-  __HAL_DMA_CLEAR_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx));
169
-
170
-  #ifdef STM32F1xx
171
-    DMAtx.Instance->CNDTR = Count;
172
-    DMAtx.Instance->CPAR = (uint32_t)Data;
173
-    DMAtx.Instance->CMAR = (uint32_t)&(LCD->RAM);
174
-  #elif defined(STM32F4xx)
175
-    DMAtx.Instance->NDTR = Count;
176
-    DMAtx.Instance->PAR = (uint32_t)Data;
177
-    DMAtx.Instance->M0AR = (uint32_t)&(LCD->RAM);
178
-  #endif
179
-  __HAL_DMA_ENABLE(&DMAtx);
174
+  DataTransferBegin();
175
+  HAL_DMA_Start(&DMAtx, (uint32_t)Data, (uint32_t)&(LCD->RAM), Count);
176
+  HAL_DMA_PollForTransfer(&DMAtx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY);
177
+  Abort();
180 178
 }
181 179
 
182 180
 #endif // HAS_FSMC_TFT

+ 7
- 2
Marlin/src/HAL/STM32/tft/tft_fsmc.h View File

@@ -25,10 +25,8 @@
25 25
 
26 26
 #ifdef STM32F1xx
27 27
   #include "stm32f1xx_hal.h"
28
-  #define __IS_DMA_ENABLED(__HANDLE__)  ((__HANDLE__)->Instance->CCR & DMA_CCR_EN)
29 28
 #elif defined(STM32F4xx)
30 29
   #include "stm32f4xx_hal.h"
31
-  #define __IS_DMA_ENABLED(__HANDLE__)  ((__HANDLE__)->Instance->CR & DMA_SxCR_EN)
32 30
 #else
33 31
   #error "FSMC TFT is currently only supported on STM32F1 and STM32F4 hardware."
34 32
 #endif
@@ -77,6 +75,13 @@ class TFT_FSMC {
77 75
 
78 76
     static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); }
79 77
     static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); }
78
+    static void WriteMultiple(uint16_t Color, uint32_t Count) {
79
+      static uint16_t Data; Data = Color;
80
+      while (Count > 0) {
81
+        TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count);
82
+        Count = Count > 0xFFFF ? Count - 0xFFFF : 0;
83
+      }
84
+    }
80 85
 };
81 86
 
82 87
 

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

@@ -88,7 +88,7 @@ void TFT_SPI::Init() {
88 88
       #elif defined(STM32F4xx)
89 89
         __HAL_RCC_DMA1_CLK_ENABLE();
90 90
         DMAtx.Instance = DMA1_Stream4;
91
-        DMAtx.Init.Channel = DMA_CHANNEL_4;
91
+        DMAtx.Init.Channel = DMA_CHANNEL_0;
92 92
       #endif
93 93
     }
94 94
   #endif
@@ -101,7 +101,7 @@ void TFT_SPI::Init() {
101 101
       #elif defined(STM32F4xx)
102 102
         __HAL_RCC_DMA1_CLK_ENABLE();
103 103
         DMAtx.Instance = DMA1_Stream5;
104
-        DMAtx.Init.Channel = DMA_CHANNEL_5;
104
+        DMAtx.Init.Channel = DMA_CHANNEL_0;
105 105
       #endif
106 106
     }
107 107
   #endif
@@ -183,6 +183,9 @@ bool TFT_SPI::isBusy() {
183 183
 }
184 184
 
185 185
 void TFT_SPI::Abort() {
186
+  // Wait for any running spi
187
+  while ((SPIx.Instance->SR & SPI_FLAG_TXE) != SPI_FLAG_TXE) {}
188
+  while ((SPIx.Instance->SR & SPI_FLAG_BSY) == SPI_FLAG_BSY) {}
186 189
   // First, abort any running dma
187 190
   HAL_DMA_Abort(&DMAtx);
188 191
   // DeInit objects
@@ -223,6 +226,9 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun
223 226
   __HAL_SPI_ENABLE(&SPIx);
224 227
 
225 228
   SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN);   /* Enable Tx DMA Request */
229
+
230
+  HAL_DMA_PollForTransfer(&DMAtx, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY);
231
+  Abort();
226 232
 }
227 233
 
228 234
 #endif // HAS_SPI_TFT

+ 7
- 0
Marlin/src/HAL/STM32/tft/tft_spi.h View File

@@ -64,4 +64,11 @@ public:
64 64
 
65 65
   static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); }
66 66
   static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
67
+  static void WriteMultiple(uint16_t Color, uint32_t Count) {
68
+    static uint16_t Data; Data = Color;
69
+    while (Count > 0) {
70
+      TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count);
71
+      Count = Count > 0xFFFF ? Count - 0xFFFF : 0;
72
+    }
73
+  }
67 74
 };

+ 1
- 21
Marlin/src/HAL/STM32/tft/xpt2046.cpp View File

@@ -23,7 +23,7 @@
23 23
 
24 24
 #include "../../../inc/MarlinConfig.h"
25 25
 
26
-#if HAS_TFT_XPT2046
26
+#if HAS_TFT_XPT2046 || HAS_TOUCH_BUTTONS
27 27
 
28 28
 #include "xpt2046.h"
29 29
 #include "pinconfig.h"
@@ -31,7 +31,6 @@
31 31
 uint16_t delta(uint16_t a, uint16_t b) { return a > b ? a - b : b - a; }
32 32
 
33 33
 SPI_HandleTypeDef XPT2046::SPIx;
34
-DMA_HandleTypeDef XPT2046::DMAtx;
35 34
 
36 35
 void XPT2046::Init() {
37 36
   SPI_TypeDef *spiInstance;
@@ -71,34 +70,16 @@ void XPT2046::Init() {
71 70
       if (SPIx.Instance == SPI1) {
72 71
         __HAL_RCC_SPI1_CLK_ENABLE();
73 72
         SPIx.Init.BaudRatePrescaler  = SPI_BAUDRATEPRESCALER_16;
74
-        #ifdef STM32F1xx
75
-          DMAtx.Instance = DMA1_Channel3;
76
-        #elif defined(STM32F4xx)
77
-          DMAtx.Instance = DMA2_Stream3; // DMA2_Stream5
78
-        #endif
79
-        //SERIAL_ECHO_MSG(" Touch Screen on SPI1");
80 73
       }
81 74
     #endif
82 75
     #ifdef SPI2_BASE
83 76
       if (SPIx.Instance == SPI2) {
84 77
         __HAL_RCC_SPI2_CLK_ENABLE();
85
-        #ifdef STM32F1xx
86
-          DMAtx.Instance = DMA1_Channel5;
87
-        #elif defined(STM32F4xx)
88
-          DMAtx.Instance = DMA1_Stream4;
89
-        #endif
90
-        //SERIAL_ECHO_MSG(" Touch Screen on SPI2");
91 78
       }
92 79
     #endif
93 80
     #ifdef SPI3_BASE
94 81
       if (SPIx.Instance == SPI3) {
95 82
         __HAL_RCC_SPI3_CLK_ENABLE();
96
-        #ifdef STM32F1xx
97
-          DMAtx.Instance = DMA2_Channel2;
98
-        #elif defined(STM32F4xx)
99
-          DMAtx.Instance = DMA1_Stream5;  // DMA1_Stream7
100
-        #endif
101
-        //SERIAL_ECHO_MSG(" Touch Screen on SPI3");
102 83
       }
103 84
     #endif
104 85
   }
@@ -107,7 +88,6 @@ void XPT2046::Init() {
107 88
     SET_INPUT(TOUCH_MISO_PIN);
108 89
     SET_OUTPUT(TOUCH_MOSI_PIN);
109 90
     SET_OUTPUT(TOUCH_SCK_PIN);
110
-    //SERIAL_ECHO_MSG(" Touch Screen on Software SPI");
111 91
   }
112 92
 
113 93
   getRawData(XPT2046_Z1);

+ 1
- 4
Marlin/src/HAL/STM32/tft/xpt2046.h View File

@@ -23,10 +23,8 @@
23 23
 
24 24
 #ifdef STM32F1xx
25 25
   #include <stm32f1xx_hal.h>
26
-  #define __IS_DMA_ENABLED(__HANDLE__)  ((__HANDLE__)->Instance->CCR & DMA_CCR_EN)
27 26
 #elif defined(STM32F4xx)
28 27
   #include <stm32f4xx_hal.h>
29
-  #define __IS_DMA_ENABLED(__HANDLE__)  ((__HANDLE__)->Instance->CR & DMA_SxCR_EN)
30 28
 #endif
31 29
 
32 30
 #include "../../../inc/MarlinConfig.h"
@@ -65,9 +63,8 @@ enum XPTCoordinate : uint8_t {
65 63
 class XPT2046 {
66 64
 private:
67 65
   static SPI_HandleTypeDef SPIx;
68
-  static DMA_HandleTypeDef DMAtx;
69 66
 
70
-  static bool isBusy() { return SPIx.Instance ? __IS_DMA_ENABLED(&DMAtx) : false; }
67
+  static bool isBusy() { return false; }
71 68
 
72 69
   static uint16_t getRawData(const XPTCoordinate coordinate);
73 70
   static bool isTouched();

+ 1
- 1
Marlin/src/gcode/calibrate/G34.cpp View File

@@ -42,7 +42,7 @@ void GcodeSuite::G34() {
42 42
   if (!all_axes_trusted()) home_all_axes();
43 43
 
44 44
   TERN_(HAS_LEVELING, TEMPORARY_BED_LEVELING_STATE(false));
45
-  
45
+
46 46
   SET_SOFT_ENDSTOP_LOOSE(true);
47 47
   TemporaryGlobalEndstopsState unlock_z(false);
48 48
 

+ 1
- 1
Marlin/src/inc/Conditionals_LCD.h View File

@@ -1187,7 +1187,7 @@
1187 1187
 // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
1188 1188
 #if ENABLED(TOUCH_SCREEN) && !HAS_GRAPHICAL_TFT
1189 1189
   #undef TOUCH_SCREEN
1190
-  #if !HAS_TFT_LVGL_UI
1190
+  #if ENABLED(TFT_CLASSIC_UI)
1191 1191
     #define HAS_TOUCH_BUTTONS 1
1192 1192
   #endif
1193 1193
 #endif

+ 1
- 1
Marlin/src/inc/SanityCheck.h View File

@@ -3242,7 +3242,7 @@ static_assert(   _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
3242 3242
 /**
3243 3243
  * Touch Buttons
3244 3244
  */
3245
-#if ENABLED(TOUCH_SCREEN)
3245
+#if ENABLED(TOUCH_SCREEN) && DISABLED(TOUCH_SCREEN_CALIBRATION)
3246 3246
   #ifndef TOUCH_CALIBRATION_X
3247 3247
     #error "TOUCH_CALIBRATION_X must be defined with TOUCH_SCREEN."
3248 3248
   #endif

+ 8
- 9
Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp View File

@@ -339,6 +339,8 @@ static uint8_t page;
339 339
   }
340 340
 #endif // HAS_TOUCH_BUTTONS
341 341
 
342
+static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT
343
+
342 344
 uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
343 345
   u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
344 346
 
@@ -352,19 +354,21 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
352 354
   switch (msg) {
353 355
     case U8G_DEV_MSG_INIT:
354 356
       dev->com_fn(u8g, U8G_COM_MSG_INIT, U8G_SPI_CLK_CYCLE_NONE, nullptr);
355
-      tftio.Init();
356
-      tftio.InitTFT();
357
-      TERN_(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration_reset());
358 357
 
359 358
       if (preinit) {
360 359
         preinit = false;
361 360
         return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
362 361
       }
363 362
 
363
+      if (msgInitCount) return -1;
364
+      tftio.Init();
365
+      tftio.InitTFT();
366
+      TERN_(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration_reset());
367
+
364 368
       // Clear Screen
365 369
       setWindow(u8g, dev, 0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1);
366 370
       #if HAS_LCD_IO
367
-        tftio.WriteMultiple(TFT_MARLINBG_COLOR, uint32_t(TFT_WIDTH) * (TFT_HEIGHT));
371
+        tftio.WriteMultiple(TFT_MARLINBG_COLOR, (TFT_WIDTH) * (TFT_HEIGHT));
368 372
       #else
369 373
         memset2(buffer, TFT_MARLINBG_COLOR, (TFT_WIDTH) / 2);
370 374
         for (uint16_t i = 0; i < (TFT_HEIGHT) * sq(GRAPHICAL_TFT_UPSCALE); i++)
@@ -420,8 +424,6 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
420 424
   return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
421 425
 }
422 426
 
423
-static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT
424
-
425 427
 uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
426 428
   if (msgInitCount) {
427 429
     if (msg == U8G_COM_MSG_INIT) msgInitCount--;
@@ -433,8 +435,6 @@ uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_p
433 435
   switch (msg) {
434 436
     case U8G_COM_MSG_STOP: break;
435 437
     case U8G_COM_MSG_INIT:
436
-      u8g_SetPIOutput(u8g, U8G_PI_RESET);
437
-      u8g_Delay(50);
438 438
       isCommand = 0;
439 439
       break;
440 440
 
@@ -443,7 +443,6 @@ uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_p
443 443
       break;
444 444
 
445 445
     case U8G_COM_MSG_RESET:
446
-      u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
447 446
       break;
448 447
 
449 448
     case U8G_COM_MSG_WRITE_BYTE:

+ 1
- 1
Marlin/src/lcd/tft/tft.h View File

@@ -30,7 +30,7 @@
30 30
 
31 31
 #include "../../inc/MarlinConfig.h"
32 32
 
33
-#if TFT_INTERFACE_FSMC_8BIT
33
+#if ENABLED(TFT_INTERFACE_FSMC_8BIT)
34 34
   // When we have a 8 bit interface, we need to invert the bytes of the color
35 35
   #define ENDIAN_COLOR(C) (((C) >> 8) | ((C) << 8))
36 36
 #else

+ 1
- 1
Marlin/src/lcd/tft_io/tft_io.h View File

@@ -121,7 +121,7 @@ public:
121 121
   static void write_esc_sequence(const uint16_t *Sequence);
122 122
 
123 123
   // Deletaged methods
124
-  inline static void Init() { io.Init(); };
124
+  inline static void Init() { io.Init(); io.Abort(); };
125 125
   inline static bool isBusy() { return io.isBusy(); };
126 126
   inline static void Abort() { io.Abort(); };
127 127
   inline static uint32_t GetID() { return io.GetID(); };

+ 3
- 1
Marlin/src/lcd/touch/touch_buttons.cpp View File

@@ -32,6 +32,7 @@ XPT2046 touchIO;
32 32
 #endif
33 33
 
34 34
 #include "../marlinui.h" // For EN_C bit mask
35
+#include "../tft_io/tft_io.h"
35 36
 
36 37
 #define DOGM_AREA_LEFT   TFT_PIXEL_OFFSET_X
37 38
 #define DOGM_AREA_TOP    TFT_PIXEL_OFFSET_Y
@@ -49,7 +50,8 @@ uint8_t TouchButtons::read_buttons() {
49 50
   #ifdef HAS_WIRED_LCD
50 51
     int16_t x, y;
51 52
 
52
-    if (!touchIO.getRawPoint(&x, &y)) return 0;
53
+    const bool is_touched = (TERN(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration.orientation, TOUCH_ORIENTATION) == TOUCH_PORTRAIT ? touchIO.getRawPoint(&y, &x) : touchIO.getRawPoint(&x, &y));
54
+    if (!is_touched) return 0;
53 55
 
54 56
     #if ENABLED(TOUCH_SCREEN_CALIBRATION)
55 57
       const calibrationState state = touch_calibration.get_calibration_state();

+ 5
- 1
Marlin/src/pins/stm32f4/pins_ANET_ET4.h View File

@@ -139,11 +139,15 @@
139 139
 #define TFT_RS_PIN                          PD13
140 140
 #define TFT_INTERFACE_FSMC_8BIT
141 141
 
142
+#define LCD_USE_DMA_FSMC                          // Use DMA transfers to send data to the TFT
143
+#define FSMC_CS_PIN                   TFT_CS_PIN
144
+#define FSMC_RS_PIN                   TFT_RS_PIN
145
+
142 146
 //
143 147
 // Touch Screen
144 148
 // https://ldm-systems.ru/f/doc/catalog/HY-TFT-2,8/XPT2046.pdf
145 149
 //
146
-#if ENABLED(TOUCH_SCREEN)
150
+#if NEED_TOUCH_PINS
147 151
   #define TOUCH_CS_PIN                      PB2
148 152
   #define TOUCH_SCK_PIN                     PB0
149 153
   #define TOUCH_MOSI_PIN                    PE5

+ 2
- 22
Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h View File

@@ -32,7 +32,7 @@
32 32
 #define BOARD_INFO_NAME "MKS Robin Nano V3"
33 33
 
34 34
 // Avoid conflict with TIMER_TONE
35
-#define STEP_TIMER 13
35
+#define STEP_TIMER 10
36 36
 
37 37
 // Use one of these or SDCard-based Emulation will be used
38 38
 //#define SRAM_EEPROM_EMULATION                   // Use BackSRAM-based EEPROM emulation
@@ -255,7 +255,7 @@
255 255
  *                EXP1                                               EXP2
256 256
  */
257 257
 
258
-#if EITHER(TFT_480x320_SPI, TFT_LVGL_UI_SPI)
258
+#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI)
259 259
   #ifndef TOUCH_CALIBRATION_X
260 260
     #define TOUCH_CALIBRATION_X           -17253
261 261
   #endif
@@ -345,26 +345,6 @@
345 345
     #define BOARD_ST7920_DELAY_3    DELAY_NS(600)
346 346
 
347 347
   #endif // !MKS_MINI_12864
348
-
349
-#elif ENABLED(SPI_GRAPHICAL_TFT)
350
-  #define SPI_TFT_CS_PIN                    PD11
351
-  #define SPI_TFT_SCK_PIN                   PA5
352
-  #define SPI_TFT_MISO_PIN                  PA6
353
-  #define SPI_TFT_MOSI_PIN                  PA7
354
-  #define SPI_TFT_DC_PIN                    PD10
355
-  #define SPI_TFT_RST_PIN                   PC6
356
-
357
-  #define LCD_BACKLIGHT_PIN                 PD13
358
-
359
-  #define TOUCH_CS_PIN                      PE14  // SPI1_NSS
360
-  #define TOUCH_SCK_PIN                     PA5   // SPI1_SCK
361
-  #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
362
-  #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
363
-
364
-  #define BTN_EN1                           PE8
365
-  #define BTN_EN2                           PE11
366
-  #define BEEPER_PIN                        PC5
367
-  #define BTN_ENC                           PE13
368 348
 #endif // HAS_SPI_LCD
369 349
 
370 350
 #define HAS_OTG_USB_HOST_SUPPORT

+ 3
- 23
Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h View File

@@ -30,7 +30,7 @@
30 30
 #define BOARD_INFO_NAME "MKS Robin PRO V2"
31 31
 
32 32
 // Avoid conflict with TIMER_TONE
33
-#define STEP_TIMER 13
33
+#define STEP_TIMER 10
34 34
 
35 35
 // Use one of these or SDCard-based Emulation will be used
36 36
 //#define SRAM_EEPROM_EMULATION                   // Use BackSRAM-based EEPROM emulation
@@ -243,7 +243,7 @@
243 243
 //
244 244
 // LCD / Controller
245 245
 #define SPI_FLASH
246
-// #define HAS_SPI_FLASH 1
246
+#define HAS_SPI_FLASH 1
247 247
 #define SPI_DEVICE                             2
248 248
 #define SPI_FLASH_SIZE                 0x1000000
249 249
 #if ENABLED(SPI_FLASH)
@@ -264,7 +264,7 @@
264 264
  *                EXP1                                               EXP2
265 265
  */
266 266
 
267
-#if EITHER(TFT_480x320_SPI, TFT_LVGL_UI_SPI)
267
+#if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI)
268 268
   #ifndef TOUCH_CALIBRATION_X
269 269
     #define TOUCH_CALIBRATION_X           -17253
270 270
   #endif
@@ -361,24 +361,4 @@
361 361
     #endif
362 362
 
363 363
   #endif // !MKS_MINI_12864
364
-
365
-#elif ENABLED(SPI_GRAPHICAL_TFT)
366
-  #define SPI_TFT_CS_PIN                    PD11
367
-  #define SPI_TFT_SCK_PIN                   PA5
368
-  #define SPI_TFT_MISO_PIN                  PA6
369
-  #define SPI_TFT_MOSI_PIN                  PA7
370
-  #define SPI_TFT_DC_PIN                    PD10
371
-  #define SPI_TFT_RST_PIN                   PC6
372
-
373
-  #define LCD_BACKLIGHT_PIN                 PD13
374
-
375
-  #define TOUCH_CS_PIN                      PE14  // SPI1_NSS
376
-  #define TOUCH_SCK_PIN                     PA5   // SPI1_SCK
377
-  #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
378
-  #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
379
-
380
-  #define BTN_EN1                           PE8
381
-  #define BTN_EN2                           PE11
382
-  #define BEEPER_PIN                        PC5
383
-  #define BTN_ENC                           PE13
384 364
 #endif // HAS_SPI_LCD

+ 14
- 0
buildroot/share/PlatformIO/scripts/anet_et4_openblt.py View File

@@ -0,0 +1,14 @@
1
+# Generate the firmware as OpenBLT needs
2
+
3
+import os,sys
4
+from os.path import join
5
+
6
+Import("env")
7
+
8
+env.AddPostAction(
9
+    "$BUILD_DIR/${PROGNAME}.elf",
10
+    env.VerboseAction(" ".join([
11
+        "$OBJCOPY", "-O", "srec",
12
+        "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"$BUILD_DIR/${PROGNAME}.srec\""
13
+    ]), "Building " + join("$BUILD_DIR","${PROGNAME}.srec"))
14
+)

+ 5
- 5
buildroot/share/PlatformIO/scripts/stm32_bootloader.py View File

@@ -6,9 +6,7 @@ board = DefaultEnvironment().BoardConfig()
6 6
 
7 7
 def noencrypt(source, target, env):
8 8
   firmware = os.path.join(target[0].dir.path, board.get("build.firmware"))
9
-  # do not overwrite encrypted firmware if present
10
-  if not os.path.isfile(firmware):
11
-    shutil.copy(target[0].path, firmware)
9
+  shutil.copy(target[0].path, firmware)
12 10
 
13 11
 if 'offset' in board.get("build").keys():
14 12
   LD_FLASH_OFFSET = board.get("build.offset")
@@ -26,5 +24,7 @@ if 'offset' in board.get("build").keys():
26 24
     if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag:
27 25
       env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
28 26
 
29
-  if 'firmware' in board.get("build").keys():
30
-    env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt);
27
+board_keys = board.get("build").keys()
28
+# Only copy file if there's no encryptation
29
+if 'firmware' in board_keys and not 'encrypt' in board_keys:
30
+  env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt)

+ 2
- 2
buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/PeripheralPins.c View File

@@ -254,7 +254,7 @@ WEAK const PinMap PinMap_SPI_MOSI[] = {
254 254
   {PA_7,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
255 255
   //  {PB_5,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
256 256
   {PB_5,  SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
257
-  // {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
257
+  {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
258 258
   {PC_3,  SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
259 259
   {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
260 260
   {NC,    NP,    0}
@@ -266,7 +266,7 @@ WEAK const PinMap PinMap_SPI_MISO[] = {
266 266
   {PA_6,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
267 267
   //  {PB_4,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
268 268
   {PB_4,  SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
269
-  // {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
269
+  {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
270 270
   {PC_2,  SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
271 271
   {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
272 272
   {NC,    NP,    0}

+ 20
- 15
platformio.ini View File

@@ -970,6 +970,7 @@ board_build.core     = stm32
970 970
 board_build.variant  = MARLIN_F103Zx
971 971
 board_build.ldscript = ldscript.ld
972 972
 board_build.offset   = 0x7000
973
+board_build.encrypt  = Yes
973 974
 board_build.firmware = Robin.bin
974 975
 build_flags          = ${common_stm32.build_flags}
975 976
   -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 -DTIMER_SERIAL=TIM5
@@ -1155,6 +1156,7 @@ board_build.variant  = MARLIN_F103Vx
1155 1156
 board_build.ldscript = ldscript.ld
1156 1157
 board_build.offset   = 0x7000
1157 1158
 board_build.firmware = Robin_mini.bin
1159
+board_build.encrypt  = Yes
1158 1160
 board_upload.offset_address = 0x08007000
1159 1161
 build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
1160 1162
 extra_scripts        = ${common.extra_scripts}
@@ -1247,6 +1249,8 @@ board_build.core     = stm32
1247 1249
 board_build.variant  = MARLIN_F4x7Vx
1248 1250
 board_build.ldscript = ldscript.ld
1249 1251
 board_build.firmware = firmware.srec
1252
+# Just anet_et4_openblt.py generates the file, not stm32_bootloader.py
1253
+board_build.encrypt  = Yes
1250 1254
 board_build.offset   = 0x10000
1251 1255
 board_upload.offset_address = 0x08010000
1252 1256
 build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483
@@ -1255,6 +1259,7 @@ upload_protocol      = jlink
1255 1259
 extra_scripts        = ${common.extra_scripts}
1256 1260
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1257 1261
   buildroot/share/PlatformIO/scripts/stm32_bootloader.py
1262
+  buildroot/share/PlatformIO/scripts/anet_et4_openblt.py
1258 1263
 
1259 1264
 #
1260 1265
 # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4)
@@ -1304,19 +1309,20 @@ extra_scripts     = ${common.extra_scripts}
1304 1309
 # Lerdge base
1305 1310
 #
1306 1311
 [lerdge_common]
1307
-platform           = ${common_stm32.platform}
1308
-extends            = common_stm32
1309
-board              = LERDGE
1310
-board_build.offset = 0x10000
1311
-extra_scripts      = ${common.extra_scripts}
1312
-                     pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py
1313
-                     buildroot/share/PlatformIO/scripts/stm32_bootloader.py
1314
-                     buildroot/share/PlatformIO/scripts/lerdge.py
1315
-build_flags        = ${common_stm32.build_flags}
1312
+platform            = ${common_stm32.platform}
1313
+extends             = common_stm32
1314
+board               = LERDGE
1315
+board_build.offset  = 0x10000
1316
+board_build.encrypt = Yes
1317
+extra_scripts       = ${common.extra_scripts}
1318
+                      pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py
1319
+                      buildroot/share/PlatformIO/scripts/stm32_bootloader.py
1320
+                      buildroot/share/PlatformIO/scripts/lerdge.py
1321
+build_flags         = ${common_stm32.build_flags}
1316 1322
   -DSTM32F4 -DSTM32F4xx -DTARGET_STM32F4
1317 1323
   -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 -DARDUINO_LERDGE
1318 1324
   -DTRANSFER_CLOCK_DIV=8 -DHAL_SRAM_MODULE_ENABLED
1319
-build_unflags      = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483
1325
+build_unflags       = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483
1320 1326
 
1321 1327
 #
1322 1328
 # Lerdge X
@@ -1369,6 +1375,7 @@ board_build.core     = stm32
1369 1375
 board_build.variant  = MARLIN_F103Vx
1370 1376
 board_build.ldscript = ldscript.ld
1371 1377
 board_build.offset   = 0x7000
1378
+board_build.encrypt  = Yes
1372 1379
 board_build.firmware = Robin_nano35.bin
1373 1380
 board_upload.offset_address = 0x08007000
1374 1381
 build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
@@ -1385,19 +1392,18 @@ extra_scripts        = ${common.extra_scripts}
1385 1392
 [env:mks_robin_pro2]
1386 1393
 platform             = ${common_stm32.platform}
1387 1394
 extends              = common_stm32
1388
-build_flags          = ${common_stm32.build_flags} -DHAL_HCD_MODULE_ENABLED  -DUSBHOST -DARDUINO_BLACK_F407VE
1395
+build_flags          = ${common_stm32.build_flags} -DHAL_HCD_MODULE_ENABLED -DUSBHOST
1389 1396
 board                = genericSTM32F407VET6
1390 1397
 board_build.core     = stm32
1391
-board_build.variant  = MARLIN_F407VE
1398
+board_build.variant  = MARLIN_F4x7Vx
1392 1399
 board_build.ldscript = ldscript.ld
1393
-board_build.firmware = Robin_nano35.bin
1400
+board_build.firmware = firmware.bin
1394 1401
 build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
1395 1402
 debug_tool           = jlink
1396 1403
 upload_protocol      = jlink
1397 1404
 extra_scripts        = ${common.extra_scripts}
1398 1405
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1399 1406
   buildroot/share/PlatformIO/scripts/stm32_bootloader.py
1400
-  buildroot/share/PlatformIO/scripts/mks_encrypt.py
1401 1407
 
1402 1408
 #
1403 1409
 # MKS Robin Nano V3
@@ -1419,7 +1425,6 @@ upload_protocol      = jlink
1419 1425
 extra_scripts        = ${common.extra_scripts}
1420 1426
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1421 1427
   buildroot/share/PlatformIO/scripts/stm32_bootloader.py
1422
-  buildroot/share/PlatformIO/scripts/mks_encrypt.py
1423 1428
 
1424 1429
 #################################
1425 1430
 #                               #

Loading…
Cancel
Save