avr-classes
|
#include <bufferedusart.h>
Public Member Functions | |
BufferedUsart (Usart *usart) | |
void | enable (bool state) |
bool | read (uint8_t *byte) |
bool | write (uint8_t byte) |
virtual void | onDataRegisterEmpty (void) override |
virtual void | onRxComplete (void) override |
![]() | |
SimpleUsart (Usart *usart) | |
void | enable (bool state) |
uint8_t | read (void) |
void | write (uint8_t byte) |
Additional Inherited Members | |
![]() | |
Usart *const | m_usart |
This template class implements an USART with separate buffers for incoming and outgoing data. The class makes use of the USART's RX Complete and Data Register Empty interrupts.
RXQUEUESIZE | Size of the queue for incoming data in bytes |
TXQUEUESIZE | Size of the queue for outgoing data in bytes |
|
inline |
Constructor.
usart | Pointer to USART device to be used. |
|
inline |
Enables or disables the USART on hardware level. This also enables or disables the RX Complete Interrupt.
state | Desired state of USART, true means enabled, false means disabled. |
|
inlineoverridevirtual |
Handler for Data Register Empty interrupt. Used to put next data byte from outgoing data buffer into data register. When no data is left the Data Register Empty interrupt is disabled.
Reimplemented from Usart::InterruptHandler.
Reimplemented in NotifyingBufferedUsart< RXQUEUESIZE, TXQUEUESIZE >.
|
inlineoverridevirtual |
Handler for RX Complete interrupt. Called in ISR context. Used to get data byte from data register and to store byte in incoming data buffer. If buffer is full the date byte is discarded.
Reimplemented from Usart::InterruptHandler.
Reimplemented in NotifyingBufferedUsart< RXQUEUESIZE, TXQUEUESIZE >.
|
inline |
Gets a byte from the incoming data buffer, if available.
byte | Pointer to buffer that receives the data byte. |
|
inline |
Puts a byte in the outgoing data buffer, if possible. This also enables the Data Register Empty interrupt to continue with emptying the buffer.
byte | Data byte to send. |