瀏覽代碼

✨ BigTreeTech SKR3 - STM32H743 (#24271)

Co-authored-by: Alan.Ma <alansayyeah@gmail.com>
BIGTREETECH 2 年之前
父節點
當前提交
eda61a2cbd
No account linked to committer's email address

+ 162
- 215
Marlin/src/HAL/STM32/sdio.cpp 查看文件

@@ -35,42 +35,15 @@
35 35
 
36 36
 // use local drivers
37 37
 #if defined(STM32F103xE) || defined(STM32F103xG)
38
-  #include <stm32f1xx_hal_rcc_ex.h>
39
-  #include <stm32f1xx_hal_sd.h>
38
+  #include <stm32f1xx.h>
40 39
 #elif defined(STM32F4xx)
41
-  #include <stm32f4xx_hal_rcc.h>
42
-  #include <stm32f4xx_hal_dma.h>
43
-  #include <stm32f4xx_hal_gpio.h>
44
-  #include <stm32f4xx_hal_sd.h>
40
+  #include <stm32f4xx.h>
45 41
 #elif defined(STM32F7xx)
46
-  #include <stm32f7xx_hal_rcc.h>
47
-  #include <stm32f7xx_hal_dma.h>
48
-  #include <stm32f7xx_hal_gpio.h>
49
-  #include <stm32f7xx_hal_sd.h>
42
+  #include <stm32f7xx.h>
43
+#elif defined(STM32H7xx)
44
+  #include <stm32h7xx.h>
50 45
 #else
51
-  #error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, or STM32F7xx."
52
-#endif
53
-
54
-SD_HandleTypeDef hsd;  // create SDIO structure
55
-// F4 supports one DMA for RX and another for TX, but Marlin will never
56
-// do read and write at same time, so we use the same DMA for both.
57
-DMA_HandleTypeDef hdma_sdio;
58
-
59
-/*
60
-  SDIO_INIT_CLK_DIV is 118
61
-  SDIO clock frequency is 48MHz / (TRANSFER_CLOCK_DIV + 2)
62
-  SDIO init clock frequency should not exceed 400kHz = 48MHz / (118 + 2)
63
-
64
-  Default TRANSFER_CLOCK_DIV is 2 (118 / 40)
65
-  Default SDIO clock frequency is 48MHz / (2 + 2) = 12 MHz
66
-  This might be too fast for stable SDIO operations
67
-
68
-  MKS Robin board seems to have stable SDIO with BusWide 1bit and ClockDiv 8 i.e. 4.8MHz SDIO clock frequency
69
-  Additional testing is required as there are clearly some 4bit initialization problems
70
-*/
71
-
72
-#ifndef USBD_OK
73
-  #define USBD_OK 0
46
+  #error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, STM32F7xx, or STM32H7xx."
74 47
 #endif
75 48
 
76 49
 // Target Clock, configurable. Default is 18MHz, from STM32F1
@@ -78,223 +51,208 @@ DMA_HandleTypeDef hdma_sdio;
78 51
   #define SDIO_CLOCK 18000000 // 18 MHz
79 52
 #endif
80 53
 
81
-// SDIO retries, configurable. Default is 3, from STM32F1
82
-#ifndef SDIO_READ_RETRIES
83
-  #define SDIO_READ_RETRIES 3
84
-#endif
54
+#define SD_TIMEOUT              1000 // ms
85 55
 
86 56
 // SDIO Max Clock (naming from STM Manual, don't change)
87 57
 #define SDIOCLK 48000000
88 58
 
89
-static uint32_t clock_to_divider(uint32_t clk) {
90
-  // limit the SDIO master clock to 8/3 of PCLK2. See STM32 Manuals
91
-  // Also limited to no more than 48Mhz (SDIOCLK).
92
-  const uint32_t pclk2 = HAL_RCC_GetPCLK2Freq();
93
-  clk = min(clk, (uint32_t)(pclk2 * 8 / 3));
94
-  clk = min(clk, (uint32_t)SDIOCLK);
95
-  // Round up divider, so we don't run the card over the speed supported,
96
-  // and subtract by 2, because STM32 will add 2, as written in the manual:
97
-  // SDIO_CK frequency = SDIOCLK / [CLKDIV + 2]
98
-  return pclk2 / clk + (pclk2 % clk != 0) - 2;
99
-}
100
-
101
-void go_to_transfer_speed() {
102
-  /* Default SDIO peripheral configuration for SD card initialization */
103
-  hsd.Init.ClockEdge           = hsd.Init.ClockEdge;
104
-  hsd.Init.ClockBypass         = hsd.Init.ClockBypass;
105
-  hsd.Init.ClockPowerSave      = hsd.Init.ClockPowerSave;
106
-  hsd.Init.BusWide             = hsd.Init.BusWide;
107
-  hsd.Init.HardwareFlowControl = hsd.Init.HardwareFlowControl;
108
-  hsd.Init.ClockDiv            = clock_to_divider(SDIO_CLOCK);
109
-
110
-  /* Initialize SDIO peripheral interface with default configuration */
111
-  SDIO_Init(hsd.Instance, hsd.Init);
112
-}
113
-
114
-void SD_LowLevel_Init(void) {
115
-  uint32_t tempreg;
59
+#if defined(STM32F1xx)
60
+  DMA_HandleTypeDef hdma_sdio;
61
+  extern "C" void DMA2_Channel4_5_IRQHandler(void) {
62
+    HAL_DMA_IRQHandler(&hdma_sdio);
63
+  }
64
+#elif defined(STM32F4xx)
65
+  DMA_HandleTypeDef hdma_sdio_rx;
66
+  DMA_HandleTypeDef hdma_sdio_tx;
67
+  extern "C" void DMA2_Stream3_IRQHandler(void) {
68
+    HAL_DMA_IRQHandler(&hdma_sdio_rx);
69
+  }
116 70
 
117
-  __HAL_RCC_GPIOC_CLK_ENABLE(); //enable GPIO clocks
118
-  __HAL_RCC_GPIOD_CLK_ENABLE(); //enable GPIO clocks
71
+  extern "C" void DMA2_Stream6_IRQHandler(void) {
72
+    HAL_DMA_IRQHandler(&hdma_sdio_tx);
73
+  }
74
+#elif defined(STM32H7xx)
75
+  #define __HAL_RCC_SDIO_FORCE_RESET          __HAL_RCC_SDMMC1_FORCE_RESET
76
+  #define __HAL_RCC_SDIO_RELEASE_RESET        __HAL_RCC_SDMMC1_RELEASE_RESET
77
+  #define __HAL_RCC_SDIO_CLK_ENABLE           __HAL_RCC_SDMMC1_CLK_ENABLE
78
+  #define SDIO                                SDMMC1
79
+  #define SDIO_IRQn                           SDMMC1_IRQn
80
+  #define SDIO_IRQHandler                     SDMMC1_IRQHandler
81
+  #define SDIO_CLOCK_EDGE_RISING              SDMMC_CLOCK_EDGE_RISING
82
+  #define SDIO_CLOCK_POWER_SAVE_DISABLE       SDMMC_CLOCK_POWER_SAVE_DISABLE
83
+  #define SDIO_BUS_WIDE_1B                    SDMMC_BUS_WIDE_1B
84
+  #define SDIO_BUS_WIDE_4B                    SDMMC_BUS_WIDE_4B
85
+  #define SDIO_HARDWARE_FLOW_CONTROL_DISABLE  SDMMC_HARDWARE_FLOW_CONTROL_DISABLE
86
+#endif
119 87
 
120
-  GPIO_InitTypeDef  GPIO_InitStruct;
88
+uint8_t waitingRxCplt = 0;
89
+uint8_t waitingTxCplt = 0;
90
+SD_HandleTypeDef hsd;
121 91
 
122
-  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
123
-  GPIO_InitStruct.Pull = 1;  //GPIO_NOPULL;
124
-  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
92
+extern "C" void SDIO_IRQHandler(void) {
93
+  HAL_SD_IRQHandler(&hsd);
94
+}
125 95
 
126
-  #if DISABLED(STM32F1xx)
127
-    GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
128
-  #endif
96
+void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsdio) {
97
+  waitingTxCplt = 0;
98
+}
129 99
 
130
-  GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_12;  // D0 & SCK
131
-  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
100
+void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsdio) {
101
+  waitingRxCplt = 0;
102
+}
132 103
 
104
+void HAL_SD_MspInit(SD_HandleTypeDef *hsd) {
105
+  pinmap_pinout(PC_12, PinMap_SD);
106
+  pinmap_pinout(PD_2, PinMap_SD);
107
+  pinmap_pinout(PC_8, PinMap_SD);
133 108
   #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3)  // define D1-D3 only if have a four bit wide SDIO bus
134
-    GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11;  // D1-D3
135
-    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
109
+    // D1-D3
110
+    pinmap_pinout(PC_9, PinMap_SD);
111
+    pinmap_pinout(PC_10, PinMap_SD);
112
+    pinmap_pinout(PC_11, PinMap_SD);
136 113
   #endif
137 114
 
138
-  // Configure PD.02 CMD line
139
-  GPIO_InitStruct.Pin = GPIO_PIN_2;
140
-  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
115
+  __HAL_RCC_SDIO_CLK_ENABLE();
116
+  HAL_NVIC_EnableIRQ(SDIO_IRQn);
141 117
 
142
-  // Setup DMA
118
+  // DMA Config
143 119
   #if defined(STM32F1xx)
144
-    hdma_sdio.Init.Mode = DMA_NORMAL;
145
-    hdma_sdio.Instance = DMA2_Channel4;
120
+    __HAL_RCC_DMA2_CLK_ENABLE();
146 121
     HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn);
122
+    hdma_sdio.Instance = DMA2_Channel4;
123
+    hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY;
124
+    hdma_sdio.Init.PeriphInc = DMA_PINC_DISABLE;
125
+    hdma_sdio.Init.MemInc = DMA_MINC_ENABLE;
126
+    hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
127
+    hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
128
+    hdma_sdio.Init.Mode = DMA_NORMAL;
129
+    hdma_sdio.Init.Priority = DMA_PRIORITY_LOW;
130
+    HAL_DMA_Init(&hdma_sdio);
131
+
132
+    __HAL_LINKDMA(hsd, hdmarx ,hdma_sdio);
133
+    __HAL_LINKDMA(hsd, hdmatx, hdma_sdio);
147 134
   #elif defined(STM32F4xx)
148
-    hdma_sdio.Init.Mode = DMA_PFCTRL;
149
-    hdma_sdio.Instance = DMA2_Stream3;
150
-    hdma_sdio.Init.Channel = DMA_CHANNEL_4;
151
-    hdma_sdio.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
152
-    hdma_sdio.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
153
-    hdma_sdio.Init.MemBurst = DMA_MBURST_INC4;
154
-    hdma_sdio.Init.PeriphBurst = DMA_PBURST_INC4;
135
+    __HAL_RCC_DMA2_CLK_ENABLE();
155 136
     HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn);
137
+    HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn);
138
+    hdma_sdio_rx.Instance = DMA2_Stream3;
139
+    hdma_sdio_rx.Init.Channel = DMA_CHANNEL_4;
140
+    hdma_sdio_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
141
+    hdma_sdio_rx.Init.PeriphInc = DMA_PINC_DISABLE;
142
+    hdma_sdio_rx.Init.MemInc = DMA_MINC_ENABLE;
143
+    hdma_sdio_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
144
+    hdma_sdio_rx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
145
+    hdma_sdio_rx.Init.Mode = DMA_PFCTRL;
146
+    hdma_sdio_rx.Init.Priority = DMA_PRIORITY_LOW;
147
+    hdma_sdio_rx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
148
+    hdma_sdio_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
149
+    hdma_sdio_rx.Init.MemBurst = DMA_MBURST_INC4;
150
+    hdma_sdio_rx.Init.PeriphBurst = DMA_PBURST_INC4;
151
+    HAL_DMA_Init(&hdma_sdio_rx);
152
+
153
+    __HAL_LINKDMA(hsd,hdmarx,hdma_sdio_rx);
154
+
155
+    hdma_sdio_tx.Instance = DMA2_Stream6;
156
+    hdma_sdio_tx.Init.Channel = DMA_CHANNEL_4;
157
+    hdma_sdio_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
158
+    hdma_sdio_tx.Init.PeriphInc = DMA_PINC_DISABLE;
159
+    hdma_sdio_tx.Init.MemInc = DMA_MINC_ENABLE;
160
+    hdma_sdio_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
161
+    hdma_sdio_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
162
+    hdma_sdio_tx.Init.Mode = DMA_PFCTRL;
163
+    hdma_sdio_tx.Init.Priority = DMA_PRIORITY_LOW;
164
+    hdma_sdio_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
165
+    hdma_sdio_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
166
+    hdma_sdio_tx.Init.MemBurst = DMA_MBURST_INC4;
167
+    hdma_sdio_tx.Init.PeriphBurst = DMA_PBURST_INC4;
168
+    HAL_DMA_Init(&hdma_sdio_tx);
169
+
170
+    __HAL_LINKDMA(hsd,hdmatx,hdma_sdio_tx);
156 171
   #endif
157
-  HAL_NVIC_EnableIRQ(SDIO_IRQn);
158
-  hdma_sdio.Init.PeriphInc = DMA_PINC_DISABLE;
159
-  hdma_sdio.Init.MemInc = DMA_MINC_ENABLE;
160
-  hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
161
-  hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
162
-  hdma_sdio.Init.Priority = DMA_PRIORITY_LOW;
163
-  __HAL_LINKDMA(&hsd, hdmarx, hdma_sdio);
164
-  __HAL_LINKDMA(&hsd, hdmatx, hdma_sdio);
172
+}
165 173
 
