LOCALvoiduart0_rx_intr_handler(void*para)
{
/* uart0 and uart1 intr combine togther, when interrupt occur, see reg 0x3ff20020, bit2, bit0 represents
* uart1 and uart0 respectively
*/ uint8 RcvChar;
uint8 uart_no = UART0;//UartDev.buff_uart_no;
uint8 fifo_len =0;
uint8 buf_idx =0;
//uint8 fifo_tmp[128] = {0};//只是告诉我们这个单片机的内部FIFO是128字节大小
uint32 uart_intr_status = READ_PERI_REG(UART_INT_ST(uart_no)) ;//读取中断状态
while(uart_intr_status !=0x0)
{
if(UART_FRM_ERR_INT_ST == (uart_intr_status & UART_FRM_ERR_INT_ST))// 接收帧错误中断,,,可能是数据位数不对,或者接收到的数据不满8bit...等等
{
WRITE_PERI_REG(UART_INT_CLR(uart_no), UART_FRM_ERR_INT_CLR);// 清除中断寄存器的 帧错误位
}
elseif(UART_RXFIFO_FULL_INT_ST == (uart_intr_status & UART_RXFIFO_FULL_INT_ST))//进入FIFO满中断
{
fifo_len = (READ_PERI_REG(UART_STATUS(UART0)) >> UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT;//读出来内部FIFO缓存的数据个数
while(fifo_len--)
{
if(Usart1ReadCnt
Usart1ReadBuff[Usart1ReadCnt] = READ_PERI_REG(UART_FIFO(UART0)) &0xFF;//取出来一个数据
Usart1ReadCnt++;
}
else
{
Usart1ReadCnt =0;
}
}
WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_FULL_INT_CLR);// 清除满中断
}
elseif(UART_RXFIFO_TOUT_INT_ST == (uart_intr_status & UART_RXFIFO_TOUT_INT_ST))//空闲中断,证明接受到了一条完整的数据
{
fifo_len = (READ_PERI_REG(UART_STATUS(UART0)) >> UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT;//读出来接收的数据个数
while(fifo_len--)
{
if(Usart1ReadCnt
Usart1ReadBuff[Usart1ReadCnt] = READ_PERI_REG(UART_FIFO(UART0)) &0xFF;//取出来一个数据
Usart1ReadCnt++;
}
else
{
Usart1ReadCnt =0;
}
}
Usart1ReadCntCopy = Usart1ReadCnt;//串口1接收到的数据个数拷贝
Usart1ReadCnt =0;
Usart1ReadFlage=1;//串口1接收到一条完整数据
WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_TOUT_INT_CLR);// 清除空闲标志位
}
elseif(UART_TXFIFO_EMPTY_INT_ST == (uart_intr_status & UART_TXFIFO_EMPTY_INT_ST))//发送FIFO里面的数据个数少于20个,进入中断
{
WRITE_PERI_REG(UART_INT_CLR(uart_no), UART_TXFIFO_EMPTY_INT_CLR);// 清除中断标志
CLEAR_PERI_REG_MASK(UART_INT_ENA(UART0), UART_TXFIFO_EMPTY_INT_ENA);//清除中断
}
else
{
//skip
}
uart_intr_status = READ_PERI_REG(UART_INT_ST(uart_no)) ;
}
}
|