Byggern
UART Class Reference

An interface for communicating through UART. More...

#include <uart.h>

Inheritance diagram for UART:
Stream

Public Member Functions

void Write (uint8_t *string, uint16_t size)
 
void Init (uint16_t baud_rate)
 
 UART (const UART &)=delete
 
void operator= (const UART &)=delete
 
- Public Member Functions inherited from Stream
 Stream (uint16_t input_stream_size, uint16_t output_stream_size)
 
virtual uint16_t Read (uint8_t *string, uint16_t size)
 
virtual bool ReadByte (uint8_t &byte)
 
virtual void WriteByte (uint8_t byte)
 
virtual uint8_t GetAvailableWriteBytes ()
 
virtual uint8_t GetAvailableReadBytes ()
 
virtual bool CheckInputOverflowFlag ()
 
virtual bool CheckOutputOverflowFlag ()
 
virtual uint16_t GetInputBufferLength ()
 
virtual uint16_t GetOutputBufferLength ()
 
virtual void FlushInputBuffer ()
 
virtual void FlushOutputBuffer ()
 

Static Public Member Functions

static UARTGetInstance ()
 

Private Member Functions

 UART ()
 
void StartTransmission ()
 

Private Attributes

bool ongoing_transmission = false
 

Friends

void USART0_UDRE_vect ()
 

Additional Inherited Members

- Protected Member Functions inherited from Stream
virtual uint16_t ReadFromBuffer (uint8_t *buffer, uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty, uint8_t *string, uint16_t &string_size)
 
virtual void WriteToBuffer (uint8_t *buffer, uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty, bool &overflow_flag, uint8_t *string, uint16_t &string_size, void(*cb)(Stream *stream))
 
virtual bool ReadByteFromBuffer (uint8_t &byte, uint8_t *buffer, uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty)
 
virtual void WriteByteToBuffer (uint8_t *buffer, uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty, bool &overflow_flag, uint8_t &byte, void(*cb)(Stream *stream))
 
virtual void WriteByteToInputStream (uint8_t &byte)
 
virtual bool ReadByteFromOutputStream (uint8_t &byte)
 
virtual void WriteToInputStream (uint8_t *string, uint16_t size)
 
virtual uint16_t ReadFromOutputStream (uint8_t *string, uint16_t size)
 
virtual uint16_t CalculateLength (uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty)
 
virtual void FlushStream (uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty)
 
- Protected Attributes inherited from Stream
uint8_t * input_buffer
 
uint8_t * output_buffer
 
uint16_t input_buffer_start_index = 0
 
uint16_t output_buffer_start_index = 0
 
uint16_t input_buffer_stop_index
 
uint16_t output_buffer_stop_index
 
uint16_t input_buffer_size
 
uint16_t output_buffer_size
 
void(* event_input_buffer_not_empty )(Stream *stream) = nullptr
 
void(* event_output_buffer_not_empty )(Stream *stream) = nullptr
 
bool input_buffer_empty = true
 
bool output_buffer_empty = true
 
bool input_buffer_overflowed = false
 
bool output_buffer_overflowed = false
 

Detailed Description

An interface for communicating through UART.

Constructor & Destructor Documentation

§ UART() [1/2]

UART::UART ( )
private

A constructor that initializes the UART to a certain size

§ UART() [2/2]

UART::UART ( const UART )
delete

Beacause of singleton - makes sure its not copied etc.

Member Function Documentation

§ GetInstance()

static UART& UART::GetInstance ( )
inlinestatic

A Singleton implementation of this class

§ Init()

void UART::Init ( uint16_t  baud_rate)

Initializer because of the singleton implementation.

Parameters
baud_rateThe baud rate of the uart

§ operator=()

void UART::operator= ( const UART )
delete

Beacause of singleton - makes sure its not copied etc.

§ StartTransmission()

void UART::StartTransmission ( )
inlineprivate

Starts the transmission. Just a void-void function to modulize

§ Write()

void UART::Write ( uint8_t *  string,
uint16_t  size 
)
virtual

Write the inserted string to output (i.e. write to computer)

Parameters
stringThe "data string" that shall be written to the output
sizethe size of the data string

Reimplemented from Stream.

Friends And Related Function Documentation

§ USART0_UDRE_vect

void USART0_UDRE_vect ( )
friend

The interrupt handler vector. To be run on each DRE interrupt

Member Data Documentation

§ ongoing_transmission

bool UART::ongoing_transmission = false
private

A bool to indicate whether or not a transmission is going on


The documentation for this class was generated from the following files: