最近在做一个关于串口irDA的红外通信模块,GD32F450做串口初始化的时候 我使能了串口收发以及红外功能,但是数据能发不能接收是怎么一回事呢?不知道有没有大佬用过GD 的irDA??串口初始化代码如下:
void gd_eval_com_init(uint32_t com)
{
/* enable GPIO clock */
uint32_t COM_ID;
if(EVAL_COM1 == com)
{
COM_ID = 0U;
}
rcu_periph_clock_enable( EVAL_COM_GPIO_CLK);
/* enable USART clock */
rcu_periph_clock_enable(COM_CLK[COM_ID]);
/* connect port to USARTx_Tx */
gpio_af_set(EVAL_COM_GPIO_PORT, EVAL_COM_AF, COM_TX_PIN[COM_ID]);
/* connect port to USARTx_Rx */
gpio_af_set(EVAL_COM_GPIO_PORT, EVAL_COM_AF, COM_RX_PIN[COM_ID]);
/* configure USART Tx as alternate function push-pull */
gpio_mode_set(EVAL_COM_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_PULLUP,COM_TX_PIN[COM_ID]);
gpio_output_options_set(EVAL_COM_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ,COM_TX_PIN[COM_ID]);
/* configure USART Rx as alternate function push-pull */
gpio_mode_set(EVAL_COM_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_PULLUP,COM_RX_PIN[COM_ID]);
gpio_output_options_set(EVAL_COM_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ,COM_RX_PIN[COM_ID]);
/* USART configure */
usart_deinit(com);
usart_baudrate_set(com,115200U);
usart_stop_bit_set(com, USART_STB_1BIT);
usart_receive_config(com, USART_RECEIVE_ENABLE);
usart_transmit_config(com, USART_TRANSMIT_ENABLE);
// usart_irda_lowpower_config(com, USART_IRLP_NORMAL);
usart_irda_mode_enable(com);
usart_enable(com);
/* USART interrupt configuration */
nvic_irq_enable(UART3_IRQn, 1, 1);
/* enable USART0 receive interrupt */
usart_interrupt_enable(UART3, USART_INTEN_RBNEIE);
// /* enable USART0 transmit interrupt */
// usart_interrupt_enable(USART0, USART_INTEN_TBEIE);
}
|