stm32: fix conditional compilation error when not using uart

This commit is contained in:
hohoho
2025-01-23 19:56:57 +01:00
parent 597446fbea
commit 5ca3822830
4 changed files with 17 additions and 12 deletions

View File

@@ -46,7 +46,9 @@ void USB_LP_IRQHandler(void) {
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+
#ifdef UART_DEV
UART_HandleTypeDef UartHandle;
#endif
void board_init(void) {
board_clock_init();
@@ -58,8 +60,6 @@ void board_init(void) {
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
UART_CLK_EN();
#if CFG_TUSB_OS == OPT_OS_NONE
// 1ms tick timer
SysTick_Config(SystemCoreClock / 1000);
@@ -102,6 +102,8 @@ void board_init(void) {
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
#ifdef UART_DEV
UART_CLK_EN();
// UART
GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
@@ -159,7 +161,7 @@ int board_uart_write(void const* buf, int len) {
HAL_UART_Transmit(&UartHandle, (uint8_t*) (uintptr_t) buf, len, 0xffff);
return len;
#else
(void) buf; (void) len; (void) UartHandle;
(void) buf; (void) len;
return 0;
#endif
}