Keywords: OSDK STM32 platform, UART port
On the OSDK STM32 platform, the default UART port connected to the drone is USART3. how to change this UART port?
Just change the callback registered in the OSDK to the UART port used.
static T_OsdkHalUartHandler halUartHandler;
halUartHandler.UartInit = OsdkSTM32_UartInit;
halUartHandler.UartWriteData = OsdkSTM32_UartSendData;
halUartHandler.UartReadData = OsdkSTM32_UartReadData;
halUartHandler.UartClose = OsdkSTM32_UartClose;
Or directly modify the code in the UART port initialization.
void
USART3_Config(void)
{
UartDataRecvQueue = xQueueCreate(USART_3_BUFFER_SIZE, sizeof(uint8_t));
USART3_Gpio_Config();
USART_InitTypeDef USART_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
USART_InitStructure.USART_BaudRate = 921600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl =
USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART3, &USART_InitStructure);
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
USART_Cmd(USART3, ENABLE);
while (USART_GetFlagStatus(USART3, USART_FLAG_TXE) != SET)
;
}
Note: This article is from Chinese and is translated by machine. If there is any suggestions, please point it out and we will correct it in time
Comments
0 comments
Please sign in to leave a comment.