只是单纯的发个数据
初始化为: gd_eval_com_init(USART_NUM);
循环里发数据:usart_data_transmit(USART_NUM, 0x55);
宏定义:#define USART_NUM USART5
初始化函数为:
void gd_eval_com_init(uint32_t com)
{
rcu_periph_clock_enable(RCU_GPIOG);
/* enable USART clock */
rcu_periph_clock_enable(RCU_USART5);
/* connect port to USARTx_Tx */
gpio_af_set(GPIO_NUM, GPIO_AF_7, USART_TX);
/* connect port to USARTx_Rx */
gpio_af_set(GPIO_NUM, GPIO_AF_7, USART_RX);
/* configure USART Tx as alternate function push-pull */
gpio_mode_set(GPIO_NUM, GPIO_MODE_AF, GPIO_PUPD_PULLUP,USART_TX);
gpio_output_options_set(GPIO_NUM, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ,USART_TX);
/* configure USART Rx as alternate function push-pull */
gpio_mode_set(GPIO_NUM, GPIO_MODE_AF, GPIO_PUPD_PULLUP,USART_RX);
gpio_output_options_set(GPIO_NUM, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ,USART_RX);
/* USART configure */
usart_deinit(com);
usart_baudrate_set(com,9600U);
usart_receive_config(com, USART_RECEIVE_ENABLE);
usart_transmit_config(com, USART_TRANSMIT_ENABLE);
usart_enable(com);
}
函数里的参数的宏定义为:
#define USART_TX GPIO_PIN_14
#define USART_RX GPIO_PIN_9
#define GPIO_NUM GPIOG |