RT-Thread is a powerful, component-rich open source operating system that combines features such as the STM32WL low-power combination to accelerate product development and landing by running RTOS in STM32WL.
This article focuses on how to port RT-Thread to the NUCLEO-WL55JC2 board and create a new RT-Thread-based NUCLEO-WL55JC2 BSP.
The main content of this article includes:
RT-Thread officially offers very detailed documents that introduce the "STM32 Series BSP Creation Tutorial"
The structure of the STM32 BSP framework is shown in the following image:
Each STM32 series of BSPs consists of three parts: a universal library, a BSP template, and a specific board BSP.
| STM32WL Series BSP template | stm32/libraries/templates/stm32wlxx | At present, RT-Thread officially does not support STM32WL |
| Specific board BSP | stm32/nucleo-wl55jc2 | Main Chip: STM32WL55JC |
Since RT-Thread does not currently support STM32WL, the creation process for the STM32WL BSP is as follows:
Add STM32WL support at stm32.libraries
Update HAL_Drivers
Add NUCLEO-WL55JC2 BSP
Configurations
Add STM32WLxx_HAL and its associated driver files in bspstm32libraries.
Copy the following 2 files to STM32WLxx_HAL
Add SOC_SERIES_STM32WL to Kconfig in bspstm32librariesHAL_Drivers.
Add STM32WL to drv_config.h in bspstm32librariesHAL_Drivers.
Add the wl folder at bspstm32librariesHAL_Driversconfig (copy the files in STM32L4 directly and then modify them accordingly)
Add stm32wl55-st-nucleo at rt-threadbspstm32 path.(Copy stm32l476-st-nucleo)
Note: You'll need to install STM32WLxx_DFP if you don't have one.
As CubeMX doesn't fully support STM32WL, some files of CubeMX_Config needs configurations.
/**
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(huart->Instance==LPUART1)
{
/* USER CODE BEGIN LPUART1_MspInit 0 */
/* USER CODE END LPUART1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_LPUART1_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/**LPUART1 GPIO Configuration
PA3 ------> LPUART1_RX
PA2 ------> LPUART1_TX
*/
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF8_LPUART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USER CODE BEGIN LPUART1_MspInit 1 */
/* USER CODE END LPUART1_MspInit 1 */
}
}
/**
* @brief UART MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
{
if(huart->Instance==LPUART1)
{
/* USER CODE BEGIN LPUART1_MspDeInit 0 */
/* USER CODE END LPUART1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_LPUART1_CLK_DISABLE();
/**LPUART1 GPIO Configuration
PA0 ------> LPUART1_RX
PA1 ------> LPUART1_TX
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
/* USER CODE BEGIN LPUART1_MspDeInit 1 */
/* USER CODE END LPUART1_MspDeInit 1 */
}
}
Once this is done, the MDK project is generated using the SCons tool
Connect NUCLO-WL55JC to PC via Micro USB, download code to NUCLEO-WL55JC via on-board STLINKV3E, and verify if Finish available through serial ports.
Forwarded from RT-Thread Community Developer ForestRain