166
-  #if defined(STM32F1xx)
167
-    __HAL_RCC_SDIO_CLK_ENABLE();
168
-    __HAL_RCC_DMA2_CLK_ENABLE();
169
-  #else
174
+void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) {
175
+  #if !defined(STM32F1xx)
170 176
     __HAL_RCC_SDIO_FORCE_RESET();
171
-    delay(2);
177
+    delay(10);
172 178
     __HAL_RCC_SDIO_RELEASE_RESET();
173
-    delay(2);
174
-    __HAL_RCC_SDIO_CLK_ENABLE();
175
-
176
-    __HAL_RCC_DMA2_FORCE_RESET();
177
-    delay(2);
178
-    __HAL_RCC_DMA2_RELEASE_RESET();
179
-    delay(2);
180
-    __HAL_RCC_DMA2_CLK_ENABLE();
179
+    delay(10);
181 180
   #endif
182
-
183
-  //Initialize the SDIO (with initial <400Khz Clock)
184
-  tempreg = 0;  //Reset value
185
-  tempreg |= SDIO_CLKCR_CLKEN;  // Clock enabled
186
-  tempreg |= SDIO_INIT_CLK_DIV; // Clock Divider. Clock = 48000 / (118 + 2) = 400Khz
187
-  // Keep the rest at 0 => HW_Flow Disabled, Rising Clock Edge, Disable CLK ByPass, Bus Width = 0, Power save Disable
188
-  SDIO->CLKCR = tempreg;
189
-
190
-  // Power up the SDIO
191
-  SDIO_PowerState_ON(SDIO);
192
-  hsd.Instance = SDIO;
193 181
 }
194 182
 
195
-void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { // application specific init
196
-  UNUSED(hsd);   // Prevent unused argument(s) compilation warning
197
-  __HAL_RCC_SDIO_CLK_ENABLE();  // turn on SDIO clock
183
+static uint32_t clock_to_divider(uint32_t clk) {
184
+  #if defined(STM32H7xx)
185
+    // SDMMC_CK frequency = sdmmc_ker_ck / [2 * CLKDIV].
186
+    uint32_t sdmmc_clk     = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SDMMC);
187
+    return sdmmc_clk / (2U * SDIO_CLOCK) + (sdmmc_clk % (2U * SDIO_CLOCK) != 0);
188
+  #else
189
+    // limit the SDIO master clock to 8/3 of PCLK2. See STM32 Manuals
190
+    // Also limited to no more than 48Mhz (SDIOCLK).
191
+    const uint32_t pclk2 = HAL_RCC_GetPCLK2Freq();
192
+    clk = min(clk, (uint32_t)(pclk2 * 8 / 3));
193
+    clk = min(clk, (uint32_t)SDIOCLK);
194
+    // Round up divider, so we don't run the card over the speed supported,
195
+    // and subtract by 2, because STM32 will add 2, as written in the manual:
196
+    // SDIO_CK frequency = SDIOCLK / [CLKDIV + 2]
197
+    return pclk2 / clk + (pclk2 % clk != 0) - 2;
198
+  #endif
198 199
 }
199 200
 
200 201
 bool SDIO_Init() {
201
-  uint8_t retryCnt = SDIO_READ_RETRIES;
202
+  HAL_StatusTypeDef sd_state = HAL_OK;
203
+  HAL_SD_DeInit(&hsd);
202 204
 
203
-  bool status;
205
+  /* HAL SD initialization */
204 206
   hsd.Instance = SDIO;
205
-  hsd.State = HAL_SD_STATE_RESET;
206
-
207
-  SD_LowLevel_Init();
208
-
209
-  uint8_t retry_Cnt = retryCnt;
210
-  for (;;) {
211
-    hal.watchdog_refresh();
212
-    status = (bool) HAL_SD_Init(&hsd);
213
-    if (!status) break;
214
-    if (!--retry_Cnt) return false;   // return failing status if retries are exhausted
215
-  }
216
-
217
-  go_to_transfer_speed();
218
-
219
-  #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined
220
-    retry_Cnt = retryCnt;
221
-    for (;;) {
222
-      hal.watchdog_refresh();
223
-      if (!HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B)) break;  // some cards are only 1 bit wide so a pass here is not required
224
-      if (!--retry_Cnt) break;
225
-    }
226
-    if (!retry_Cnt) {  // wide bus failed, go back to one bit wide mode
227
-      hsd.State = (HAL_SD_StateTypeDef) 0;  // HAL_SD_STATE_RESET
228
-      SD_LowLevel_Init();
229
-      retry_Cnt = retryCnt;
230
-      for (;;) {
231
-        hal.watchdog_refresh();
232
-        status = (bool) HAL_SD_Init(&hsd);
233
-        if (!status) break;
234
-        if (!--retry_Cnt) return false;   // return failing status if retries are exhausted
235
-      }
236
-      go_to_transfer_speed();
207
+  hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
208
+  hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
209
+  hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
210
+  hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
211
+  hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK);
212
+  sd_state = HAL_SD_Init(&hsd);
213
+
214
+  #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3)
215
+    if (sd_state == HAL_OK) {
216
+      sd_state = HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B);
237 217
     }
238 218
   #endif
239 219
 
240
-  return true;
220
+  return (sd_state == HAL_OK) ? true : false;
241 221
 }
242 222
 
243
-static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t *src, uint8_t *dst) {
244
-  if (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false;
245
-
246
-  hal.watchdog_refresh();
223
+bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
224
+  uint32_t timeout = HAL_GetTick() + SD_TIMEOUT;
247 225
 
248
-  HAL_StatusTypeDef ret;
249
-  if (src) {
250
-    hdma_sdio.Init.Direction = DMA_MEMORY_TO_PERIPH;
251
-    HAL_DMA_Init(&hdma_sdio);
252
-    ret = HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)src, block, 1);
253
-  }
254
-  else {
255
-    hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY;
256
-    HAL_DMA_Init(&hdma_sdio);
257
-    ret = HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)dst, block, 1);
226
+  while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) {
227
+    if (HAL_GetTick() >= timeout) return false;
258 228
   }
259 229
 
260
-  if (ret != HAL_OK) {
261
-    HAL_DMA_Abort_IT(&hdma_sdio);
262
-    HAL_DMA_DeInit(&hdma_sdio);
230
+  waitingRxCplt = 1;
231
+  if (HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)dst, block, 1) != HAL_OK)
263 232
     return false;
264
-  }
265 233
 
266
-  millis_t timeout = millis() + 500;
267
-  // Wait the transfer
268
-  while (hsd.State != HAL_SD_STATE_READY) {
269
-    if (ELAPSED(millis(), timeout)) {
270
-      HAL_DMA_Abort_IT(&hdma_sdio);
271
-      HAL_DMA_DeInit(&hdma_sdio);
272
-      return false;
273
-    }
274
-  }
234
+  timeout = HAL_GetTick() + SD_TIMEOUT;
235
+  while (waitingRxCplt)
236
+    if (HAL_GetTick() >= timeout) return false;
275 237
 
276
-  while (__HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TC_FLAG_INDEX(&hdma_sdio)) != 0
277
-      || __HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TE_FLAG_INDEX(&hdma_sdio)) != 0) { /* nada */ }
238
+  return true;
239
+}
278 240
 
279
-  HAL_DMA_Abort_IT(&hdma_sdio);
280
-  HAL_DMA_DeInit(&hdma_sdio);
241
+bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
242
+  uint32_t timeout = HAL_GetTick() + SD_TIMEOUT;
281 243
 
282
-  timeout = millis() + 500;
283
-  while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) if (ELAPSED(millis(), timeout)) return false;
244
+  while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER)
245
+    if (HAL_GetTick() >= timeout) return false;
284 246
 
285
-  return true;
286
-}
247
+  waitingTxCplt = 1;
248
+  if (HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)src, block, 1) != HAL_OK)
249
+    return false;
287 250
 
288
-bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
289
-  uint8_t retries = SDIO_READ_RETRIES;
290
-  while (retries--) if (SDIO_ReadWriteBlock_DMA(block, nullptr, dst)) return true;
291
-  return false;
292
-}
251
+  timeout = HAL_GetTick() + SD_TIMEOUT;
252
+  while (waitingTxCplt)
253
+    if (HAL_GetTick() >= timeout) return false;
293 254
 
294
-bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
295
-  uint8_t retries = SDIO_READ_RETRIES;
296
-  while (retries--) if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) return true;
297
-  return false;
255
+  return true;
298 256
 }
299 257
 
300 258
 bool SDIO_IsReady() {
@@ -305,16 +263,5 @@ uint32_t SDIO_GetCardSize() {
305 263
   return (uint32_t)(hsd.SdCard.BlockNbr) * (hsd.SdCard.BlockSize);
306 264
 }
307 265
 
308
-#if defined(STM32F1xx)
309
-  #define DMA_IRQ_HANDLER DMA2_Channel4_5_IRQHandler
310
-#elif defined(STM32F4xx)
311
-  #define DMA_IRQ_HANDLER DMA2_Stream3_IRQHandler
312
-#else
313
-  #error "Unknown STM32 architecture."
314
-#endif
315
-
316
-extern "C" void SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); }
317
-extern "C" void DMA_IRQ_HANDLER(void) { HAL_DMA_IRQHandler(&hdma_sdio); }
318
-
319 266
 #endif // SDIO_SUPPORT
320 267
 #endif // HAL_STM32

+ 2
- 0
Marlin/src/core/boards.h 查看文件

@@ -429,6 +429,8 @@
429 429
 #define BOARD_T41U5XBB                5002  // T41U5XBB Teensy 4.1 breakout board
430 430
 #define BOARD_NUCLEO_F767ZI           5003  // ST NUCLEO-F767ZI Dev Board
431 431
 #define BOARD_BTT_SKR_SE_BX           5004  // BigTreeTech SKR SE BX (STM32H743II)
432
+#define BOARD_BTT_SKR_V3_0            5005  // BigTreeTech SKR V3.0 (STM32H743VG)
433
+#define BOARD_BTT_SKR_V3_0_EZ         5006  // BigTreeTech SKR V3.0 EZ (STM32H743VG)
432 434
 
433 435
 //
434 436
 // Espressif ESP32 WiFi

+ 4
- 0
Marlin/src/pins/pins.h 查看文件

@@ -708,6 +708,10 @@
708 708
   #include "stm32f7/pins_NUCLEO_F767ZI.h"       // STM32F7                                env:NUCLEO_F767ZI
709 709
 #elif MB(BTT_SKR_SE_BX)
710 710
   #include "stm32h7/pins_BTT_SKR_SE_BX.h"       // STM32H7                                env:BTT_SKR_SE_BX
711
+#elif MB(BTT_SKR_V3_0)
712
+  #include "stm32h7/pins_BTT_SKR_V3_0.h"        // STM32H7                                env:STM32H743Vx_btt
713
+#elif MB(BTT_SKR_V3_0_EZ)
714
+  #include "stm32h7/pins_BTT_SKR_V3_0_EZ.h"     // STM32H7                                env:STM32H743Vx_btt
711 715
 #elif MB(TEENSY41)
712 716
   #include "teensy4/pins_TEENSY41.h"            // Teensy-4.x                             env:teensy41
713 717
 #elif MB(T41U5XBB)

+ 26
- 0
Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0.h 查看文件

@@ -0,0 +1,26 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#define BOARD_INFO_NAME "BTT SKR V3"
25
+
26
+#include "pins_BTT_SKR_V3_0_common.h"

+ 26
- 0
Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_EZ.h 查看文件

@@ -0,0 +1,26 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#define BOARD_INFO_NAME "BTT SKR V3 EZ"
25
+
26
+#include "pins_BTT_SKR_V3_0_common.h"

+ 569
- 0
Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h 查看文件

