semf
|
Class for using UART hardware. More...
#include <uarthardware.h>
Public Types | |
enum class | ErrorCode : uint8_t { Write_IsBusy = 0 , Write_DataIsNullptr , Write_DataSizeIsZero , Read_IsBusy , Read_BufferIsNullptr , Read_BufferSizeIsZero } |
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring). More... | |
Public Types inherited from semf::Uart | |
enum class | FlowControl : uint8_t { NoFlowControl = 0x00 , RtsFlowControl = 0x01 , CtsFlowControl = 0x10 , RtsAndCtsFlowControl = 0x11 } |
enum class | Parity : uint8_t { NoParity , OddParity , EvenParity } |
enum class | StopBits : uint8_t { Stopbits_0_5 , Stopbits_1 , Stopbits_1_5 , Stopbits_2 } |
enum class | WireMode : uint8_t { ReadWire , WriteWire , ReadAndWriteWires } |
Public Types inherited from semf::CommunicationHardware | |
enum class | Type { SynchronousMaster = 1 , SynchronousSlave , Asynchronous } |
enum class | Frame : uint8_t { First = 0x01 , Next = 0x08 , Last = 0x10 , FirstAndLast = 0x11 } |
Public Member Functions | |
virtual | ~UartHardware ()=default |
void | write (const uint8_t data[], size_t dataSize) override |
For writing data, dataWritten signal will be emitted after successful write. More... | |
void | read (uint8_t buffer[], size_t bufferSize) override |
For reading data, dataAvailable signal will be emitted after successful read. More... | |
bool | isBusyReading () const override |
Communication hardware is busy reading at the moment. More... | |
bool | isBusyWriting () const override |
Communication hardware is busy writing at the moment. More... | |
Public Member Functions inherited from semf::Uart | |
virtual | ~Uart ()=default |
virtual void | setFormat (uint8_t bits, WireMode wire, Parity par, StopBits stop, FlowControl flow)=0 |
Sets the format for the spi slave device. More... | |
virtual void | setBaud (uint32_t baud)=0 |
Sets the baud rate. More... | |
virtual uint32_t | baud ()=0 |
Returns the currently used baud rate. More... | |
Public Member Functions inherited from semf::CommunicationHardwareAsynchronous | |
virtual | ~CommunicationHardwareAsynchronous ()=default |
Type | type () const override |
Returns the hardware type. More... | |
void | setFrame (Frame frame) final |
Sets the selected usage of start and stop condition. More... | |
Public Member Functions inherited from semf::CommunicationHardware | |
virtual | ~CommunicationHardware ()=default |
virtual void | init ()=0 |
virtual void | deinit ()=0 |
virtual Type | type () const =0 |
Returns the hardware type. More... | |
virtual void | setFrame (Frame frame)=0 |
Sets the selected usage of start and stop condition. More... | |
Public Member Functions inherited from semf::app::Communication | |
virtual | ~Communication ()=default |
virtual void | write (const uint8_t data[], size_t dataSize)=0 |
For writing data, dataWritten signal will be emitted after successful write. More... | |
virtual void | read (uint8_t buffer[], size_t bufferSize)=0 |
For reading data, dataAvailable signal will be emitted after successful read. More... | |
virtual void | stopRead ()=0 |
virtual void | stopWrite ()=0 |
virtual bool | isBusyReading () const =0 |
Communication hardware is busy reading at the moment. More... | |
virtual bool | isBusyWriting () const =0 |
Communication hardware is busy writing at the moment. More... | |
Protected Member Functions | |
void | setBusyReading (bool isBusy) |
Sets the busy flag for reading. More... | |
void | setBusyWriting (bool isBusy) |
Sets the busy flag for writing. More... | |
virtual void | writeHardware (const uint8_t data[], size_t dataSize)=0 |
Hardware will write data in interrupt mode. More... | |
virtual void | readHardware (uint8_t buffer[], size_t bufferSize)=0 |
Hardware will read data in interrupt mode. More... | |
void | onDataWritten () |
void | onDataAvailable () |
void | onError (Error thrown) |
Is called if an error occurred by hardware read or write access. Will throw error signal. More... | |
Additional Inherited Members | |
Public Attributes inherited from semf::app::Communication | |
Signal | dataWritten |
Signal | dataAvailable |
Signal | writeStopped |
Signal | readStopped |
Signal< Error > | error |
Class for using UART hardware.
Definition at line 21 of file uarthardware.h.
|
strong |
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring).
Enumerator | |
---|---|
Write_IsBusy | |
Write_DataIsNullptr | |
Write_DataSizeIsZero | |
Read_IsBusy | |
Read_BufferIsNullptr | |
Read_BufferSizeIsZero |
Definition at line 27 of file uarthardware.h.
|
virtualdefault |
|
overridevirtual |
Communication hardware is busy reading at the moment.
Implements semf::app::Communication.
Definition at line 68 of file uarthardware.cpp.
|
overridevirtual |
Communication hardware is busy writing at the moment.
Implements semf::app::Communication.
Definition at line 73 of file uarthardware.cpp.
|
protected |
Is called after data is available in the hardware. Will emit dataAvailable
signal.
Definition at line 95 of file uarthardware.cpp.
|
protected |
Is called after data are written by the hardware. Will emit dataWritten
signal.
Definition at line 88 of file uarthardware.cpp.
|
protected |
Is called if an error occurred by hardware read or write access. Will throw error
signal.
thrown | A thrown error object. |
Definition at line 102 of file uarthardware.cpp.
|
overridevirtual |
For reading data, dataAvailable
signal will be emitted after successful read.
buffer | Buffer to store received bytes in. |
bufferSize | Size of receive buffer. |
Read_IsBusy | If this is busy. |
Read_BufferIsNullptr | If buffer is a nullptr. |
Read_BufferSizeIsZero | If bufferSize is zero. |
Implements semf::app::Communication.
Definition at line 42 of file uarthardware.cpp.
|
protectedpure virtual |
Hardware will read data in interrupt mode.
buffer | data array. |
bufferSize | data array size. |
Implemented in semf::Stm32Uart.
|
protected |
Sets the busy flag for reading.
write()
, read()
busy is set to true
. In onDataAvailable()
, onDataWritten()
and onError()
is busy reseted to false
. isBusy | true for busy, false for idle. |
Definition at line 78 of file uarthardware.cpp.
|
protected |
Sets the busy flag for writing.
write()
, read()
busy is set to true
. In onDataAvailable()
, onDataWritten()
and onError()
is busy reseted to false
. isBusy | true for busy, false for idle. |
Definition at line 83 of file uarthardware.cpp.
|
overridevirtual |
For writing data, dataWritten
signal will be emitted after successful write.
data | Array, containing data to write. |
dataSize | Size of write data. |
Write_IsBusy | If this is busy. |
Write_DataIsNullptr | If data is a nullptr. |
Write_DataSizeIsZero | If dataSize is zero. |
Implements semf::app::Communication.
Definition at line 16 of file uarthardware.cpp.
|
protectedpure virtual |
Hardware will write data in interrupt mode.
data | data array. |
dataSize | data array size. |
Implemented in semf::Stm32Uart.