void?USARTx_Init(USART_TypeDef?*USARTx,?uint32_t?baudrate) { ????USART_InitTypeDef?USART_InitStructure?=?{0}; ????USART_InitStructure.USART_BaudRate?=?baudrate; ????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_Tx?|?USART_Mode_Rx; ????USART_Init(USARTx,?&USART_InitStructure); ????USART_ITConfig(USARTx,?USART_IT_IDLE,?ENABLE); ????USART_ClearFlag(USARTx,?USART_IT_IDLE); ????USART_Cmd(USARTx,?ENABLE); } void?USART2_IRQHandler(void) { ????if(USART_GetITStatus(USART2,?USART_IT_IDLE)?!=?RESET) ????{ ????????com2_info.rx_flag?=?1; ????????com2_info.rx_len?=?com2_info.rx_max?-?DMA_GetCurrDataCounter(DMA1_Channel6); ????????DMA_Cmd(DMA1_Channel6,?DISABLE);\ ????????USART_ClearFlag(USART2,?USART_IT_IDLE); ????} }
使能了空閑中斷,可是不進(jìn)串口中斷
熱門(mén)產(chǎn)品 :
CH32V317: 互聯(lián)型青稞RISC-V MCU