@@ -0,0 +1,569 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#if NOT_TARGET(STM32H7)
25
+  #error "Oops! Select an STM32H7 board in 'Tools > Board.'"
26
+#endif
27
+
28
+// If you have the BigTreeTech driver expansion module, enable BTT_MOTOR_EXPANSION
29
+// https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT
30
+//#define BTT_MOTOR_EXPANSION
31
+
32
+#if BOTH(HAS_WIRED_LCD, BTT_MOTOR_EXPANSION)
33
+  #if EITHER(CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY)
34
+    #define EXP_MOT_USE_EXP2_ONLY 1
35
+  #else
36
+    #error "You can't use both an LCD and a Motor Expansion Module on EXP1/EXP2 at the same time."
37
+  #endif
38
+#endif
39
+
40
+#define USES_DIAG_JUMPERS
41
+
42
+// Onboard I2C EEPROM
43
+#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM)
44
+  #undef NO_EEPROM_SELECTED
45
+  #define I2C_EEPROM
46
+  #define SOFT_I2C_EEPROM                         // Force the use of Software I2C
47
+  #define I2C_SCL_PIN                       PA14
48
+  #define I2C_SDA_PIN                       PA13
49
+  #define MARLIN_EEPROM_SIZE              0x1000  // 4KB
50
+#endif
51
+
52
+//
53
+// Servos
54
+//
55
+#define SERVO0_PIN                          PE5
56
+
57
+//
58
+// Trinamic Stallguard pins
59
+//
60
+#define X_DIAG_PIN                          PC1   // X-STOP
61
+#define Y_DIAG_PIN                          PC3   // Y-STOP
62
+#define Z_DIAG_PIN                          PC0   // Z-STOP
63
+#define E0_DIAG_PIN                         PC2   // E0DET
64
+#define E1_DIAG_PIN                         PA0   // E1DET
65
+
66
+//
67
+// Limit Switches
68
+//
69
+#ifdef X_STALL_SENSITIVITY
70
+  #define X_STOP_PIN                  X_DIAG_PIN
71
+  #if X_HOME_TO_MIN
72
+    #define X_MAX_PIN                       PC2   // E0DET
73
+  #else
74
+    #define X_MIN_PIN                       PC2   // E0DET
75
+  #endif
76
+#elif ENABLED(X_DUAL_ENDSTOPS)
77
+  #ifndef X_MIN_PIN
78
+    #define X_MIN_PIN                       PC1   // X-STOP
79
+  #endif
80
+  #ifndef X_MAX_PIN
81
+    #define X_MAX_PIN                       PC2   // E0DET
82
+  #endif
83
+#else
84
+  #define X_STOP_PIN                        PC1   // X-STOP
85
+#endif
86
+
87
+#ifdef Y_STALL_SENSITIVITY
88
+  #define Y_STOP_PIN                  Y_DIAG_PIN
89
+  #if Y_HOME_TO_MIN
90
+    #define Y_MAX_PIN                       PA0   // E1DET
91
+  #else
92
+    #define Y_MIN_PIN                       PA0   // E1DET
93
+  #endif
94
+#elif ENABLED(Y_DUAL_ENDSTOPS)
95
+  #ifndef Y_MIN_PIN
96
+    #define Y_MIN_PIN                       PC3   // Y-STOP
97
+  #endif
98
+  #ifndef Y_MAX_PIN
99
+    #define Y_MAX_PIN                       PA0   // E1DET
100
+  #endif
101
+#else
102
+  #define Y_STOP_PIN                        PC3   // Y-STOP
103
+#endif
104
+
105
+#ifdef Z_STALL_SENSITIVITY
106
+  #define Z_STOP_PIN                  Z_DIAG_PIN
107
+  #if Z_HOME_TO_MIN
108
+    #define Z_MAX_PIN                       PC15  // PWRDET
109
+  #else
110
+    #define Z_MIN_PIN                       PC15  // PWRDET
111
+  #endif
112
+#elif ENABLED(Z_MULTI_ENDSTOPS)
113
+  #ifndef Z_MIN_PIN
114
+    #define Z_MIN_PIN                       PC0   // Z-STOP
115
+  #endif
116
+  #ifndef Z_MAX_PIN
117
+    #define Z_MAX_PIN                       PC15  // PWRDET
118
+  #endif
119
+#else
120
+  #ifndef Z_STOP_PIN
121
+    #define Z_STOP_PIN                      PC0   // Z-STOP
122
+  #endif
123
+#endif
124
+
125
+//
126
+// Z Probe (when not Z_MIN_PIN)
127
+//
128
+#ifndef Z_MIN_PROBE_PIN
129
+  #define Z_MIN_PROBE_PIN                   PC13
130
+#endif
131
+
132
+//
133
+// Probe enable
134
+//
135
+#if ENABLED(PROBE_ENABLE_DISABLE)
136
+  #ifndef PROBE_ENABLE_PIN
137
+    #define PROBE_ENABLE_PIN          SERVO0_PIN
138
+  #endif
139
+#endif
140
+
141
+//
142
+// Filament Runout Sensor
143
+//
144
+#define FIL_RUNOUT_PIN                      PC2   // E0DET
145
+#define FIL_RUNOUT2_PIN                     PA0   // E1DET
146
+
147
+//
148
+// Power Supply Control
149
+//
150
+#ifndef PS_ON_PIN
151
+  #define PS_ON_PIN                         PE4   // PS-ON
152
+#endif
153
+
154
+//
155
+// Power Loss Detection
156
+//
157
+#ifndef POWER_LOSS_PIN
158
+  #define POWER_LOSS_PIN                    PC15  // PWRDET
159
+#endif
160
+
161
+//
162
+// Steppers
163
+//
164
+#define X_STEP_PIN                          PD4
165
+#define X_DIR_PIN                           PD3
166
+#define X_ENABLE_PIN                        PD6
167
+#ifndef X_CS_PIN
168
+  #define X_CS_PIN                          PD5
169
+#endif
170
+
171
+#define Y_STEP_PIN                          PA15
172
+#define Y_DIR_PIN                           PA8
173
+#define Y_ENABLE_PIN                        PD1
174
+#ifndef Y_CS_PIN
175
+  #define Y_CS_PIN                          PD0
176
+#endif
177
+
178
+#define Z_STEP_PIN                          PE2
179
+#define Z_DIR_PIN                           PE3
180
+#define Z_ENABLE_PIN                        PE0
181
+#ifndef Z_CS_PIN
182
+  #define Z_CS_PIN                          PE1
183
+#endif
184
+
185
+#ifndef E0_STEP_PIN
186
+  #define E0_STEP_PIN                       PD15
187
+#endif
188
+#ifndef E0_DIR_PIN
189
+  #define E0_DIR_PIN                        PD14
190
+#endif
191
+#ifndef E0_ENABLE_PIN
192
+  #define E0_ENABLE_PIN                     PC7
193
+#endif
194
+#ifndef E0_CS_PIN
195
+  #define E0_CS_PIN                         PC6
196
+#endif
197
+
198
+#ifndef E1_STEP_PIN
199
+  #define E1_STEP_PIN                       PD11
200
+#endif
201
+#ifndef E1_DIR_PIN
202
+  #define E1_DIR_PIN                        PD10
203
+#endif
204
+#ifndef E1_ENABLE_PIN
205
+  #define E1_ENABLE_PIN                     PD13
206
+#endif
207
+#ifndef E1_CS_PIN
208
+  #define E1_CS_PIN                         PD12
209
+#endif
210
+
211
+//
212
+// Temperature Sensors
213
+//
214
+#ifndef TEMP_0_PIN
215
+  #define TEMP_0_PIN                        PA2   // TH0
216
+#endif
217
+#ifndef TEMP_1_PIN
218
+  #define TEMP_1_PIN                        PA3   // TH1
219
+#endif
220
+#ifndef TEMP_BED_PIN
221
+  #define TEMP_BED_PIN                      PA1   // TB
222
+#endif
223
+
224
+#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL)
225
+  #if TEMP_SENSOR_PROBE
226
+    #define TEMP_PROBE_PIN            TEMP_1_PIN
227
+  #elif TEMP_SENSOR_CHAMBER
228
+    #define TEMP_CHAMBER_PIN          TEMP_1_PIN
229
+  #endif
230
+#endif
231
+
232
+//
233
+// Heaters / Fans
234
+//
235
+#ifndef HEATER_0_PIN
236
+  #define HEATER_0_PIN                      PB3   // Heater0
237
+#endif
238
+#ifndef HEATER_1_PIN
239
+  #define HEATER_1_PIN                      PB4   // Heater1
240
+#endif
241
+#ifndef HEATER_BED_PIN
242
+  #define HEATER_BED_PIN                    PD7   // Hotbed
243
+#endif
244
+#ifndef FAN_PIN
245
+  #define FAN_PIN                           PB7   // Fan0
246
+#endif
247
+
248
+#if HAS_CUTTER
249
+  #ifndef SPINDLE_LASER_PWM_PIN
250
+    #define SPINDLE_LASER_PWM_PIN           PB5
251
+  #endif
252
+  #ifndef SPINDLE_LASER_ENA_PIN
253
+    #define SPINDLE_LASER_ENA_PIN           PB6
254
+  #endif
255
+#else
256
+  #ifndef FAN1_PIN
257
+    #define FAN1_PIN                        PB6   // Fan1
258
+  #endif
259
+  #ifndef FAN2_PIN
260
+    #define FAN2_PIN                        PB5   // Fan2
261
+  #endif
262
+#endif // SPINDLE_FEATURE || LASER_FEATURE
263
+
264
+//
265
+// Software SPI pins for TMC2130 stepper drivers
266
+//
267
+#if ENABLED(TMC_USE_SW_SPI)
268
+  #ifndef TMC_SW_MOSI
269
+    #define TMC_SW_MOSI                     PE13
270
+  #endif
271
+  #ifndef TMC_SW_MISO
272
+    #define TMC_SW_MISO                     PE15
273
+  #endif
274
+  #ifndef TMC_SW_SCK
275
+    #define TMC_SW_SCK                      PE14
276
+  #endif
277
+#endif
278
+
279
+#if HAS_TMC_UART
280
+  /**
281
+   * TMC2208/TMC2209 stepper drivers
282
+   *
283
+   * Hardware serial communication ports.
284
+   * If undefined software serial is used according to the pins below
285
+   */
286
+  //#define X_HARDWARE_SERIAL  Serial1
287
+  //#define X2_HARDWARE_SERIAL Serial1
288
+  //#define Y_HARDWARE_SERIAL  Serial1
289
+  //#define Y2_HARDWARE_SERIAL Serial1
290
+  //#define Z_HARDWARE_SERIAL  Serial1
291
+  //#define Z2_HARDWARE_SERIAL Serial1
292
+  //#define E0_HARDWARE_SERIAL Serial1
293
+  //#define E1_HARDWARE_SERIAL Serial1
294
+  //#define E2_HARDWARE_SERIAL Serial1
295
+  //#define E3_HARDWARE_SERIAL Serial1
296
+  //#define E4_HARDWARE_SERIAL Serial1
297
+
298
+  //
299
+  // Software serial
300
+  //
301
+  #define X_SERIAL_TX_PIN                   PD5
302
+  #define X_SERIAL_RX_PIN        X_SERIAL_TX_PIN
303
+
304
+  #define Y_SERIAL_TX_PIN                   PD0
305
+  #define Y_SERIAL_RX_PIN        Y_SERIAL_TX_PIN
306
+
307
+  #define Z_SERIAL_TX_PIN                   PE1
308
+  #define Z_SERIAL_RX_PIN        Z_SERIAL_TX_PIN
309
+
310
+  #define E0_SERIAL_TX_PIN                  PC6
311
+  #define E0_SERIAL_RX_PIN      E0_SERIAL_TX_PIN
312
+
313
+  #define E1_SERIAL_TX_PIN                  PD12
314
+  #define E1_SERIAL_RX_PIN      E1_SERIAL_TX_PIN
315
+
316
+  // Reduce baud rate to improve software serial reliability
317
+  #define TMC_BAUD_RATE                    19200
318
+#endif
319
+
320
+//
321
+// SD Connection
322
+//
323
+#ifndef SDCARD_CONNECTION
324
+  #define SDCARD_CONNECTION              ONBOARD
325
+#endif
326
+
327
+/**
328
+ *                ------                                   ------
329
+ * (BEEPER) PC5  |10  9 | PB0  (BTN_ENC)  (MISO)      PA6 |10  9 | PA5 (SCK)
330
+ * (LCD_EN) PB1  | 8  7 | PE8  (LCD_RS)   (BTN_EN1)   PE7 | 8  7 | PA4 (SD_SS)
331
+ * (LCD_D4) PE9  | 6  5   PE10 (LCD_D5)   (BTN_EN2)   PB2 | 6  5   PA7 (MOSI)
332
+ * (LCD_D6) PE11 | 4  3 | PE12 (LCD_D7)   (SD_DETECT) PC4 | 4  3 | RESET
333
+ *           GND | 2  1 | 5V                          GND | 2  1 | --
334
+ *                ------                                   ------
335
+ *                 EXP1                                     EXP2
336
+ */
337
+#define EXP1_03_PIN                         PE12
338
+#define EXP1_04_PIN                         PE11
339
+#define EXP1_05_PIN                         PE10
340
+#define EXP1_06_PIN                         PE9
341
+#define EXP1_07_PIN                         PE8
342
+#define EXP1_08_PIN                         PB1
343
+#define EXP1_09_PIN                         PB0
344
+#define EXP1_10_PIN                         PC5
345
+
346
+#define EXP2_03_PIN                         -1
347
+#define EXP2_04_PIN                         PC4
348
+#define EXP2_05_PIN                         PA7
349
+#define EXP2_06_PIN                         PB2
350
+#define EXP2_07_PIN                         PA4
351
+#define EXP2_08_PIN                         PE7
352
+#define EXP2_09_PIN                         PA5
353
+#define EXP2_10_PIN                         PA6
354
+
355
+//
356
+// Onboard SD card
357
+// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2
358
+//
359
+#if SD_CONNECTION_IS(LCD)
360
+  #define SDSS                       EXP2_07_PIN
361
+  #define SD_SS_PIN                         SDSS
362
+  #define SD_SCK_PIN                 EXP2_09_PIN
363
+  #define SD_MISO_PIN                EXP2_10_PIN
364
+  #define SD_MOSI_PIN                EXP2_05_PIN
365
+  #define SD_DETECT_PIN              EXP2_04_PIN
366
+#elif SD_CONNECTION_IS(ONBOARD)
367
+  #define SDIO_SUPPORT
368
+  #define SDIO_CLOCK                 24000000  // 24MHz
369
+#elif SD_CONNECTION_IS(CUSTOM_CABLE)
370
+  #error "No custom SD drive cable defined for this board."
371
+#endif
372
+
373
+#if ENABLED(BTT_MOTOR_EXPANSION)
374
+  /**       -----                        -----
375
+   *    -- | . . | GND               -- | . . | GND
376
+   *    -- | . . | M1EN            M2EN | . . | M3EN
377
+   * M1STP | . .   M1DIR           M1RX | . .   M1DIAG
378
+   * M2DIR | . . | M2STP           M2RX | . . | M2DIAG
379
+   * M3DIR | . . | M3STP           M3RX | . . | M3DIAG
380
+   *        -----                        -----
381
+   *        EXP2                         EXP1
382
+   *
383
+   * NB In EXP_MOT_USE_EXP2_ONLY mode EXP1 is not used and M2EN and M3EN need to be jumpered to M1EN
384
+   */
385
+
386
+  // M1 on Driver Expansion Module
387
+  #define E2_STEP_PIN                EXP2_05_PIN
388
+  #define E2_DIR_PIN                 EXP2_06_PIN
389
+  #define E2_ENABLE_PIN              EXP2_04_PIN
390
+  #if !EXP_MOT_USE_EXP2_ONLY
391
+    #define E2_DIAG_PIN              EXP1_06_PIN
392
+    #define E2_CS_PIN                EXP1_05_PIN
393
+    #if HAS_TMC_UART
394
+      #define E2_SERIAL_TX_PIN       EXP1_05_PIN
395
+      #define E2_SERIAL_RX_PIN       EXP1_05_PIN
396
+    #endif
397
+  #endif
398
+
399
+  // M2 on Driver Expansion Module
400
+  #define E3_STEP_PIN                EXP2_08_PIN
401
+  #define E3_DIR_PIN                 EXP2_07_PIN
402
+  #if !EXP_MOT_USE_EXP2_ONLY
403
+    #define E3_ENABLE_PIN            EXP1_03_PIN
404
+    #define E3_DIAG_PIN              EXP1_08_PIN
405
+    #define E3_CS_PIN                EXP1_07_PIN
406
+    #if HAS_TMC_UART
407
+      #define E3_SERIAL_TX_PIN       EXP1_07_PIN
408
+      #define E3_SERIAL_RX_PIN       EXP1_07_PIN
409
+    #endif
410
+  #else
411
+    #define E3_ENABLE_PIN            EXP2_04_PIN
412
+  #endif
413
+
414
+  // M3 on Driver Expansion Module
415
+  #define E4_STEP_PIN                EXP2_10_PIN
416
+  #define E4_DIR_PIN                 EXP2_09_PIN
417
+  #if !EXP_MOT_USE_EXP2_ONLY
418
+    #define E4_ENABLE_PIN            EXP1_04_PIN
419
+    #define E4_DIAG_PIN              EXP1_10_PIN
420
+    #define E4_CS_PIN                EXP1_09_PIN
421
+    #if HAS_TMC_UART
422
+      #define E4_SERIAL_TX_PIN       EXP1_09_PIN
423
+      #define E4_SERIAL_RX_PIN       EXP1_09_PIN
424
+    #endif
425
+  #else
426
+    #define E4_ENABLE_PIN            EXP2_04_PIN
427
+  #endif
428
+
429
+#endif // BTT_MOTOR_EXPANSION
430
+
431
+//
432
+// LCDs and Controllers
433
+//
434
+#if IS_TFTGLCD_PANEL
435
+
436
+  #if ENABLED(TFTGLCD_PANEL_SPI)
437
+    #define TFTGLCD_CS               EXP2_08_PIN
438
+  #endif
439
+
440
+#elif HAS_WIRED_LCD
441
+
442
+  #define BEEPER_PIN                 EXP1_10_PIN
443
+  #define BTN_ENC                    EXP1_09_PIN
444
+
445
+  #if ENABLED(CR10_STOCKDISPLAY)
446
+
447
+    #define LCD_PINS_RS              EXP1_04_PIN
448
+
449
+    #define BTN_EN1                  EXP1_08_PIN
450
+    #define BTN_EN2                  EXP1_06_PIN
451
+
452
+    #define LCD_PINS_ENABLE          EXP1_03_PIN
453
+    #define LCD_PINS_D4              EXP1_05_PIN
454
+
455
+  #elif ENABLED(MKS_MINI_12864)
456
+
457
+    #define DOGLCD_A0                EXP1_04_PIN
458
+    #define DOGLCD_CS                EXP1_05_PIN
459
+    #define BTN_EN1                  EXP2_08_PIN
460
+    #define BTN_EN2                  EXP2_06_PIN
461
+
462
+  #else
463
+
464
+    #define LCD_PINS_RS              EXP1_07_PIN
465
+
466
+    #define BTN_EN1                  EXP2_08_PIN
467
+    #define BTN_EN2                  EXP2_06_PIN
468
+
469
+    #define LCD_PINS_ENABLE          EXP1_08_PIN
470
+    #define LCD_PINS_D4              EXP1_06_PIN
471
+
472
+    #if ENABLED(FYSETC_MINI_12864)
473
+      #define DOGLCD_CS              EXP1_08_PIN
474
+      #define DOGLCD_A0              EXP1_07_PIN
475
+      //#define LCD_BACKLIGHT_PIN           -1
476
+      #define LCD_RESET_PIN          EXP1_06_PIN  // Must be high or open for LCD to operate normally.
477
+      #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
478
+        #ifndef RGB_LED_R_PIN
479
+          #define RGB_LED_R_PIN      EXP1_05_PIN
480
+        #endif
481
+        #ifndef RGB_LED_G_PIN
482
+          #define RGB_LED_G_PIN      EXP1_04_PIN
483
+        #endif
484
+        #ifndef RGB_LED_B_PIN
485
+          #define RGB_LED_B_PIN      EXP1_03_PIN
486
+        #endif
487
+      #elif ENABLED(FYSETC_MINI_12864_2_1)
488
+        #define NEOPIXEL_PIN         EXP1_05_PIN
489
+      #endif
490
+    #endif // !FYSETC_MINI_12864
491
+
492
+    #if IS_ULTIPANEL
493
+      #define LCD_PINS_D5            EXP1_05_PIN
494
+      #define LCD_PINS_D6            EXP1_04_PIN
495
+      #define LCD_PINS_D7            EXP1_03_PIN
496
+
497
+      #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
498
+        #define BTN_ENC_EN           LCD_PINS_D7  // Detect the presence of the encoder
499
+      #endif
500
+
501
+    #endif
502
+
503
+  #endif
504
+
505
+#endif // HAS_WIRED_LCD
506
+
507
+// Alter timing for graphical display
508
+#if IS_U8GLIB_ST7920
509
+  #ifndef BOARD_ST7920_DELAY_1
510
+    #define BOARD_ST7920_DELAY_1             120
511
+  #endif
512
+  #ifndef BOARD_ST7920_DELAY_2
513
+    #define BOARD_ST7920_DELAY_2              80
514
+  #endif
515
+  #ifndef BOARD_ST7920_DELAY_3
516
+    #define BOARD_ST7920_DELAY_3             580
517
+  #endif
518
+#endif
519
+
520
+#if HAS_SPI_TFT
521
+  //
522
+  // e.g., BTT_TFT35_SPI_V1_0 (480x320, 3.5", SPI Stock Display with Rotary Encoder in BIQU B1 SE)
523
+  //
524
+  #define TFT_CS_PIN                 EXP2_07_PIN
525
+  #define TFT_A0_PIN                 EXP2_04_PIN
526
+  #define TFT_SCK_PIN                EXP2_09_PIN
527
+  #define TFT_MISO_PIN               EXP2_10_PIN
528
+  #define TFT_MOSI_PIN               EXP2_05_PIN
529
+
530
+  #define TOUCH_INT_PIN              EXP1_04_PIN
531
+  #define TOUCH_MISO_PIN             EXP1_05_PIN
532
+  #define TOUCH_MOSI_PIN             EXP1_08_PIN
533
+  #define TOUCH_SCK_PIN              EXP1_06_PIN
534
+  #define TOUCH_CS_PIN               EXP1_07_PIN
535
+
536
+  #define BTN_EN1                    EXP2_08_PIN
537
+  #define BTN_EN2                    EXP2_06_PIN
538
+  #define BTN_ENC                    EXP1_09_PIN
539
+#endif
540
+
541
+//
542
+// NeoPixel LED
543
+//
544
+#ifndef NEOPIXEL_PIN
545
+  #define NEOPIXEL_PIN                      PE6
546
+#endif
547
+
548
+//
549
+// WIFI
550
+//
551
+
552
+/**
553
+ *                      -------
554
+ *            GND | 9  |       | 8 | 3.3V
555
+ *  (ESP-CS) PB12 | 10 |       | 7 | PB15 (ESP-MOSI)
556
+ *           3.3V | 11 |       | 6 | PB14 (ESP-MISO)
557
+ * (ESP-IO0) PB10 | 12 |       | 5 | PB13 (ESP-CLK)
558
+ * (ESP-IO4) PB11 | 13 |       | 4 | --
559
+ *             -- | 14 |       | 3 | 3.3V (ESP-EN)
560
+ *  (ESP-RX)  PD8 | 15 |       | 2 | --
561
+ *  (ESP-TX)  PD9 | 16 |       | 1 | PC14 (ESP-RST)
562
+ *                      -------
563
+ *                       WIFI
564
+ */
565
+#define ESP_WIFI_MODULE_COM                    3  // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this
566
+#define ESP_WIFI_MODULE_BAUDRATE        BAUDRATE  // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2
567
+#define ESP_WIFI_MODULE_RESET_PIN           PC14
568
+#define ESP_WIFI_MODULE_GPIO0_PIN           PB10
569
+#define ESP_WIFI_MODULE_GPIO4_PIN           PB11

