“CH579SFR.h”库文件,关于串口中断部分
/* UART interrupt identification values for IIR bits 3:0 */
#define UART_II_SLV_ADDR 0x0E // RO, UART0 slave address match
#define UART_II_LINE_STAT 0x06 // Re staO, UART interrupt by receiver lintus
#define UART_II_RECV_RDY 0x04 // RO, UART interrupt by receiver data available
#define UART_II_RECV_TOUT 0x0C // RO, UART interrupt by receiver fifo timeout
#define UART_II_THR_EMPTY 0x02 // RO, UART interrupt by THR empty
#define UART_II_MODEM_CHG 0x00 // RO, UART0 interrupt by modem status change
#define UART_II_NO_INTER 0x01 // RO, no UART interrupt is pending
名称 | 说明 | 解释 |
---|---|---|
UART_II_SLV_ADDR 0x0E | RO, UART0 slave address match | 只读,串口0从机地址匹配 |
UART_II_LINE_STAT 0x06 | Re staO, UART interrupt by receiver lintus | 只读,串口 |
UART_II_RECV_RDY 0x04 | RO, UART interrupt by receiver data available | 只读, |
UART_II_RECV_TOUT 0x0C | RO, UART interrupt by receiver fifo timeout | 只读, |
UART_II_THR_EMPTY 0x02 | RO, UART interrupt by THR empty | 只读, |
UART_II_MODEM_CHG 0x00 | RO, UART0 interrupt by modem status change | 只读, |
UART_II_NO_INTER 0x01 | RO, no UART interrupt is pending | 只读, |
接收长字符串
CH57x_uart.h中修改提供代码如下
红圈部分根据芯片说明书修改为如下
typedef enum
{UART_1BYTE_TRIG = 0, // 1×Ö½Ú´¥·¢UART_2BYTE_TRIG = 1, // 2×Ö½Ú´¥·¢UART_4BYTE_TRIG = 2, // 4×Ö½Ú´¥·¢UART_7BYTE_TRIG = 3, // 7×Ö½Ú´¥·¢}UARTByteTRIGTypeDef;
初始化UART1
文件CH57x_uart.c中修改为1字节触发。