[bsp][hc32]更正pin和usart初始化顺序(bug fix)

#8480
#8458
This commit is contained in:
yangpengya 2024-01-16 01:00:09 +08:00 committed by GitHub
parent e4be19eb8f
commit 2a68f70094
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 10 deletions

View File

@ -13,6 +13,28 @@
#define DBG_TAG "drv_common" #define DBG_TAG "drv_common"
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#include <rtdbg.h> #include <rtdbg.h>
#ifdef RT_USING_PIN
#include <drv_gpio.h>
#endif
#ifdef RT_USING_SERIAL
#ifdef RT_USING_SERIAL_V2
#include <drv_usart_v2.h>
#else
#include <drv_usart.h>
#endif /* RT_USING_SERIAL */
#endif /* RT_USING_SERIAL_V2 */
#ifdef RT_USING_FINSH
#include <finsh.h>
static void reboot(uint8_t argc, char **argv)
{
rt_hw_cpu_reset();
}
MSH_CMD_EXPORT(reboot, Reboot System);
#endif /* RT_USING_FINSH */
/** /**
* This function is executed in case of error occurrence. * This function is executed in case of error occurrence.
*/ */
@ -71,14 +93,22 @@ void rt_hw_board_init()
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
#endif #endif
/* Board underlying hardware initialization */ #ifdef RT_USING_PIN
#ifdef RT_USING_COMPONENTS_INIT rt_hw_pin_init();
rt_components_board_init(); #endif
#ifdef RT_USING_SERIAL
rt_hw_usart_init();
#endif #endif
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
rt_console_set_device(RT_CONSOLE_DEVICE_NAME); rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif #endif
/* Board underlying hardware initialization */
#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif
} }
void rt_hw_us_delay(rt_uint32_t us) void rt_hw_us_delay(rt_uint32_t us)

View File

@ -504,7 +504,6 @@ int rt_hw_pin_init(void)
return rt_device_pin_register("pin", &hc32_pin_ops, RT_NULL); return rt_device_pin_register("pin", &hc32_pin_ops, RT_NULL);
} }
INIT_BOARD_EXPORT(rt_hw_pin_init);
#endif #endif

View File

@ -26,6 +26,8 @@ struct hc32_pin_irq_map
struct hc32_irq_config irq_config; struct hc32_irq_config irq_config;
}; };
int rt_hw_pin_init(void);
#endif #endif
#endif /* __DRV_GPIO_H__ */ #endif /* __DRV_GPIO_H__ */

View File

@ -1490,7 +1490,7 @@ static const struct rt_uart_ops hc32_uart_ops =
.dma_transmit = hc32_dma_transmit .dma_transmit = hc32_dma_transmit
}; };
int hc32_hw_uart_init(void) int rt_hw_usart_init(void)
{ {
rt_err_t result = RT_EOK; rt_err_t result = RT_EOK;
rt_size_t obj_num = sizeof(uart_obj) / sizeof(struct hc32_uart); rt_size_t obj_num = sizeof(uart_obj) / sizeof(struct hc32_uart);
@ -1537,8 +1537,6 @@ int hc32_hw_uart_init(void)
return result; return result;
} }
INIT_BOARD_EXPORT(hc32_hw_uart_init);
#endif #endif
#endif /* RT_USING_SERIAL */ #endif /* RT_USING_SERIAL */

View File

@ -90,6 +90,7 @@ struct hc32_uart
/******************************************************************************* /*******************************************************************************
* Global function prototypes (definition in C source) * Global function prototypes (definition in C source)
******************************************************************************/ ******************************************************************************/
int rt_hw_usart_init(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1630,7 +1630,7 @@ static const struct rt_uart_ops hc32_uart_ops =
.transmit = hc32_transmit .transmit = hc32_transmit
}; };
int hc32_hw_uart_init(void) int rt_hw_usart_init(void)
{ {
rt_err_t result = RT_EOK; rt_err_t result = RT_EOK;
rt_size_t obj_num = sizeof(uart_obj) / sizeof(struct hc32_uart); rt_size_t obj_num = sizeof(uart_obj) / sizeof(struct hc32_uart);
@ -1674,8 +1674,6 @@ int hc32_hw_uart_init(void)
return result; return result;
} }
INIT_BOARD_EXPORT(hc32_hw_uart_init);
#endif #endif
#endif /* RT_USING_SERIAL_V2 */ #endif /* RT_USING_SERIAL_V2 */

View File

@ -90,6 +90,7 @@ struct hc32_uart
/******************************************************************************* /*******************************************************************************
* Global function prototypes (definition in C source) * Global function prototypes (definition in C source)
******************************************************************************/ ******************************************************************************/
int rt_hw_usart_init(void);
#ifdef __cplusplus #ifdef __cplusplus
} }