@@ -270,27 +270,26 @@ void uart_init(serial_t *obj)
270
270
function = pinmap_function (obj -> pin_rx , PinMap_UART_RX );
271
271
GPIO_InitStruct .Pin = STM_GPIO_PIN (obj -> pin_rx );
272
272
GPIO_InitStruct .Mode = STM_PIN_MODE (function );
273
- GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_HIGH ;
274
273
GPIO_InitStruct .Pull = STM_PIN_PUPD (function );
274
+ /* Common */
275
275
#ifdef STM32F1xx
276
276
pin_SetF1AFPin (STM_PIN_AFNUM (function ));
277
277
#else
278
278
GPIO_InitStruct .Alternate = STM_PIN_AFNUM (function );
279
279
#endif /* STM32F1xx */
280
+ #ifdef GPIO_SPEED_FREQ_VERY_HIGH
281
+ GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_VERY_HIGH ;
282
+ #else
283
+ GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_HIGH ;
284
+ #endif
280
285
HAL_GPIO_Init (port , & GPIO_InitStruct );
281
286
282
287
//TX
283
288
port = set_GPIO_Port_Clock (STM_PORT (obj -> pin_tx ));
284
289
function = pinmap_function (obj -> pin_tx , PinMap_UART_TX );
285
290
GPIO_InitStruct .Pin = STM_GPIO_PIN (obj -> pin_tx );
286
291
GPIO_InitStruct .Mode = STM_PIN_MODE (function );
287
- GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_HIGH ;
288
292
GPIO_InitStruct .Pull = STM_PIN_PUPD (function );
289
- #ifdef STM32F1xx
290
- pin_SetF1AFPin (STM_PIN_AFNUM (function ));
291
- #else
292
- GPIO_InitStruct .Alternate = STM_PIN_AFNUM (function );
293
- #endif /* STM32F1xx */
294
293
HAL_GPIO_Init (port , & GPIO_InitStruct );
295
294
296
295
@@ -308,7 +307,9 @@ void uart_init(serial_t *obj)
308
307
&& !defined(STM32L1xx )
309
308
huart -> AdvancedInit .AdvFeatureInit = UART_ADVFEATURE_NO_INIT ;
310
309
#endif
311
- // huart->Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
310
+ #ifdef UART_ONE_BIT_SAMPLE_DISABLE
311
+ huart -> Init .OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE ;
312
+ #endif
312
313
313
314
#if defined(LPUART1_BASE )
314
315
/* Note that LPUART clock source must be in the range [3 x baud rate, 4096 x baud rate], check Ref Manual */
0 commit comments