+ 61
- 0
buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json 查看文件

@@ -0,0 +1,61 @@
1
+{
2
+  "build": {
3
+    "core": "stm32",
4
+    "cpu": "cortex-m7",
5
+    "extra_flags": "-DSTM32H7xx -DSTM32H743xx",
6
+    "f_cpu": "400000000L",
7
+    "mcu": "stm32h743vit6",
8
+    "product_line": "STM32H743xx",
9
+    "variant": "MARLIN_H743Vx"
10
+  },
11
+  "connectivity": [
12
+    "can",
13
+    "ethernet"
14
+  ],
15
+  "debug": {
16
+    "jlink_device": "STM32H743VI",
17
+    "openocd_target": "stm32h7x",
18
+    "svd_path": "STM32H7x3.svd",
19
+    "tools": {
20
+      "stlink": {
21
+        "server": {
22
+          "arguments": [
23
+            "-f",
24
+            "scripts/interface/stlink.cfg",
25
+            "-c",
26
+            "transport select hla_swd",
27
+            "-f",
28
+            "scripts/target/stm32h7x.cfg",
29
+            "-c",
30
+            "reset_config none"
31
+          ],
32
+          "executable": "bin/openocd",
33
+          "package": "tool-openocd"
34
+        }
35
+      }
36
+    }
37
+  },
38
+  "frameworks": [
39
+    "arduino",
40
+    "stm32cube"
41
+  ],
42
+  "name": "STM32H743VI (1024k RAM. 2048k Flash)",
43
+  "upload": {
44
+    "disable_flushing": false,
45
+    "maximum_ram_size": 1048576,
46
+    "maximum_size": 2097152,
47
+    "protocol": "stlink",
48
+    "protocols": [
49
+      "stlink",
50
+      "dfu",
51
+      "jlink",
52
+      "cmsis-dap"
53
+    ],
54
+    "offset_address": "0x8020000",
55
+    "require_upload_port": true,
56
+    "use_1200bps_touch": false,
57
+    "wait_for_upload_port": false
58
+  },
59
+  "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32h743vi.html",
60
+  "vendor": "ST"
61
+}

+ 539
- 0
buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c 查看文件

