@2019-01-30
【小記】
> rt-thread 工程啟動之后先是進入函數 rtthread_startup 做一些系統運行前的基礎工作,主要有:
* 板級硬件初始化
* 系統定時器初始化
* 系統調度器初始化
* 創建初始化線程 (組件初始化)
* 定時器線程初始化
* 空閑線程初始化
* 系統調度器工作
> 串口設備的配置發生在板級硬件初始化中
串口設備配置函數中遍歷要使用的串口設備,做一些工作參數配置和設備接口實現並注冊設備 (但在此不初始化設備或不使能設備)
具體配置過程:
1. 注冊串口設備,以便 find
rt_hw_board_init() ---> rt_hw_usart_init() ---> rt_hw_serial_register() ---> rt_device_register()
2. 開啟串口時鍾及外設管腳,配置串口工作參數
> 作為輸出終端
rt_components_board_init() ---> rt_console_set_device() ---> rt_device_open() ---> device_init() ---> serial->ops->configure() ---> stm32_configure() ---> HAL_UART_Init() ---> HAL_UART_MspInit() , UART_setConfig()
> 作為驅動 ESP8266
rt_components_init() ---> at_socket_device_init() ---> at_client_init() ---> rt_device_open() ---> device_init() ---> serial->ops->configure() ---> stm32_configure() ---> HAL_UART_Init() ---> HAL_UART_MspInit() , UART_setConfig()