关键词:OSDK STM32平台、串口通信端口
OSDK STM32平台,默认与无人机连接的串口都是USART3,如果想修改连接无人机的串口号,需要在什么地方进行修改?
将对应OSDK中注册的回调改成使用的串口即可。
static T_OsdkHalUartHandler halUartHandler;
halUartHandler.UartInit = OsdkSTM32_UartInit;
halUartHandler.UartWriteData = OsdkSTM32_UartSendData;
halUartHandler.UartReadData = OsdkSTM32_UartReadData;
halUartHandler.UartClose = OsdkSTM32_UartClose;
或者直接在串口初始化的部分修改对应关系。
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)
;
}
评论
0 条评论
请登录写评论。