59 #ifndef USART_DRIVER_H 60 #define USART_DRIVER_H 67 #define USART_RX_BUFFER_SIZE 4 69 #define USART_TX_BUFFER_SIZE 4 71 #define USART_RX_BUFFER_MASK ( USART_RX_BUFFER_SIZE - 1 ) 73 #define USART_TX_BUFFER_MASK ( USART_TX_BUFFER_SIZE - 1 ) 76 #if ( USART_RX_BUFFER_SIZE & USART_RX_BUFFER_MASK ) 77 #error RX buffer size is not a power of 2 79 #if ( USART_TX_BUFFER_SIZE & USART_TX_BUFFER_MASK ) 80 #error TX buffer size is not a power of 2 129 #define USART_Format_Set(_usart, _charSize, _parityMode, _twoStopBits) \ 130 (_usart)->CTRLC = (uint8_t) _charSize | _parityMode | \ 131 (_twoStopBits ? USART_SBMODE_bm : 0) 156 #define USART_Baudrate_Set(_usart, _bselValue, _bScaleFactor) \ 157 (_usart)->BAUDCTRLA =(uint8_t)_bselValue; \ 158 (_usart)->BAUDCTRLB =(_bScaleFactor << USART_BSCALE0_bp)|(_bselValue >> 8) 165 #define USART_Rx_Enable(_usart) ((_usart)->CTRLB |= USART_RXEN_bm) 172 #define USART_Rx_Disable(_usart) ((_usart)->CTRLB &= ~USART_RXEN_bm) 179 #define USART_Tx_Enable(_usart) ((_usart)->CTRLB |= USART_TXEN_bm) 186 #define USART_Tx_Disable(_usart) ((_usart)->CTRLB &= ~USART_TXEN_bm) 197 #define USART_RxdInterruptLevel_Set(_usart, _rxdIntLevel) \ 198 ((_usart)->CTRLA = ((_usart)->CTRLA & ~USART_RXCINTLVL_gm) | _rxdIntLevel) 209 #define USART_TxdInterruptLevel_Set(_usart, _txdIntLevel) \ 210 (_usart)->CTRLA = ((_usart)->CTRLA & ~USART_TXCINTLVL_gm) | _txdIntLevel 222 #define USART_DreInterruptLevel_Set(_usart, _dreIntLevel) \ 223 (_usart)->CTRLA = ((_usart)->CTRLA & ~USART_DREINTLVL_gm) | _dreIntLevel 239 #define USART_SetMode(_usart, _usartMode) \ 240 ((_usart)->CTRLC = ((_usart)->CTRLC & (~USART_CMODE_gm)) | _usartMode) 248 #define USART_IsTXDataRegisterEmpty(_usart) (((_usart)->STATUS & USART_DREIF_bm) != 0) 260 #define USART_PutChar(_usart, _data) ((_usart)->DATA = _data) 270 #define USART_IsRXComplete(_usart) (((_usart)->STATUS & USART_RXCIF_bm) != 0) 284 #define USART_GetChar(_usart) ((_usart)->DATA) 290 USART_DREINTLVL_t dreIntLevel );
293 USART_DREINTLVL_t dreIntLevel);
bool USART_TXBuffer_FreeSpace(USART_data_t *usart_data)
Test if there is data in the transmitter software buffer.
bool USART_RXComplete(USART_data_t *usart_data)
RX Complete Interrupt Service Routine.
Struct used when interrupt driven driver is used.
uint8_t USART_RXBuffer_GetByte(USART_data_t *usart_data)
Get received data (5-8 bit character).
bool USART_TXBuffer_PutByte(USART_data_t *usart_data, uint8_t data)
Put data (5-8 bit character).
This file implements some macros that makes the IAR C-compiler and avr-gcc work with the same code ba...
volatile uint8_t RX[USART_RX_BUFFER_SIZE]
bool USART_RXBufferData_Available(USART_data_t *usart_data)
Test if there is data in the receive software buffer.
void USART_InterruptDriver_Initialize(USART_data_t *usart_data, USART_t *usart, USART_DREINTLVL_t dreIntLevel)
Initializes buffer and selects what USART module to use.
struct USART_Buffer USART_Buffer_t
void USART_NineBits_PutChar(USART_t *usart, uint16_t data)
Put data (9 bit character).
void USART_InterruptDriver_DreInterruptLevel_Set(USART_data_t *usart_data, USART_DREINTLVL_t dreIntLevel)
Set USART DRE interrupt level.
#define USART_RX_BUFFER_SIZE
struct Usart_and_buffer USART_data_t
Struct used when interrupt driven driver is used.
uint16_t USART_NineBits_GetChar(USART_t *usart)
Get received data (9 bit character).
volatile uint8_t TX[USART_TX_BUFFER_SIZE]
#define USART_TX_BUFFER_SIZE
void USART_DataRegEmpty(USART_data_t *usart_data)
Data Register Empty Interrupt Service Routine.
USART_DREINTLVL_t dreIntLevel