将AVR 上的队列串口驱动程序修改后,运行在STM32 开发板,采用中断方式接收和中断发送,并加入了缓冲收发队列操作。由于该驱动是用来操作西门子的TC35 或 MC55 等通信模块,所以加入了“等待串口接收完成”函数,该函数需要一个 10ms 的定时进行计数累加。 #define SMS_UART0_c /* ************************************************************************************************************* * * STM32 UART1 driver * * File : UART0.c * By : hjjft ************************************************************************************************************* */ ///////////////////////////////////////////////// // 这里将串口1 写作0,主要原因是 AVR 是串口0,为了方便移植,这里仍然称为串口0 // ///////////////////////////////////////////////// static char UART0_RxBuf[UART0_RX_BUFFER_SIZE]; static volatile unsigned char UART0_RxHead;// static volatile unsigned char UART0_RxTail; static char UART0_TxBuf[UART0_TX_BUFFER_SIZE];// static volatile unsigned char UART0_TxHead; static volatile unsigned char UART0_TxTail; //------------------------------------------------------------ static volatile unsigned char Frame_counting; /******************************************************************************* * Function Name : NVIC_Configuration * Description : Configures Vector Table base location. * Input : None * Output : None * Return : None *******************************************************************************/ void NVIC_USART_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; /* Enable the USART1 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel; // NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 10; // NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } void GPIO_USART_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Configure USART1 Tx (...