最后来写一段 串口0发送数据的驱动代码
void USART_Config()
{
rcu_periph_clock_enable(RCU_GPIOA);
rcu_periph_clock_enable(RCU_USART0);
// USART Tx
gpio_init(GPIOA,GPIO_MODE_OUT_PP,GPIO_OSPEED_50MHZ,GPIO_PIN_9);
// USART Rx
gpio_init(GPIOA,GPIO_MODE_IN_FLOATING,GPIO_OSPEED_50MHZ,GPIO_PIN_10);
// USART
usart_deinit(USART0);
usart_baudrate_set(USART0,115200U);
usart_parity_config(USART0,USART_PM_NONE);
usart_word_length_set(USART0,USART_WL_8BIT);
usart_stop_bit_set(USART0,USART_STB_1BIT);
usart_hardware_flow_rts_config(USART0,USART_RTS_DISABLE);
usart_hardware_flow_cts_config(USART0,USART_CTS_DISABLE);
usart_transmit_config(USART0,USART_TRANSMIT_ENABLE);
usart_receive_config(USART0,USART_RECEIVE_ENABLE);
usart_enable(USART0);
}
|