@@ -0,0 +1,539 @@
1
+/*
2
+ *******************************************************************************
3
+ * Copyright (c) 2020-2021, STMicroelectronics
4
+ * All rights reserved.
5
+ *
6
+ * This software component is licensed by ST under BSD 3-Clause license,
7
+ * the "License"; You may not use this file except in compliance with the
8
+ * License. You may obtain a copy of the License at:
9
+ *                        opensource.org/licenses/BSD-3-Clause
10
+ *
11
+ *******************************************************************************
12
+ */
13
+/*
14
+ * Automatically generated from STM32H742V(G-I)Hx.xml, STM32H742V(G-I)Tx.xml
15
+ * STM32H743V(G-I)Hx.xml, STM32H743VGTx.xml
16
+ * STM32H743VITx.xml, STM32H750VBTx.xml
17
+ * STM32H753VIHx.xml, STM32H753VITx.xml
18
+ * CubeMX DB release 6.0.30
19
+ */
20
+#if !defined(CUSTOM_PERIPHERAL_PINS)
21
+#include "Arduino.h"
22
+#include "PeripheralPins.h"
23
+
24
+/* =====
25
+ * Notes:
26
+ * - The pins mentioned Px_y_ALTz are alternative possibilities which use other
27
+ *   HW peripheral instances. You can use them the same way as any other "normal"
28
+ *   pin (i.e. analogWrite(PA7_ALT1, 128);).
29
+ *
30
+ * - Commented lines are alternative possibilities which are not used per default.
31
+ *   If you change them, you will have to know what you do
32
+ * =====
33
+ */
34
+
35
+//*** ADC ***
36
+
37
+#ifdef HAL_ADC_MODULE_ENABLED
38
+WEAK const PinMap PinMap_ADC[] = {
39
+  {PA_0,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC1_INP16
40
+  {PA_1,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, // ADC1_INP17
41
+  {PA_2,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_INP14
42
+  {PA_2_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_INP14
43
+  {PA_3,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_INP15
44
+  {PA_3_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_INP15
45
+  {PA_4,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC1_INP18
46
+  {PA_4_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC2_INP18
47
+  {PA_5,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 19, 0)}, // ADC1_INP19
48
+  {PA_5_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 19, 0)}, // ADC2_INP19
49
+  {PA_6,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_INP3
50
+  {PA_6_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_INP3
51
+  {PA_7,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_INP7
52
+  {PA_7_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_INP7
53
+  {PB_0,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_INP9
54
+  {PB_0_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_INP9
55
+  {PB_1,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_INP5
56
+  {PB_1_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_INP5
57
+  {PC_0,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_INP10
58
+  {PC_0_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_INP10
59
+  {PC_0_ALT2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_INP10
60
+  {PC_1,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_INP11
61
+  {PC_1_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_INP11
62
+  {PC_1_ALT2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_INP11
63
+  {PC_2_C,    ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_INP0
64
+  {PC_3_C,    ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_INP1
65
+  {PC_4,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_INP4
66
+  {PC_4_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_INP4
67
+  {PC_5,      ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_INP8
68
+  {PC_5_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_INP8
69
+  {NC,        NP,   0}
70
+};
71
+#endif
72
+
73
+//*** DAC ***
74
+
75
+#ifdef HAL_DAC_MODULE_ENABLED
76
+WEAK const PinMap PinMap_DAC[] = {
77
+  {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC1_OUT1
78
+  {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_OUT2
79
+  {NC,   NP,   0}
80
+};
81
+#endif
82
+
83
+//*** I2C ***
84
+
85
+#ifdef HAL_I2C_MODULE_ENABLED
86
+WEAK const PinMap PinMap_I2C_SDA[] = {
87
+  {PB_7,      I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
88
+  {PB_7_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)},
89
+  {PB_9,      I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
90
+  {PB_9_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)},
91
+  {PB_11,     I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
92
+  {PC_9,      I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
93
+  {PD_13,     I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)},
94
+  {NC,        NP,   0}
95
+};
96
+#endif
97
+
98
+#ifdef HAL_I2C_MODULE_ENABLED
99
+WEAK const PinMap PinMap_I2C_SCL[] = {
100
+  {PA_8,      I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
101
+  {PB_6,      I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
102
+  {PB_6_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)},
103
+  {PB_8,      I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
104
+  {PB_8_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)},
105
+  {PB_10,     I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
106
+  {PD_12,     I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)},
107
+  {NC,        NP,   0}
108
+};
109
+#endif
110
+
111
+//*** TIM ***
112
+
113
+#ifdef HAL_TIM_MODULE_ENABLED
114
+WEAK const PinMap PinMap_TIM[] = {
115
+  {PA_0,       TIM2,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
116
+  {PA_0_ALT1,  TIM5,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1
117
+  {PA_1,       TIM2,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
118
+  {PA_1_ALT1,  TIM5,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2
119
+  {PA_1_ALT2,  TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N
120
+  {PA_2,       TIM2,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3
121
+  {PA_2_ALT1,  TIM5,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3
122
+  {PA_2_ALT2,  TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_CH1
123
+  {PA_3,       TIM2,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4
124
+  {PA_3_ALT1,  TIM5,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4
125
+  {PA_3_ALT2,  TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2
126
+  {PA_5,       TIM2,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
127
+  {PA_5_ALT1,  TIM8,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N
128
+  {PA_6,       TIM3,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
129
+  {PA_6_ALT1,  TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1
130
+  {PA_7,       TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
131
+  {PA_7_ALT1,  TIM3,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
132
+  {PA_7_ALT2,  TIM8,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N
133
+  {PA_7_ALT3,  TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1
134
+  {PA_8,       TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
135
+  {PA_9,       TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2
136
+  {PA_10,      TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3
137
+  {PA_11,      TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
138
+  {PA_15,      TIM2,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
139
+  {PB_0,       TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
140
+  {PB_0_ALT1,  TIM3,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
141
+  {PB_0_ALT2,  TIM8,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N
142
+  {PB_1,       TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
143
+  {PB_1_ALT1,  TIM3,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
144
+  {PB_1_ALT2,  TIM8,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N
145
+  {PB_3,       TIM2,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
146
+  {PB_4,       TIM3,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
147
+  {PB_5,       TIM3,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
148
+  {PB_6,       TIM4,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1
149
+  {PB_6_ALT1,  TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N
150
+  {PB_7,       TIM4,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2
151
+  {PB_7_ALT1,  TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N
152
+  {PB_8,       TIM4,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3
153
+  {PB_8_ALT1,  TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1
154
+  {PB_9,       TIM4,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4
155
+  {PB_9_ALT1,  TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 0)}, // TIM17_CH1
156
+  {PB_10,      TIM2,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3
157
+  {PB_11,      TIM2,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4
158
+  {PB_13,      TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
159
+  {PB_14,      TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
160
+  {PB_14_ALT1, TIM8,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N
161
+  {PB_14_ALT2, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM12, 1, 0)}, // TIM12_CH1
162
+  {PB_15,      TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
163
+  {PB_15_ALT1, TIM8,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N
164
+  {PB_15_ALT2, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM12, 2, 0)}, // TIM12_CH2
165
+  {PC_6,       TIM3,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
166
+  {PC_6_ALT1,  TIM8,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1
167
+  {PC_7,       TIM3,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
168
+  {PC_7_ALT1,  TIM8,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2
169
+  {PC_8,       TIM3,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
170
+  {PC_8_ALT1,  TIM8,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3
171
+  {PC_9,       TIM3,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
172
+  {PC_9_ALT1,  TIM8,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4
173
+  {PD_12,      TIM4,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1
174
+  {PD_13,      TIM4,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2
175
+  {PD_14,      TIM4,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3
176
+  {PD_15,      TIM4,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4
177
+  {PE_4,       TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N
178
+  {PE_5,       TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_CH1
179
+  {PE_6,       TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2
180
+  {PE_8,       TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
181
+  {PE_9,       TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
182
+  {PE_10,      TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
183
+  {PE_11,      TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2
184
+  {PE_12,      TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
185
+  {PE_13,      TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3
186
+  {PE_14,      TIM1,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
187
+  {NC,         NP,    0}
188
+};
189
+#endif
190
+
191
+//*** UART ***
192
+
193
+#ifdef HAL_UART_MODULE_ENABLED
194
+WEAK const PinMap PinMap_UART_TX[] = {
195
+  {PA_0,       UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
196
+  {PA_2,       USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
197
+  {PA_9,       LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)},
198
+  {PA_9_ALT1,  USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
199
+  {PA_12,      UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)},
200
+  {PA_15,      UART7,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)},
201
+  {PB_4,       UART7,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)},
202
+  {PB_6,       LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)},
203
+  {PB_6_ALT1,  UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)},
204
+  {PB_6_ALT2,  USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
205
+  {PB_9,       UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
206
+  {PB_10,      USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
207
+  {PB_13,      UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)},
208
+  {PB_14,      USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)},
209
+  {PC_6,       USART6,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)},
210
+  {PC_10,      UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
211
+  {PC_10_ALT1, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
212
+  {PC_12,      UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
213
+  {PD_1,       UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
214
+  {PD_5,       USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
215
+  {PD_8,       USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
216
+  {PE_1,       UART8,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)},
217
+  {PE_8,       UART7,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)},
218
+  {NC,         NP,      0}
219
+};
220
+#endif
221
+
222
+#ifdef HAL_UART_MODULE_ENABLED
223
+WEAK const PinMap PinMap_UART_RX[] = {
224
+  {PA_1,       UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
225
+  {PA_3,       USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
226
+  {PA_8,       UART7,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)},
227
+  {PA_10,      LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)},
228
+  {PA_10_ALT1, USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
229
+  {PA_11,      UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)},
230
+  {PB_3,       UART7,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)},
231
+  {PB_5,       UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)},
232
+  {PB_7,       LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)},
233
+  {PB_7_ALT1,  USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
234
+  {PB_8,       UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
235
+  {PB_11,      USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
236
+  {PB_12,      UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)},
237
+  {PB_15,      USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)},
238
+  {PC_7,       USART6,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)},
239
+  {PC_11,      UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
240
+  {PC_11_ALT1, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
241
+  {PD_0,       UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
242
+  {PD_2,       UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
243
+  {PD_6,       USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
244
+  {PD_9,       USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
245
+  {PE_0,       UART8,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)},
246
+  {PE_7,       UART7,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)},
247
+  {NC,         NP,      0}
248
+};
249
+#endif
250
+
251
+#ifdef HAL_UART_MODULE_ENABLED
252
+WEAK const PinMap PinMap_UART_RTS[] = {
253
+  {PA_1,       USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
254
+  {PA_12,      LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)},
255
+  {PA_12_ALT1, USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
256
+  {PA_15,      UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
257
+  {PB_14,      UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
258
+  {PB_14_ALT1, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
259
+  {PC_8,       UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
260
+  {PD_4,       USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
261
+  {PD_12,      USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
262
+  {PD_15,      UART8,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)},
263
+  {PE_9,       UART7,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)},
264
+  {NC,         NP,      0}
265
+};
266
+#endif
267
+
268
+#ifdef HAL_UART_MODULE_ENABLED
269
+WEAK const PinMap PinMap_UART_CTS[] = {
270
+  {PA_0,       USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
271
+  {PA_11,      LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)},
272
+  {PA_11_ALT1, USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
273
+  {PB_0,       UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
274
+  {PB_13,      USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
275
+  {PB_15,      UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
276
+  {PC_9,       UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
277
+  {PD_3,       USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
278
+  {PD_11,      USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
279
+  {PD_14,      UART8,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)},
280
+  {PE_10,      UART7,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)},
281
+  {NC,         NP,      0}
282
+};
283
+#endif
284
+
285
+//*** SPI ***
286
+
287
+#ifdef HAL_SPI_MODULE_ENABLED
288
+WEAK const PinMap PinMap_SPI_MOSI[] = {
289
+  {PA_7,      SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
290
+  {PA_7_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)},
291
+  {PB_2,      SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)},
292
+  {PB_5,      SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
293
+  {PB_5_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)},
294
+  {PB_5_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)},
295
+  {PB_15,     SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
296
+  {PC_1,      SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
297
+  {PC_3_C,    SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
298
+  {PC_12,     SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
299
+  {PD_6,      SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)},
300
+  {PD_7,      SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
301
+  {PE_6,      SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)},
302
+  {PE_14,     SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)},
303
+  {NC,        NP,   0}
304
+};
305
+#endif
306
+
307
+#ifdef HAL_SPI_MODULE_ENABLED
308
+WEAK const PinMap PinMap_SPI_MISO[] = {
309
+  {PA_6,      SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
310
+  {PA_6_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)},
311
+  {PB_4,      SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
312
+  {PB_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
313
+  {PB_4_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)},
314
+  {PB_14,     SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
315
+  {PC_2_C,    SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
316
+  {PC_11,     SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
317
+  {PE_5,      SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)},
318
+  {PE_13,     SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)},
319
+  {NC,        NP,   0}
320
+};
321
+#endif
322
+
323
+#ifdef HAL_SPI_MODULE_ENABLED
324
+WEAK const PinMap PinMap_SPI_SCLK[] = {
325
+  {PA_5,      SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
326
+  {PA_5_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)},
327
+  {PA_9,      SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
328
+  {PA_12,     SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
329
+  {PB_3,      SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
330
+  {PB_3_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
331
+  {PB_3_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)},
332
+  {PB_10,     SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
333
+  {PB_13,     SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
334
+  {PC_10,     SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
335
+  {PD_3,      SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
336
+  {PE_2,      SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)},
337
+  {PE_12,     SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)},
338
+  {NC,        NP,   0}
339
+};
340
+#endif
341
+
342
+#ifdef HAL_SPI_MODULE_ENABLED
343
+WEAK const PinMap PinMap_SPI_SSEL[] = {
344
+  {PA_4,       SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
345
+  {PA_4_ALT1,  SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
346
+  {PA_4_ALT2,  SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)},
347
+  {PA_11,      SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
348
+  {PA_15,      SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
349
+  {PA_15_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
350
+  {PA_15_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI6)},
351
+  {PB_4,       SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)},
352
+  {PB_9,       SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
353
+  {PB_12,      SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
354
+  {PE_4,       SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)},
355
+  {PE_11,      SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)},
356
+  {NC,         NP,   0}
357
+};
358
+#endif
359
+
360
+//*** FDCAN ***
361
+
362
+#ifdef HAL_FDCAN_MODULE_ENABLED
363
+WEAK const PinMap PinMap_CAN_RD[] = {
364
+  {PA_11, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)},
365
+  {PB_5,  FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)},
366
+  {PB_8,  FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)},
367
+  {PB_12, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)},
368
+  {PD_0,  FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)},
369
+  {NC,    NP,     0}
370
+};
371
+#endif
372
+
373
+#ifdef HAL_FDCAN_MODULE_ENABLED
374
+WEAK const PinMap PinMap_CAN_TD[] = {
375
+  {PA_12, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)},
376
+  {PB_6,  FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)},
377
+  {PB_9,  FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)},
378
+  {PB_13, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)},
379
+  {PD_1,  FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)},
380
+  {NC,    NP,     0}
381
+};
382
+#endif
383
+
384
+//*** ETHERNET ***
385
+
386
+#ifdef HAL_ETH_MODULE_ENABLED
387
+WEAK const PinMap PinMap_Ethernet[] = {
388
+  {PA_0,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS
389
+  {PA_1,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_REF_CLK
390
+  {PA_1_ALT1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_CLK
391
+  {PA_2,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDIO
392
+  {PA_3,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_COL
393
+  {PA_7,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS_DV
394
+  {PA_7_ALT1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_DV
395
+  {PB_0,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD2
396
+  {PB_1,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD3
397
+  {PB_5,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT
398
+  {PB_8,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3
399
+  {PB_10,     ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_ER
400
+  {PB_11,     ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN
401
+  {PB_12,     ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0
402
+  {PB_13,     ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1
403
+  {PC_1,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDC
404
+  {PC_2_C,    ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD2
405
+  {PC_3_C,    ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_CLK
406
+  {PC_4,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD0
407
+  {PC_5,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD1
408
+  {PE_2,      ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3
409
+  {NC,        NP,  0}
410
+};
411
+#endif
412
+
413
+//*** QUADSPI ***
414
+
415
+#ifdef HAL_QSPI_MODULE_ENABLED
416
+WEAK const PinMap PinMap_QUADSPI_DATA0[] = {
417
+  {PC_9,  QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO0
418
+  {PD_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO0
419
+  {PE_7,  QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO0
420
+  {NC,    NP,      0}
421
+};
422
+#endif
423
+
424
+#ifdef HAL_QSPI_MODULE_ENABLED
425
+WEAK const PinMap PinMap_QUADSPI_DATA1[] = {
426
+  {PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO1
427
+  {PD_12, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO1
428
+  {PE_8,  QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO1
429
+  {NC,    NP,      0}
430
+};
431
+#endif
432
+
433
+#ifdef HAL_QSPI_MODULE_ENABLED
434
+WEAK const PinMap PinMap_QUADSPI_DATA2[] = {
435
+  {PE_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO2
436
+  {PE_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO2
437
+  {NC,   NP,      0}
438
+};
439
+#endif
440
+
441
+#ifdef HAL_QSPI_MODULE_ENABLED
442
+WEAK const PinMap PinMap_QUADSPI_DATA3[] = {
443
+  {PA_1,  QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO3
444
+  {PD_13, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO3
445
+  {PE_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO3
446
+  {NC,    NP,      0}
447
+};
448
+#endif
449
+
450
+#ifdef HAL_QSPI_MODULE_ENABLED
451
+WEAK const PinMap PinMap_QUADSPI_SCLK[] = {
452
+  {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_CLK
453
+  {NC,   NP,      0}
454
+};
455
+#endif
456
+
457
+#ifdef HAL_QSPI_MODULE_ENABLED
458
+WEAK const PinMap PinMap_QUADSPI_SSEL[] = {
459
+  {PB_6,  QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_NCS
460
+  {PB_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_NCS
461
+  {PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK2_NCS
462
+  {NC,    NP,      0}
463
+};
464
+#endif
465
+
466
+//*** USB ***
467
+
468
+#if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED)
469
+WEAK const PinMap PinMap_USB_OTG_FS[] = {
470
+  {PA_8,  USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_SOF
471
+  {PA_9,  USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS
472
+  {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_ID
473
+  {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_DM
474
+  {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_DP
475
+  {NC,    NP,         0}
476
+};
477
+#endif
478
+
479
+#if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED)
480
+WEAK const PinMap PinMap_USB_OTG_HS[] = {
481
+#ifdef USE_USB_HS_IN_FS
482
+  // {PA_4,   USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_SOF
483
+  // {PB_12,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_ID
484
+  // {PB_13,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS
485
+  {PB_14,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_DM
486
+  {PB_15,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_DP
487
+#else
488
+  {PA_3,   USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D0
489
+  {PA_5,   USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_CK
490
+  {PB_0,   USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D1
491
+  {PB_1,   USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D2
492
+  {PB_5,   USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D7
493
+  {PB_10,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D3
494
+  {PB_11,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D4
495
+  {PB_12,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D5
496
+  {PB_13,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D6
497
+  {PC_0,   USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_STP
498
+  {PC_2_C, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_DIR
499
+  {PC_3_C, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_NXT
500
+#endif /* USE_USB_HS_IN_FS */
501
+  {NC,     NP,         0}
502
+};
503
+#endif
504
+
505
+//*** SD ***
506
+
507
+#ifdef HAL_SD_MODULE_ENABLED
508
+WEAK const PinMap PinMap_SD[] = {
509
+  {PA_0,      SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_SDIO2)}, // SDMMC2_CMD
510
+  {PB_3,      SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D2
511
+  {PB_4,      SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D3
512
+  {PB_8,      SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SDIO1)}, // SDMMC1_CKIN
513
+  {PB_8_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D4
514
+  {PB_8_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D4
515
+  {PB_9,      SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SDIO1)}, // SDMMC1_CDIR
516
+  {PB_9_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D5
517
+  {PB_9_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D5
518
+  {PB_14,     SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D0
519
+  {PB_15,     SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D1
520
+  {PC_1,      SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_SDIO2)}, // SDMMC2_CK
521
+  {PC_6,      SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF8_SDIO1)}, // SDMMC1_D0DIR
522
+  {PC_6_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D6
523
+  {PC_6_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D6
524
+  {PC_7,      SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF8_SDIO1)}, // SDMMC1_D123DIR
525
+  {PC_7_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D7
526
+  {PC_7_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D7
527
+  {PC_8,      SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D0
528
+  {PC_9,      SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D1
529
+  {PC_10,     SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D2
530
+  {PC_11,     SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D3
531
+  {PC_12,     SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO1)}, // SDMMC1_CK
532
+  {PD_2,      SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO1)}, // SDMMC1_CMD
533
+  {PD_6,      SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_SDIO2)}, // SDMMC2_CK
534
+  {PD_7,      SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_SDIO2)}, // SDMMC2_CMD
535
+  {NC,        NP,     0}
536
+};
537
+#endif
538
+
539
+#endif /* !CUSTOM_PERIPHERAL_PINS */

+ 112
- 0
buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PinNamesVar.h 查看文件

@@ -0,0 +1,112 @@
1
+/* Dual pad pin name */
2
+PC_2_C     = PC_2  | PDUAL,
3
+PC_3_C     = PC_3  | PDUAL,
4
+
5
+/* Alternate pin name */
6
+PA_0_ALT1  = PA_0  | ALT1,
7
+PA_1_ALT1  = PA_1  | ALT1,
8
+PA_1_ALT2  = PA_1  | ALT2,
9
+PA_2_ALT1  = PA_2  | ALT1,
10
+PA_2_ALT2  = PA_2  | ALT2,
11
+PA_3_ALT1  = PA_3  | ALT1,
12
+PA_3_ALT2  = PA_3  | ALT2,
13
+PA_4_ALT1  = PA_4  | ALT1,
14
+PA_4_ALT2  = PA_4  | ALT2,
15
+PA_5_ALT1  = PA_5  | ALT1,
16
+PA_6_ALT1  = PA_6  | ALT1,
17
+PA_7_ALT1  = PA_7  | ALT1,
18
+PA_7_ALT2  = PA_7  | ALT2,
19
+PA_7_ALT3  = PA_7  | ALT3,
20
+PA_9_ALT1  = PA_9  | ALT1,
21
+PA_10_ALT1 = PA_10 | ALT1,
22
+PA_11_ALT1 = PA_11 | ALT1,
23
+PA_12_ALT1 = PA_12 | ALT1,
24
+PA_15_ALT1 = PA_15 | ALT1,
25
+PA_15_ALT2 = PA_15 | ALT2,
26
+PB_0_ALT1  = PB_0  | ALT1,
27
+PB_0_ALT2  = PB_0  | ALT2,
28
+PB_1_ALT1  = PB_1  | ALT1,
29
+PB_1_ALT2  = PB_1  | ALT2,
30
+PB_3_ALT1  = PB_3  | ALT1,
31
+PB_3_ALT2  = PB_3  | ALT2,
32
+PB_4_ALT1  = PB_4  | ALT1,
33
+PB_4_ALT2  = PB_4  | ALT2,
34
+PB_5_ALT1  = PB_5  | ALT1,
35
+PB_5_ALT2  = PB_5  | ALT2,
36
+PB_6_ALT1  = PB_6  | ALT1,
37
+PB_6_ALT2  = PB_6  | ALT2,
38
+PB_7_ALT1  = PB_7  | ALT1,
39
+PB_8_ALT1  = PB_8  | ALT1,
40
+PB_8_ALT2  = PB_8  | ALT2,
41
+PB_9_ALT1  = PB_9  | ALT1,
42
+PB_9_ALT2  = PB_9  | ALT2,
43
+PB_14_ALT1 = PB_14 | ALT1,
44
+PB_14_ALT2 = PB_14 | ALT2,
45
+PB_15_ALT1 = PB_15 | ALT1,
46
+PB_15_ALT2 = PB_15 | ALT2,
47
+PC_0_ALT1  = PC_0  | ALT1,
48
+PC_0_ALT2  = PC_0  | ALT2,
49
+PC_1_ALT1  = PC_1  | ALT1,
50
+PC_1_ALT2  = PC_1  | ALT2,
51
+PC_4_ALT1  = PC_4  | ALT1,
52
+PC_5_ALT1  = PC_5  | ALT1,
53
+PC_6_ALT1  = PC_6  | ALT1,
54
+PC_6_ALT2  = PC_6  | ALT2,
55
+PC_7_ALT1  = PC_7  | ALT1,
56
+PC_7_ALT2  = PC_7  | ALT2,
57
+PC_8_ALT1  = PC_8  | ALT1,
58
+PC_9_ALT1  = PC_9  | ALT1,
59
+PC_10_ALT1 = PC_10 | ALT1,
60
+PC_11_ALT1 = PC_11 | ALT1,
61
+
62
+/* SYS_WKUP */
63
+#ifdef PWR_WAKEUP_PIN1
64
+  SYS_WKUP1 = PA_0, /* SYS_WKUP0 */
65
+#endif
66
+#ifdef PWR_WAKEUP_PIN2
67
+  SYS_WKUP2 = PA_2, /* SYS_WKUP1 */
68
+#endif
69
+#ifdef PWR_WAKEUP_PIN3
70
+  SYS_WKUP3 = PC_13, /* SYS_WKUP2 */
71
+#endif
72
+#ifdef PWR_WAKEUP_PIN4
73
+  SYS_WKUP4 = NC,
74
+#endif
75
+#ifdef PWR_WAKEUP_PIN5
76
+  SYS_WKUP5 = NC,
77
+#endif
78
+#ifdef PWR_WAKEUP_PIN6
79
+  SYS_WKUP6 = PC_1, /* SYS_WKUP5 */
80
+#endif
81
+#ifdef PWR_WAKEUP_PIN7
82
+  SYS_WKUP7 = NC,
83
+#endif
84
+#ifdef PWR_WAKEUP_PIN8
85
+  SYS_WKUP8 = NC,
86
+#endif
87
+
88
+/* USB */
89
+#ifdef USBCON
90
+  USB_OTG_FS_DM       = PA_11,
91
+  USB_OTG_FS_DP       = PA_12,
92
+  USB_OTG_FS_ID       = PA_10,
93
+  USB_OTG_FS_SOF      = PA_8,
94
+  USB_OTG_FS_VBUS     = PA_9,
95
+  USB_OTG_HS_DM       = PB_14,
96
+  USB_OTG_HS_DP       = PB_15,
97
+  USB_OTG_HS_ID       = PB_12,
98
+  USB_OTG_HS_SOF      = PA_4,
99
+  USB_OTG_HS_ULPI_CK  = PA_5,
100
+  USB_OTG_HS_ULPI_D0  = PA_3,
101
+  USB_OTG_HS_ULPI_D1  = PB_0,
102
+  USB_OTG_HS_ULPI_D2  = PB_1,
103
+  USB_OTG_HS_ULPI_D3  = PB_10,
104
+  USB_OTG_HS_ULPI_D4  = PB_11,
105
+  USB_OTG_HS_ULPI_D5  = PB_12,
106
+  USB_OTG_HS_ULPI_D6  = PB_13,
107
+  USB_OTG_HS_ULPI_D7  = PB_5,
108
+  USB_OTG_HS_ULPI_DIR = PC_2_C,
109
+  USB_OTG_HS_ULPI_NXT = PC_3_C,
110
+  USB_OTG_HS_ULPI_STP = PC_0,
111
+  USB_OTG_HS_VBUS     = PB_13,
112
+#endif

+ 208
- 0
buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld 查看文件

@@ -0,0 +1,208 @@
1
+/*
2
+******************************************************************************
3
+**
4
+**  File        : LinkerScript.ld
5
+**
6
+**  Author		: Auto-generated by STM32CubeIDE
7
+**
8
+**  Abstract    : Linker script for STM32H743VI Device from STM32H7 series
9
+**                      2048Kbytes FLASH
10
+**                      128Kbytes DTCMRAM
11
+**                      64Kbytes ITCMRAM
12
+**                      512Kbytes RAM_D1
13
+**                      288Kbytes RAM_D2
14
+**                      64Kbytes RAM_D3
15
+**
16
+**                Set heap size, stack size and stack location according
17
+**                to application requirements.
18
+**
19
+**                Set memory bank area and size if external memory is used.
20
+**
21
+**  Target      : STMicroelectronics STM32
22
+**
23
+**  Distribution: The file is distributed as is without any warranty
24
+**                of any kind.
25
+**
26
+*****************************************************************************
27
+** @attention
28
+**
29
+** <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
30
+**
31
+** Redistribution and use in source and binary forms, with or without modification,
32
+** are permitted provided that the following conditions are met:
33
+**   1. Redistributions of source code must retain the above copyright notice,
34
+**      this list of conditions and the following disclaimer.
35
+**   2. Redistributions in binary form must reproduce the above copyright notice,
36
+**      this list of conditions and the following disclaimer in the documentation
37
+**      and/or other materials provided with the distribution.
38
+**   3. Neither the name of STMicroelectronics nor the names of its contributors
39
+**      may be used to endorse or promote products derived from this software
40
+**      without specific prior written permission.
41
+**
42
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43
+** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
+** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45
+** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
46
+** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47
+** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
48
+** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
49
+** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50
+** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
51
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52
+**
53
+*****************************************************************************
54
+*/
55
+
56
+/* Entry Point */
57
+ENTRY(Reset_Handler)
58
+
59
+/* Highest address of the user mode stack */
60
+_estack = 0x24080000;	/* end of "RAM_D1" Ram type memory */
61
+
62
+_Min_Heap_Size = 0x200;	/* required amount of heap  */
63
+_Min_Stack_Size = 0x400;	/* required amount of stack */
64
+
65
+/* Memories definition */
66
+MEMORY
67
+{
68
+    DTCMRAM	(xrw)	: ORIGIN = 0x20000000,	LENGTH = 128K
69
+    ITCMRAM	(xrw)	: ORIGIN = 0x00000000,	LENGTH = 64K
70
+    RAM_D1	(xrw)	: ORIGIN = 0x24000000,	LENGTH = 512K
71
+    RAM_D2	(xrw)	: ORIGIN = 0x30000000,	LENGTH = 288K
72
+    RAM_D3	(xrw)	: ORIGIN = 0x38000000,	LENGTH = 64K
73
+    FLASH	(rx)	: ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
74
+}
75
+
76
+/* Sections */
77
+SECTIONS
78
+{
79
+  /* The startup code into "FLASH" Rom type memory */
80
+  .isr_vector :
81
+  {
82
+    . = ALIGN(4);
83
+    KEEP(*(.isr_vector)) /* Startup code */
84
+    . = ALIGN(4);
85
+  } >FLASH
86
+
87
+  /* The program code and other data into "FLASH" Rom type memory */
88
+  .text :
89
+  {
90
+    . = ALIGN(4);
91
+    *(.text)           /* .text sections (code) */
92
+    *(.text*)          /* .text* sections (code) */
93
+    *(.glue_7)         /* glue arm to thumb code */
94
+    *(.glue_7t)        /* glue thumb to arm code */
95
+    *(.eh_frame)
96
+
97
+    KEEP (*(.init))
98
+    KEEP (*(.fini))
99
+
100
+    . = ALIGN(4);
101
+    _etext = .;        /* define a global symbols at end of code */
102
+  } >FLASH
103
+
104
+  /* Constant data into "FLASH" Rom type memory */
105
+  .rodata :
106
+  {
107
+    . = ALIGN(4);
108
+    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
109
+    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
110
+    . = ALIGN(4);
111
+  } >FLASH
112
+
113
+  .ARM.extab   : {
114
+  	. = ALIGN(4);
115
+  	*(.ARM.extab* .gnu.linkonce.armextab.*)
116
+  	. = ALIGN(4);
117
+  } >FLASH
118
+
119
+  .ARM : {
120
+    . = ALIGN(4);
121
+    __exidx_start = .;
122
+    *(.ARM.exidx*)
123
+    __exidx_end = .;
124
+    . = ALIGN(4);
125
+  } >FLASH
126
+
127
+  .preinit_array     :
128
+  {
129
+    . = ALIGN(4);
130
+    PROVIDE_HIDDEN (__preinit_array_start = .);
131
+    KEEP (*(.preinit_array*))
132
+    PROVIDE_HIDDEN (__preinit_array_end = .);
133
+    . = ALIGN(4);
134
+  } >FLASH
135
+
136
+  .init_array :
137
+  {
138
+    . = ALIGN(4);
139
+    PROVIDE_HIDDEN (__init_array_start = .);
140
+    KEEP (*(SORT(.init_array.*)))
141
+    KEEP (*(.init_array*))
142
+    PROVIDE_HIDDEN (__init_array_end = .);
143
+    . = ALIGN(4);
144
+  } >FLASH
145
+
146
+  .fini_array :
147
+  {
148
+    . = ALIGN(4);
149
+    PROVIDE_HIDDEN (__fini_array_start = .);
150
+    KEEP (*(SORT(.fini_array.*)))
151
+    KEEP (*(.fini_array*))
152
+    PROVIDE_HIDDEN (__fini_array_end = .);
153
+    . = ALIGN(4);
154
+  } >FLASH
155
+
156
+  /* Used by the startup to initialize data */
157
+  _sidata = LOADADDR(.data);
158
+
159
+  /* Initialized data sections into "RAM_D1" Ram type memory */
160
+  .data :
161
+  {
162
+    . = ALIGN(4);
163
+    _sdata = .;        /* create a global symbol at data start */
164
+    *(.data)           /* .data sections */
165
+    *(.data*)          /* .data* sections */
166
+
167
+    . = ALIGN(4);
168
+    _edata = .;        /* define a global symbol at data end */
169
+
170
+  } >RAM_D1 AT> FLASH
171
+
172
+  /* Uninitialized data section into "RAM_D1" Ram type memory */
173
+  . = ALIGN(4);
174
+  .bss :
175
+  {
176
+    /* This is used by the startup in order to initialize the .bss section */
177
+    _sbss = .;         /* define a global symbol at bss start */
178
+    __bss_start__ = _sbss;
179
+    *(.bss)
180
+    *(.bss*)
181
+    *(COMMON)
182
+
183
+    . = ALIGN(4);
184
+    _ebss = .;         /* define a global symbol at bss end */
185
+    __bss_end__ = _ebss;
186
+  } >RAM_D1
187
+
188
+  /* User_heap_stack section, used to check that there is enough "RAM_D1" Ram  type memory left */
189
+  ._user_heap_stack :
190
+  {
191
+    . = ALIGN(8);
192
+    PROVIDE ( end = . );
193
+    PROVIDE ( _end = . );
194
+    . = . + _Min_Heap_Size;
195
+    . = . + _Min_Stack_Size;
196
+    . = ALIGN(8);
197
+  } >RAM_D1
198
+
199
+  /* Remove information from the compiler libraries */
200
+  /DISCARD/ :
201
+  {
202
+    libc.a ( * )
203
+    libm.a ( * )
204
+    libgcc.a ( * )
205
+  }
206
+
207
+  .ARM.attributes 0 : { *(.ARM.attributes) }
208
+}

+ 245
- 0
buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743Vx.cpp 查看文件

@@ -0,0 +1,245 @@
1
+/*
2
+ *******************************************************************************
3
+ * Copyright (c) 2020-2021, STMicroelectronics
4
+ * All rights reserved.
5
+ *
6
+ * This software component is licensed by ST under BSD 3-Clause license,
7
+ * the "License"; You may not use this file except in compliance with the
8
+ * License. You may obtain a copy of the License at:
9
+ *                        opensource.org/licenses/BSD-3-Clause
10
+ *
11
+ *******************************************************************************
12
+ */
13
+#if defined(STM32H743xx)
14
+#include "pins_arduino.h"
15
+
16
+// Digital PinName array
17
+const PinName digitalPin[] = {
18
+  PA_0,   // D0/A0
19
+  PA_1,   // D1/A1
20
+  PA_2,   // D2/A2
21
+  PA_3,   // D3/A3
22
+  PA_4,   // D4/A4
23
+  PA_5,   // D5/A5
24
+  PA_6,   // D6/A6
25
+  PA_7,   // D7/A7
26
+  PA_8,   // D8
27
+  PA_9,   // D9
28
+  PA_10,  // D10
29
+  PA_11,  // D11
30
+  PA_12,  // D12
31
+  PA_13,  // D13
32
+  PA_14,  // D14
33
+  PA_15,  // D15
34
+  PB_0,   // D16/A8
35
+  PB_1,   // D17/A9
36
+  PB_2,   // D18
37
+  PB_3,   // D19
38
+  PB_4,   // D20
39
+  PB_5,   // D21
40
+  PB_6,   // D22
41
+  PB_7,   // D23
42
+  PB_8,   // D24
43
+  PB_9,   // D25
44
+  PB_10,  // D26
45
+  PB_11,  // D27
46
+  PB_12,  // D28
47
+  PB_13,  // D29
48
+  PB_14,  // D30
49
+  PB_15,  // D31
50
+  PC_0,   // D32/A10
51
+  PC_1,   // D33/A11
52
+  PC_4,   // D34/A12
53
+  PC_5,   // D35/A13
54
+  PC_6,   // D36
55
+  PC_7,   // D37
56
+  PC_8,   // D38
57
+  PC_9,   // D39
58
+  PC_10,  // D40
59
+  PC_11,  // D41
60
+  PC_12,  // D42
61
+  PC_13,  // D43
62
+  PC_14,  // D44
63
+  PC_15,  // D45
64
+  PD_0,   // D46
65
+  PD_1,   // D47
66
+  PD_2,   // D48
67
+  PD_3,   // D49
68
+  PD_4,   // D50
69
+  PD_5,   // D51
70
+  PD_6,   // D52
71
+  PD_7,   // D53
72
+  PD_8,   // D54
73
+  PD_9,   // D55
74
+  PD_10,  // D56
75
+  PD_11,  // D57
76
+  PD_12,  // D58
77
+  PD_13,  // D59
78
+  PD_14,  // D60
79
+  PD_15,  // D61
80
+  PE_0,   // D62
81
+  PE_1,   // D63
82
+  PE_2,   // D64
83
+  PE_3,   // D65
84
+  PE_4,   // D66
85
+  PE_5,   // D67
86
+  PE_6,   // D68
87
+  PE_7,   // D69
88
+  PE_8,   // D70
89
+  PE_9,   // D71
90
+  PE_10,  // D72
91
+  PE_11,  // D73
92
+  PE_12,  // D74
93
+  PE_13,  // D75
94
+  PE_14,  // D76
95
+  PE_15,  // D77
96
+  PH_0,   // D78
97
+  PH_1,   // D79
98
+  PC_2_C, // D80/A14
99
+  PC_3_C  // D81/A15
100
+};
101
+
102
+// Analog (Ax) pin number array
103
+const uint32_t analogInputPin[] = {
104
+  0,  // A0,  PA0
105
+  1,  // A1,  PA1
106
+  2,  // A2,  PA2
107
+  3,  // A3,  PA3
108
+  4,  // A4,  PA4
109
+  5,  // A5,  PA5
110
+  6,  // A6,  PA6
111
+  7,  // A7,  PA7
112
+  16, // A8,  PB0
113
+  17, // A9,  PB1
114
+  32, // A10, PC0
115
+  33, // A11, PC1
116
+  34, // A12, PC4
117
+  35, // A13, PC5
118
+  80, // A14, PC2_C
119
+  81  // A15, PC3_C
120
+};
121
+
122
+/*
123
+ * @brief  System Clock Configuration
124
+ * @param  None
125
+ * @retval None
126
+ */
127
+WEAK void SystemClock_Config(void)
128
+{
129
+  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
130
+  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
131
+  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {};
132
+
133
+  /** Supply configuration update enable
134
+  */
135
+  HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
136
+  /** Configure the main internal regulator output voltage
137
+  */
138
+  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
139
+
140
+  while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
141
+  /** Initializes the RCC Oscillators according to the specified parameters
142
+  * in the RCC_OscInitTypeDef structure.
143
+  */
144
+  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
145
+  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
146
+  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
147
+  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
148
+  RCC_OscInitStruct.PLL.PLLM = 5;  // 25Mhz / 5 = 5Mhz
149
+  RCC_OscInitStruct.PLL.PLLN = 192; // 25Mhz / 5 * 192 = 960Mhz
150
+  RCC_OscInitStruct.PLL.PLLP = 2;  // 960Mhz / 2 = 480Mhz
151
+  RCC_OscInitStruct.PLL.PLLQ = 20; // 960Mhz / 20 = 48Mhz for USB
152
+  RCC_OscInitStruct.PLL.PLLR = 20; // unused
153
+  RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
154
+  RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
155
+  RCC_OscInitStruct.PLL.PLLFRACN = 0;
156
+  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
157
+  {
158
+    Error_Handler();
159
+  }
160
+  /** Initializes the CPU, AHB and APB buses clocks
161
+  */
162
+  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
163
+                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
164
+                              |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
165
+  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
166
+  RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
167
+  RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
168
+  RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
169
+  RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
170
+  RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
171
+  RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
172
+
173
+  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
174
+  {
175
+    Error_Handler();
176
+  }
177
+
178
+  PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_QSPI
179
+                                             | RCC_PERIPHCLK_SDMMC | RCC_PERIPHCLK_ADC
180
+                                             | RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USART16
181
+                                             | RCC_PERIPHCLK_USART234578 | RCC_PERIPHCLK_I2C123
182
+                                             | RCC_PERIPHCLK_I2C4 | RCC_PERIPHCLK_SPI123
183
+                                             | RCC_PERIPHCLK_SPI45 | RCC_PERIPHCLK_SPI6;
184
+
185
+  /* PLL1 qclk used for USB 48 Mhz */
186
+  /* PLL1 qclk also used for FMC, QUADSPI, SDMMC, RNG, SAI */
187
+  /* PLL2 pclk is needed for adc max 80 Mhz (p,q,r same) */
188
+  /* PLL2 pclk also used for LP timers 2,3,4,5, SPI 1,2,3 */
189
+  /* PLL2 qclk is needed for uart, can, spi4,5,6 80 Mhz */
190
+  /* PLL3 r clk is needed for i2c 80 Mhz (p,q,r same) */
191
+  PeriphClkInitStruct.PLL2.PLL2M = 15; // M DIV 15 vco 25 / 15 ~ 1.667 Mhz
192
+  PeriphClkInitStruct.PLL2.PLL2N = 96; // N MUL 96
193
+  PeriphClkInitStruct.PLL2.PLL2P = 2;  // P div 2
194
+  PeriphClkInitStruct.PLL2.PLL2Q = 2;  // Q div 2
195
+  PeriphClkInitStruct.PLL2.PLL2R = 2;  // R div 2
196
+  // RCC_PLL1VCIRANGE_0  Clock range frequency between 1 and 2 MHz
197
+  PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_0;
198
+  PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM;
199
+  PeriphClkInitStruct.PLL2.PLL2FRACN = 0;
200
+  PeriphClkInitStruct.PLL3.PLL3M = 15; // M DIV 15 vco 25 / 15 ~ 1.667 Mhz
201
+  PeriphClkInitStruct.PLL3.PLL3N = 96; // N MUL 96
202
+  PeriphClkInitStruct.PLL3.PLL3P = 2;  // P div 2
203
+  PeriphClkInitStruct.PLL3.PLL3Q = 2;  // Q div 2
204
+  PeriphClkInitStruct.PLL3.PLL3R = 2;  // R div 2
205
+  // RCC_PLL1VCIRANGE_0  Clock range frequency between 1 and 2 MHz
206
+  PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_0;
207
+  PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOMEDIUM;
208
+  PeriphClkInitStruct.PLL3.PLL3FRACN = 0;
209
+  // ADC from PLL2 pclk
210
+  PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2;
211
+  // USB from PLL1 qclk
212
+  PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
213
+  // QSPI from PLL1 qclk
214
+  PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_PLL;
215
+  // SDMMC from PLL1 qclk
216
+  PeriphClkInitStruct.SdmmcClockSelection = 0;
217
+  //PeriphClkInitStruct.SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL;
218
+  // LPUART from PLL2 qclk
219
+  PeriphClkInitStruct.Lpuart1ClockSelection = 0;
220
+  //PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PLL2;
221
+  // USART from PLL2 qclk
222
+  PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_PLL2;
223
+  // USART from PLL2 qclk
224
+  PeriphClkInitStruct.Usart234578ClockSelection = 0;
225
+  //PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_PLL2;
226
+  // I2C123 from PLL3 rclk
227
+  PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_PLL3;
228
+  // I2C4 from PLL3 rclk
229
+  PeriphClkInitStruct.I2c4ClockSelection = 0;
230
+  //PeriphClkInitStruct.I2c4ClockSelection = RCC_I2C4CLKSOURCE_PLL3;
231
+  // SPI123 from PLL2 pclk
232
+  PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2;
233
+  // SPI45 from PLL2 qclk
234
+  PeriphClkInitStruct.Spi45ClockSelection = 0;
235
+  //PeriphClkInitStruct.Spi45ClockSelection = RCC_SPI45CLKSOURCE_PLL2;
236
+  // SPI6 from PLL2 qclk
237
+  PeriphClkInitStruct.Spi6ClockSelection = 0;
238
+  //PeriphClkInitStruct.Spi6ClockSelection = RCC_SPI6CLKSOURCE_PLL2;
239
+
240
+  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
241
+    Error_Handler();
242
+  }
243
+}
244
+
245
+#endif /* ARDUINO_GENERIC_* */

+ 268
- 0
buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743Vx.h 查看文件

@@ -0,0 +1,268 @@
1
+/*
2
+ *******************************************************************************
3
+ * Copyright (c) 2020-2021, STMicroelectronics
4
+ * All rights reserved.
5
+ *
6
+ * This software component is licensed by ST under BSD 3-Clause license,
7
+ * the "License"; You may not use this file except in compliance with the
8
+ * License. You may obtain a copy of the License at:
9
+ *                        opensource.org/licenses/BSD-3-Clause
10
+ *
11
+ *******************************************************************************
12
+ */
13
+#pragma once
14
+
15
+/*----------------------------------------------------------------------------
16
+ *        STM32 pins number
17
+ *----------------------------------------------------------------------------*/
18
+#define PA0                     PIN_A0
19
+#define PA1                     PIN_A1
20
+#define PA2                     PIN_A2
21
+#define PA3                     PIN_A3
22
+#define PA4                     PIN_A4
23
+#define PA5                     PIN_A5
24
+#define PA6                     PIN_A6
25
+#define PA7                     PIN_A7
26
+#define PA8                     8
27
+#define PA9                     9
28
+#define PA10                    10
29
+#define PA11                    11
30
+#define PA12                    12
31
+#define PA13                    13
32
+#define PA14                    14
33
+#define PA15                    15
34
+#define PB0                     PIN_A8
35
+#define PB1                     PIN_A9
36
+#define PB2                     18
37
+#define PB3                     19
38
+#define PB4                     20
39
+#define PB5                     21
40
+#define PB6                     22
41
+#define PB7                     23
42
+#define PB8                     24
43
+#define PB9                     25
44
+#define PB10                    26
45
+#define PB11                    27
46
+#define PB12                    28
47
+#define PB13                    29
48
+#define PB14                    30
49
+#define PB15                    31
50
+#define PC0                     PIN_A10
51
+#define PC1                     PIN_A11
52
+#define PC4                     PIN_A12
53
+#define PC5                     PIN_A13
54
+#define PC6                     36
55
+#define PC7                     37
56
+#define PC8                     38
57
+#define PC9                     39
58
+#define PC10                    40
59
+#define PC11                    41
60
+#define PC12                    42
61
+#define PC13                    43
62
+#define PC14                    44
63
+#define PC15                    45
64
+#define PD0                     46
65
+#define PD1                     47
66
+#define PD2                     48
67
+#define PD3                     49
68
+#define PD4                     50
69
+#define PD5                     51
70
+#define PD6                     52
71
+#define PD7                     53
72
+#define PD8                     54
73
+#define PD9                     55
74
+#define PD10                    56
75
+#define PD11                    57
76
+#define PD12                    58
77
+#define PD13                    59
78
+#define PD14                    60
79
+#define PD15                    61
80
+#define PE0                     62
81
+#define PE1                     63
82
+#define PE2                     64
83
+#define PE3                     65
84
+#define PE4                     66
85
+#define PE5                     67
86
+#define PE6                     68
87
+#define PE7                     69
88
+#define PE8                     70
89
+#define PE9                     71
90
+#define PE10                    72
91
+#define PE11                    73
92
+#define PE12                    74
93
+#define PE13                    75
94
+#define PE14                    76
95
+#define PE15                    77
96
+#define PH0                     78
97
+#define PH1                     79
98
+#define PC2_C                   PIN_A14
99
+#define PC3_C                   PIN_A15
100
+#define PC2                     PC2_C
101
+#define PC3                     PC3_C
102
+
103
+// Alternate pins number
104
+#define PA0_ALT1                (PA0  | ALT1)
105
+#define PA1_ALT1                (PA1  | ALT1)
106
+#define PA1_ALT2                (PA1  | ALT2)
107
+#define PA2_ALT1                (PA2  | ALT1)
108
+#define PA2_ALT2                (PA2  | ALT2)
109
+#define PA3_ALT1                (PA3  | ALT1)
110
+#define PA3_ALT2                (PA3  | ALT2)
111
+#define PA4_ALT1                (PA4  | ALT1)
112
+#define PA4_ALT2                (PA4  | ALT2)
113
+#define PA5_ALT1                (PA5  | ALT1)
114
+#define PA6_ALT1                (PA6  | ALT1)
115
+#define PA7_ALT1                (PA7  | ALT1)
116
+#define PA7_ALT2                (PA7  | ALT2)
117
+#define PA7_ALT3                (PA7  | ALT3)
118
+#define PA9_ALT1                (PA9  | ALT1)
119
+#define PA10_ALT1               (PA10 | ALT1)
120
+#define PA11_ALT1               (PA11 | ALT1)
121
+#define PA12_ALT1               (PA12 | ALT1)
122
+#define PA15_ALT1               (PA15 | ALT1)
123
+#define PA15_ALT2               (PA15 | ALT2)
124
+#define PB0_ALT1                (PB0  | ALT1)
125
+#define PB0_ALT2                (PB0  | ALT2)
126
+#define PB1_ALT1                (PB1  | ALT1)
127
+#define PB1_ALT2                (PB1  | ALT2)
128
+#define PB3_ALT1                (PB3  | ALT1)
129
+#define PB3_ALT2                (PB3  | ALT2)
130
+#define PB4_ALT1                (PB4  | ALT1)
131
+#define PB4_ALT2                (PB4  | ALT2)
132
+#define PB5_ALT1                (PB5  | ALT1)
133
+#define PB5_ALT2                (PB5  | ALT2)
134
+#define PB6_ALT1                (PB6  | ALT1)
135
+#define PB6_ALT2                (PB6  | ALT2)
136
+#define PB7_ALT1                (PB7  | ALT1)
137
+#define PB8_ALT1                (PB8  | ALT1)
138
+#define PB8_ALT2                (PB8  | ALT2)
139
+#define PB9_ALT1                (PB9  | ALT1)
140
+#define PB9_ALT2                (PB9  | ALT2)
141
+#define PB14_ALT1               (PB14 | ALT1)
142
+#define PB14_ALT2               (PB14 | ALT2)
143
+#define PB15_ALT1               (PB15 | ALT1)
144
+#define PB15_ALT2               (PB15 | ALT2)
145
+#define PC0_ALT1                (PC0  | ALT1)
146
+#define PC0_ALT2                (PC0  | ALT2)
147
+#define PC1_ALT1                (PC1  | ALT1)
148
+#define PC1_ALT2                (PC1  | ALT2)
149
+#define PC4_ALT1                (PC4  | ALT1)
150
+#define PC5_ALT1                (PC5  | ALT1)
151
+#define PC6_ALT1                (PC6  | ALT1)
152
+#define PC6_ALT2                (PC6  | ALT2)
153
+#define PC7_ALT1                (PC7  | ALT1)
154
+#define PC7_ALT2                (PC7  | ALT2)
155
+#define PC8_ALT1                (PC8  | ALT1)
156
+#define PC9_ALT1                (PC9  | ALT1)
157
+#define PC10_ALT1               (PC10 | ALT1)
158
+#define PC11_ALT1               (PC11 | ALT1)
159
+
160
+#define NUM_DIGITAL_PINS        82
161
+#define NUM_DUALPAD_PINS        2
162
+#define NUM_ANALOG_INPUTS       16
163
+
164
+// On-board LED pin number
165
+#ifndef LED_BUILTIN
166
+  #define LED_BUILTIN           PNUM_NOT_DEFINED
167
+#endif
168
+
169
+// On-board user button
170
+#ifndef USER_BTN
171
+  #define USER_BTN              PNUM_NOT_DEFINED
172
+#endif
173
+
174
+// SPI definitions
175
+#ifndef PIN_SPI_SS
176
+  #define PIN_SPI_SS            PA4
177
+#endif
178
+#ifndef PIN_SPI_SS1
179
+  #define PIN_SPI_SS1           PA15
180
+#endif
181
+#ifndef PIN_SPI_SS2
182
+  #define PIN_SPI_SS2           PNUM_NOT_DEFINED
183
+#endif
184
+#ifndef PIN_SPI_SS3
185
+  #define PIN_SPI_SS3           PNUM_NOT_DEFINED
186
+#endif
187
+#ifndef PIN_SPI_MOSI
188
+  #define PIN_SPI_MOSI          PA7
189
+#endif
190
+#ifndef PIN_SPI_MISO
191
+  #define PIN_SPI_MISO          PA6
192
+#endif
193
+#ifndef PIN_SPI_SCK
194
+  #define PIN_SPI_SCK           PA5
195
+#endif
196
+
197
+// I2C definitions
198
+#ifndef PIN_WIRE_SDA
199
+  #define PIN_WIRE_SDA          PB7
200
+#endif
201
+#ifndef PIN_WIRE_SCL
202
+  #define PIN_WIRE_SCL          PB6
203
+#endif
204
+
205
+// Timer Definitions
206
+// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
207
+#ifndef TIMER_TONE
208
+  #define TIMER_TONE            TIM6
209
+#endif
210
+#ifndef TIMER_SERVO
211
+  #define TIMER_SERVO           TIM7
212
+#endif
213
+
214
+// UART Definitions
215
+#ifndef SERIAL_UART_INSTANCE
216
+  #define SERIAL_UART_INSTANCE  4
217
+#endif
218
+
219
+// Default pin used for generic 'Serial' instance
220
+// Mandatory for Firmata
221
+#ifndef PIN_SERIAL_RX
222
+  #define PIN_SERIAL_RX         PA1
223
+#endif
224
+#ifndef PIN_SERIAL_TX
225
+  #define PIN_SERIAL_TX         PA0
226
+#endif
227
+
228
+// Extra HAL modules
229
+#if !defined(HAL_DAC_MODULE_DISABLED)
230
+  #define HAL_DAC_MODULE_ENABLED
231
+#endif
232
+#if !defined(HAL_ETH_MODULE_DISABLED)
233
+  #define HAL_ETH_MODULE_ENABLED
234
+#endif
235
+#if !defined(HAL_QSPI_MODULE_DISABLED)
236
+  #define HAL_QSPI_MODULE_ENABLED
237
+#endif
238
+#if !defined(HAL_SD_MODULE_DISABLED)
239
+  #define HAL_SD_MODULE_ENABLED
240
+#endif
241
+
242
+/*----------------------------------------------------------------------------
243
+ *        Arduino objects - C++ only
244
+ *----------------------------------------------------------------------------*/
245
+
246
+#ifdef __cplusplus
247
+  // These serial port names are intended to allow libraries and architecture-neutral
248
+  // sketches to automatically default to the correct port name for a particular type
249
+  // of use.  For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
250
+  // the first hardware serial port whose RX/TX pins are not dedicated to another use.
251
+  //
252
+  // SERIAL_PORT_MONITOR        Port which normally prints to the Arduino Serial Monitor
253
+  //
254
+  // SERIAL_PORT_USBVIRTUAL     Port which is USB virtual serial
255
+  //
256
+  // SERIAL_PORT_LINUXBRIDGE    Port which connects to a Linux system via Bridge library
257
+  //
258
+  // SERIAL_PORT_HARDWARE       Hardware serial port, physical RX & TX pins.
259
+  //
260
+  // SERIAL_PORT_HARDWARE_OPEN  Hardware serial ports which are open for use.  Their RX & TX
261
+  //                            pins are NOT connected to anything by default.
262
+  #ifndef SERIAL_PORT_MONITOR
263
+    #define SERIAL_PORT_MONITOR   Serial
264
+  #endif
265
+  #ifndef SERIAL_PORT_HARDWARE
266
+    #define SERIAL_PORT_HARDWARE  Serial
267
+  #endif
268
+#endif

+ 21
- 0
ini/stm32h7.ini 查看文件

@@ -38,3 +38,24 @@ build_flags        = ${stm32_variant.build_flags} ${stm_flash_drive.build_flags}
38 38
                     -DHAL_SD_MODULE_ENABLED
39 39
 upload_protocol    = cmsis-dap
40 40
 debug_tool         = cmsis-dap
41
+
42
+#
43
+# BigTreeTech SKR V3.0 / V3.0 EZ (STM32H743VIT6 ARM Cortex-M7)
44
+#
45
+[env:STM32H743Vx_btt]
46
+extends                     = stm32_variant
47
+platform                    = ststm32@~14.1.0
48
+platform_packages           = framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/main.zip
49
+board                       = marlin_STM32H743Vx
50
+board_build.offset          = 0x20000
51
+board_upload.offset_address = 0x08020000
52
+build_flags                 = ${stm32_variant.build_flags}
53
+                            -DPIN_SERIAL1_RX=PA_10 -DPIN_SERIAL1_TX=PA_9
54
+                            -DPIN_SERIAL3_RX=PD_9 -DPIN_SERIAL3_TX=PD_8
55
+                            -DPIN_SERIAL4_RX=PA_1 -DPIN_SERIAL4_TX=PA_0
56
+                            -DSERIAL_RX_BUFFER_SIZE=1024 -DSERIAL_TX_BUFFER_SIZE=1024
57
+                            -DTIMER_SERVO=TIM5 -DTIMER_TONE=TIM2
58
+                            -DSTEP_TIMER_IRQ_PRIO=0
59
+                            -DD_CACHE_DISABLED
60
+upload_protocol             = cmsis-dap
61
+debug_tool                  = cmsis-dap

Loading…
取消
儲存