SCI 寄存器定义详解 - 详细位定义及功能解释
struct SCICCR_BITS {
// bit description
Uint16 SCICHAR:3; // 2:0 Character length control
Uint16 ADDRIDLE_MODE:1; // 3 ADDR/IDLE Mode control
Uint16 LOOPBKENA:1; // 4 Loop Back enable
Uint16 PARITYENA:1; // 5 Parity enable
Uint16 PARITY:1; // 6 Even or Odd Parity
Uint16 STOPBITS:1; // 7 Number of Stop Bits
Uint16 rsvd1:8; // 15:8 reserved
};
union SCICCR_REG {
Uint16 all;
struct SCICCR_BITS bit;
};
//-------------------------------------------
// SCICTL1 control register 1 bit definitions:
//
struct SCICTL1_BITS {
// bit description
Uint16 RXENA:1; // 0 SCI receiver enable
Uint16 TXENA:1; // 1 SCI transmitter enable
Uint16 SLEEP:1; // 2 SCI sleep
Uint16 TXWAKE:1; // 3 Transmitter wakeup method
Uint16 rsvd:1; // 4 reserved
Uint16 SWRESET:1; // 5 Software reset
Uint16 RXERRINTENA:1; // 6 Recieve interrupt enable
Uint16 rsvd1:9; // 15:7 reserved
};
union SCICTL1_REG {
Uint16 all;
struct SCICTL1_BITS bit;
};
//---------------------------------------------
// SCICTL2 control register 2 bit definitions:
//
struct SCICTL2_BITS {
// bit description
Uint16 TXINTENA:1; // 0 Transmit interrupt enable
Uint16 RXBKINTENA:1; // 1 Receiver-buffer break enable
Uint16 rsvd:4; // 5:2 reserved
Uint16 TXEMPTY:1; // 6 Transmitter empty flag
Uint16 TXRDY:1; // 7 Transmitter ready flag
Uint16 rsvd1:8; // 15:8 reserved
};
union SCICTL2_REG {
Uint16 all;
struct SCICTL2_BITS bit;
};
//---------------------------------------------------
// SCIRXST Receiver status register bit definitions:
//
struct SCIRXST_BITS {
// bit description
Uint16 rsvd:1; // 0 reserved
Uint16 RXWAKE:1; // 1 Receiver wakeup detect flag
Uint16 PE:1; // 2 Parity error flag
Uint16 OE:1; // 3 Overrun error flag
Uint16 FE:1; // 4 Framing error flag
Uint16 BRKDT:1; // 5 Break-detect flag
Uint16 RXRDY:1; // 6 Receiver ready flag
Uint16 RXERROR:1; // 7 Receiver error flag
Uint16 rsvd1:8; // 15-8 reserved
};
union SCIRXST_REG {
Uint16 all;
struct SCIRXST_BITS bit;
};
//----------------------------------------------------
// SCIRXBUF Receiver Data Buffer with FIFO bit definitions:
//
struct SCIRXBUF_BITS {
// bits description
Uint16 RXDT:8; // 7:0 Receive word
Uint16 rsvd:6; // 13:8 reserved
Uint16 SCIFFPE:1; // 14 SCI PE error in FIFO mode
Uint16 SCIFFFE:1; // 15 SCI FE error in FIFO mode
};
union SCIRXBUF_REG {
Uint16 all;
struct SCIRXBUF_BITS bit;
};
//--------------------------------------------------
// SCIPRI Priority control register bit definitions:
//
//
struct SCIPRI_BITS {
// bit description
Uint16 rsvd:3; // 2:0 reserved
Uint16 FREE:1; // 3 Free emulation suspend mode
Uint16 SOFT:1; // 4 Soft emulation suspend mode
Uint16 rsvd1:11; // 15:5 reserved
};
union SCIPRI_REG {
Uint16 all;
struct SCIPRI_BITS bit;
};
//-------------------------------------------------
// SCI FIFO Transmit register bit definitions:
//
//
struct SCIFFTX_BITS {
// bit description
Uint16 TXFFIL:5; // 4:0 Interrupt level
Uint16 TXFFIENA:1; // 5 Interrupt enable
Uint16 TXFFINTCLR:1; // 6 Clear INT flag
Uint16 TXFFINT:1; // 7 INT flag
Uint16 TXFFST:5; // 12:8 FIFO status
Uint16 TXFIFOXRESET:1; // 13 FIFO reset
Uint16 SCIFFENA:1; // 14 Enhancement enable
Uint16 SCIRST:1; // 15 SCI reset rx/tx channels
};
union SCIFFTX_REG {
Uint16 all;
struct SCIFFTX_BITS bit;
};
//------------------------------------------------
// SCI FIFO recieve register bit definitions:
//
//
struct SCIFFRX_BITS {
// bits description
Uint16 RXFFIL:5; // 4:0 Interrupt level
Uint16 RXFFIENA:1; // 5 Interrupt enable
Uint16 RXFFINTCLR:1; // 6 Clear INT flag
Uint16 RXFFINT:1; // 7 INT flag
Uint16 RXFFST:5; // 12:8 FIFO status
Uint16 RXFIFORESET:1; // 13 FIFO reset
Uint16 RXFFOVRCLR:1; // 14 Clear overflow
Uint16 RXFFOVF:1; // 15 FIFO overflow
};
union SCIFFRX_REG {
Uint16 all;
struct SCIFFRX_BITS bit;
};
// SCI FIFO control register bit definitions:
struct SCIFFCT_BITS {
// bits description
Uint16 FFTXDLY:8; // 7:0 FIFO transmit delay
Uint16 rsvd:5; // 12:8 reserved
Uint16 CDC:1; // 13 Auto baud mode enable
Uint16 ABDCLR:1; // 14 Auto baud clear
Uint16 ABD:1; // 15 Auto baud detect
};
union SCIFFCT_REG {
Uint16 all;
struct SCIFFCT_BITS bit;
};
//---------------------------------------------------------------------------
// SCI Register File:
//
struct SCI_REGS {
union SCICCR_REG SCICCR; // Communications control register
union SCICTL1_REG SCICTL1; // Control register 1
Uint16 SCIHBAUD; // Baud rate (high) register
Uint16 SCILBAUD; // Baud rate (low) register
union SCICTL2_REG SCICTL2; // Control register 2
union SCIRXST_REG SCIRXST; // Recieve status register
Uint16 SCIRXEMU; // Recieve emulation buffer register
union SCIRXBUF_REG SCIRXBUF; // Recieve data buffer
Uint16 rsvd1; // reserved
Uint16 SCITXBUF; // Transmit data buffer
union SCIFFTX_REG SCIFFTX; // FIFO transmit register
union SCIFFRX_REG SCIFFRX; // FIFO recieve register
union SCIFFCT_REG SCIFFCT; // FIFO control register
Uint16 rsvd2; // reserved
Uint16 rsvd3; // reserved
union SCIPRI_REG SCIPRI; // FIFO Priority control
};
解释:
该代码定义了一个SCI寄存器文件,包含了SCI的各个寄存器及其位定义。具体解释如下:
-
SCICCR_BITS: 定义了SCI通信控制寄存器(SCICCR)的位定义,包括字符长度控制、地址/空闲模式控制、回环使能、奇偶校验使能、奇偶校验类型、停止位数量等。
-
SCICCR_REG: 定义了一个16位的联合体,包含了SCICCR_BITS定义的位字段和一个整体的寄存器值。
-
SCICTL1_BITS: 定义了SCI控制寄存器1(SCICTL1)的位定义,包括接收器使能、发送器使能、睡眠模式、发送器唤醒方法、软件复位、接收中断使能等。
-
SCICTL1_REG: 定义了一个16位的联合体,包含了SCICTL1_BITS定义的位字段和一个整体的寄存器值。
-
SCICTL2_BITS: 定义了SCI控制寄存器2(SCICTL2)的位定义,包括发送中断使能、接收器缓冲区中断使能、发送器空闲标志、发送器就绪标志等。
-
SCICTL2_REG: 定义了一个16位的联合体,包含了SCICTL2_BITS定义的位字段和一个整体的寄存器值。
-
SCIRXST_BITS: 定义了SCI接收状态寄存器(SCIRXST)的位定义,包括接收器唤醒检测标志、奇偶校验错误标志、溢出错误标志、帧错误标志、中断标志等。
-
SCIRXST_REG: 定义了一个16位的联合体,包含了SCIRXST_BITS定义的位字段和一个整体的寄存器值。
-
SCIRXBUF_BITS: 定义了SCI接收数据缓冲区(SCIRXBUF)的位定义,包括接收字、PE错误标志、FE错误标志等。
-
SCIRXBUF_REG: 定义了一个16位的联合体,包含了SCIRXBUF_BITS定义的位字段和一个整体的寄存器值。
-
SCIPRI_BITS: 定义了SCI优先级控制寄存器(SCIPRI)的位定义,包括软件暂停模式和自由暂停模式等。
-
SCIPRI_REG: 定义了一个16位的联合体,包含了SCIPRI_BITS定义的位字段和一个整体的寄存器值。
-
SCIFFTX_BITS: 定义了SCI发送FIFO寄存器(SCIFFTX)的位定义,包括中断级别、中断使能、中断标志、FIFO状态等。
-
SCIFFTX_REG: 定义了一个16位的联合体,包含了SCIFFTX_BITS定义的位字段和一个整体的寄存器值。
-
SCIFFRX_BITS: 定义了SCI接收FIFO寄存器(SCIFFRX)的位定义,包括中断级别、中断使能、中断标志、FIFO状态、溢出标志等。
-
SCIFFRX_REG: 定义了一个16位的联合体,包含了SCIFFRX_BITS定义的位字段和一个整体的寄存器值。
-
SCIFFCT_BITS: 定义了SCI FIFO控制寄存器(SCIFFCT)的位定义,包括FIFO发送延迟、自动波特率检测模式等。
-
SCIFFCT_REG: 定义了一个16位的联合体,包含了SCIFFCT_BITS定义的位字段和一个整体的寄存器值。
-
SCI_REGS: 定义了一个SCI寄存器文件,包含了上述各个寄存器及其位定义。其中,SCIHBAUD和SCILBAUD为波特率寄存器,SCIRXEMU为接收仿真缓冲区寄存器,SCITXBUF为发送数据缓冲区寄存器。其他都是控制寄存器和状态寄存器。
原文地址: https://www.cveoy.top/t/topic/oLbW 著作权归作者所有。请勿转载和采集!