void UART3_Init()
{
/* enable GPIO clock */
rcu_periph_clock_enable(RCU_GPIOC);
/* enable USART clock */
rcu_periph_clock_enable(RCU_UART3);
/* configure the USART0 TX pin and USART0 RX pin */
gpio_af_set(GPIOC, GPIO_AF_8, GPIO_PIN_11);
gpio_af_set(GPIOC, GPIO_AF_8, GPIO_PIN_10);
/* configure UART4 TX as alternate function push-pull */
gpio_mode_set(GPIOC, GPIO_MODE_AF, GPIO_PUPD_PULLUP, GPIO_PIN_10);
gpio_output_options_set(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_10);
/* configure USART0 RXs alternate fion push-pull */
gpio_mode_set(GPIOC, GPIO_MODE_AF, GPIO_PUPD_PULLDOWN, GPIO_PIN_11);
//gpio_output_options_set(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_11);
/* USART configure */
usart_deinit(UART3);
usart_baudrate_set(UART3, 115200U);
usart_receive_config(UART3, USART_RECEIVE_ENABLE);
usart_transmit_config(UART3, USART_TRANSMIT_ENABLE);
usart_enable(UART3);
nvic_irq_enable(UART3_IRQn,0,1);
/* enable USART TBE interrupt */
usart_interrupt_enable(UART3_IRQn, USART_INT_TBE);
usart_interrupt_enable(UART3_IRQn, USART_INT_RBNE);
usart_interrupt_enable(UART3_IRQn, USART_INT_IDLE);
}
void UART3_IRQHandler(void)
{
if((RESET != usart_interrupt_flag_get(UART3, USART_INT_FLAG_RBNE)) &&
(RESET != usart_flag_get(UART3, USART_FLAG_RBNE))) {
/* receive data */
USART_Receive_Data[0] = usart_data_receive(UART3);
}
if((RESET != usart_interrupt_flag_get(UART3, USART_INT_FLAG_IDLE)) &&
(RESET != usart_flag_get(UART3, USART_FLAG_IDLE))) {
/* receive data */
usart_interrupt_flag_clear(UART3,USART_INT_FLAG_IDLE);
}
}
这样配置无法进入中断,是什么原因? |