00001
00039 #ifndef REGS_XMEGA_USART_H_INCLUDED
00040 #define REGS_XMEGA_USART_H_INCLUDED
00041
00042 #include <io.h>
00043
00056
00057
00058 #define USART_DATA 0x00 //!< TX/RX Data Register
00059 #define USART_STATUS 0x01 //!< Status Register
00060 #define USART_CTRLA 0x03 //!< Control Register A
00061 #define USART_CTRLB 0x04 //!< Control Register B
00062 #define USART_CTRLC 0x05 //!< Control Register C
00063 #define USART_BAUDCTRLA 0x06 //!< Baud Rate Register A
00064 #define USART_BAUDCTRLB 0x07 //!< Baud Rate Register B
00065
00066
00068
00069 #define USART_RXB8_BIT 0 //!< Receive Bit 8
00070 #define USART_PERR_BIT 2 //!< Parity Error
00071 #define USART_BUFOVF_BIT 3 //!< Buffer Overflow
00072 #define USART_FERR_BIT 4 //!< Frame Error
00073 #define USART_DREIF_BIT 5 //!< Data Register Empty
00074 #define USART_TXCIF_BIT 6 //!< Transmit Complete
00075 #define USART_RXCIF_BIT 7 //!< Receive Complete
00076
00077
00079
00080 #define USART_DREINTLVL_START 0 //!< Data Reg Empty Interrupt Level
00081 #define USART_DREINTLVL_SIZE 2 //!< Data Reg Empty Interrupt Level
00082 #define USART_TXCINTLVL_START 2 //!< TX Complete Interrupt Level
00083 #define USART_TXCINTLVL_SIZE 2 //!< TX Complete Interrupt Level
00084 #define USART_RXCINTLVL_START 4 //!< RX Complete Interrupt Level
00085 #define USART_RXCINTLVL_SIZE 2 //!< RX Complete Interrupt Level
00086
00087
00089
00090 #define USART_TXB8_BIT 0 //!< Transmit Bit 8
00091 #define USART_MPCM_BIT 1 //!< Multi-processor Communication Mode
00092 #define USART_CLK2X_BIT 2 //!< Double Transmission Speed
00093 #define USART_TXEN_BIT 3 //!< Transmitter Enable
00094 #define USART_RXEN_BIT 4 //!< Receiver Enable
00095
00096
00098
00099 #define USART_CHSIZE_START 0 //!< Character Size
00100 #define USART_CHSIZE_SIZE 3 //!< Character Size
00101 #define USART_SBMODE_START 3 //!< Stop Bit Mode
00102 #define USART_SBMODE_SIZE 1 //!< Stop Bit Mode
00103 #define USART_PMODE_START 4 //!< Parity Mode
00104 #define USART_PMODE_SIZE 2 //!< Parity Mode
00105 #define USART_CMODE_START 6 //!< Communication Mode
00106 #define USART_CMODE_SIZE 2 //!< Communication Mode
00107
00108
00110
00111 #define USART_BSELB_START 0 //!< Baud Rate bits 8..11
00112 #define USART_BSELB_SIZE 4 //!< Baud Rate bits 8..11
00113 #define USART_BSCALE_START 4 //!< Baud Rate Scale factor
00114 #define USART_BSCALE_SIZE 4 //!< Baud Rate Scale factor
00115
00116
00118
00119
00120 #define USART_BIT(name) \
00121 (1U << USART_##name##_BIT)
00122
00123 #define USART_BF(name, value) \
00124 ((value) << USART_##name##_START)
00125
00126 #define USART_BFEXT(name, regval) \
00127 (((regval) >> USART_##name##_START) \
00128 & ((1U << USART_##name##_SIZE) - 1))
00129
00130 #define USART_BFINS(name, value, regval) \
00131 (((regval) & ~(((1U << USART_##name##_SIZE) - 1) \
00132 << USART_##name##_START)) \
00133 | USART_BF(name, value))
00134
00136
00138
00139
00140 #define usart_read_reg(usart, reg) \
00141 mmio_read8((void *)((uintptr_t)(usart) + USART_##reg))
00142
00143 #define usart_write_reg(usart, reg, value) \
00144 mmio_write8((void *)((uintptr_t)(usart) + USART_##reg), value)
00145
00146
00148
00149 #endif