![]() |
semf
|
Class for using spi hardware in slave mode. In order of being a SPI slave IO-operations will not get executed before the CS-Signal is LOW. After calling an IO-operation successfully, the hardware state will change to busy while executing the IO call. The hardware state will change to ready after IO-operation is done. When the IO-operation got executed successfully one of the signals dataWritten
or dataAvailable
gets emitted. The signal handlers can start the next IO-operation as in all other classes deriving from CommunicationHardware
.
More...
#include <spislavehardware.h>
Public Types | |
enum class | ErrorCode : uint8_t { Write_IsBusy = 0 , Write_DataIsNullptr , Write_DataSizeIsZero , Read_IsBusy , Read_BufferIsNullptr , Read_BufferSizeIsZero , SetFormat_IsBusy , StopWrite_IsNotWriting , StopRead_IsNotReading , WriteRead_IsBusy , WriteRead_WriteDataIsNullptr , WriteRead_ReadBufferIsNullptr , WriteRead_SizeIsZero } |
Error IDs for this class. Error ID identify a unique error() / onError call (excluding transferring). More... | |
![]() | |
enum class | TransmissionMode : uint8_t { Mode0 , Mode1 , Mode2 , Mode3 } |
enum class | WireMode : uint8_t { FullDuplexWires , HalfDuplexWires , WriteOnlyWires , ReadOnlyWires } |
![]() | |
enum class | Type { SynchronousMaster = 1 , SynchronousSlave , Asynchronous } |
enum class | Frame : uint8_t { First = 0x01 , Next = 0x08 , Last = 0x10 , FirstAndLast = 0x11 } |
Public Member Functions | |
virtual | ~SpiSlaveHardware ()=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... | |
void | stopRead () override |
void | stopWrite () override |
void | setFrame (Frame frame) override |
Sets the selected usage of start and stop condition. More... | |
void | writeRead (const uint8_t writeData[], uint8_t readBuffer[], size_t size) override |
For writing and reading data parallel through the communication hardware 1) For interrupt or one shot dma mode, dataAvailable signal will be fired after successful read/write. 2) For cyclic dma mode, do not use this function. More... | |
void | setFormat (uint8_t bits, TransmissionMode transmission, WireMode wire) override |
Sets the format for the spi slave device. More... | |
![]() | |
virtual | ~Spi ()=default |
virtual void | writeRead (const uint8_t writeData[], uint8_t readBuffer[], size_t size)=0 |
For writing and reading data parallel through the communication hardware 1) For interrupt or one shot dma mode, dataAvailable signal will be fired after successful read/write. 2) For cyclic dma mode, do not use this function. More... | |
virtual void | setFormat (uint8_t bits, TransmissionMode transmission, WireMode wire)=0 |
Sets the format for the spi slave device. More... | |
![]() | |
virtual | ~CommunicationHardwareSynchronousSlave ()=default |
Type | type () const override |
Returns the hardware type. More... | |
![]() | |
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... | |
![]() | |
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 | onError (Error thrown) |
Error routine, emits the error signal. More... | |
void | onDataAvailable () |
void | onDataWritten () |
void | setBusy (bool busy) |
Sets the flag m_isBusy . More... | |
virtual void | writeHardware (const uint8_t data[], size_t dataSize)=0 |
Accesses the spi hardware in order to write dataSize bytes of data. More... | |
virtual void | readHardware (uint8_t buffer[], size_t bufferSize)=0 |
Accesses the spi hardware in order to read bufferSize bytes and stores them in buffer . More... | |
virtual void | writeReadHardware (const uint8_t writeData[], uint8_t readBuffer[], size_t size)=0 |
Accesses the spi hardware in order to perform a full duplex read/write. More... | |
virtual void | stopReadHardware ()=0 |
virtual void | stopWriteHardware ()=0 |
virtual void | setFormatHardware (uint8_t bits, TransmissionMode transmission, WireMode wire)=0 |
Configures the hardware for insuring the given configuration. More... | |
void | setWireMode (WireMode mode) |
Sets the wire mode. More... | |
void | setTransmissionMode (TransmissionMode mode) |
Sets the transmission mode. More... | |
Additional Inherited Members | |
![]() | |
Signal | dataWritten |
Signal | dataAvailable |
Signal | writeStopped |
Signal | readStopped |
Signal< Error > | error |
Class for using spi hardware in slave mode. In order of being a SPI slave IO-operations will not get executed before the CS-Signal is LOW. After calling an IO-operation successfully, the hardware state will change to busy while executing the IO call. The hardware state will change to ready after IO-operation is done. When the IO-operation got executed successfully one of the signals dataWritten
or dataAvailable
gets emitted. The signal handlers can start the next IO-operation as in all other classes deriving from CommunicationHardware
.
Definition at line 24 of file spislavehardware.h.
|
strong |
Error IDs for this class. Error ID identify a unique error() / onError call (excluding transferring).
Definition at line 30 of file spislavehardware.h.
|
virtualdefault |
|
overridevirtual |
Communication hardware is busy reading at the moment.
Implements semf::app::Communication.
Definition at line 66 of file spislavehardware.cpp.
|
overridevirtual |
Communication hardware is busy writing at the moment.
Implements semf::app::Communication.
Definition at line 71 of file spislavehardware.cpp.
|
protected |
Data available routine, emits the dataAvailable
signal.
Definition at line 160 of file spislavehardware.cpp.
|
protected |
Data written routine, emits the dataWritten
signal.
Definition at line 167 of file spislavehardware.cpp.
|
protected |
Error routine, emits the error
signal.
thrown | A thrown error object. |
Definition at line 153 of file spislavehardware.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 is busy. |
Read_BufferIsNullptr | If buffer is nullptr. |
Read_BufferSizeIsZero | If bufferSize is zero. |
Implements semf::app::Communication.
Definition at line 41 of file spislavehardware.cpp.
|
protectedpure virtual |
Accesses the spi hardware in order to read bufferSize
bytes and stores them in buffer
.
buffer | Buffer location. |
bufferSize | Size of the buffer . |
Implemented in semf::Stm32SpiSlave.
|
protected |
Sets the flag m_isBusy
.
busy | New value of the flag m_isBusyWriting . |
Definition at line 174 of file spislavehardware.cpp.
|
overridevirtual |
Sets the format for the spi slave device.
bits | number of bits per frame |
transmission | transmission mode (polarity and phase setting) |
wire | wire transmission setting |
SetFormat_IsBusy | If this is busy. |
Implements semf::Spi.
Definition at line 136 of file spislavehardware.cpp.
|
protectedpure virtual |
Configures the hardware for insuring the given configuration.
bits | Number of bits per frame. |
transmission | Transmission mode (polarity and phase setting). |
wire | Wire transmission setting. |
Implemented in semf::Stm32SpiSlave.
|
overridevirtual |
Sets the selected usage of start and stop condition.
frame | frame mode |
Implements semf::CommunicationHardware.
Definition at line 98 of file spislavehardware.cpp.
|
protected |
Sets the transmission mode.
mode | The new transmission mode. |
Definition at line 184 of file spislavehardware.cpp.
|
protected |
Sets the wire mode.
mode | The new wire mode. |
Definition at line 179 of file spislavehardware.cpp.
|
overridevirtual |
Stops the read process as fast as possible without destroying anything. The readStopped
Signal gets emitted if the call was successful.
StopRead_IsNotReading | If slave is not currently reading. |
Implements semf::app::Communication.
Definition at line 76 of file spislavehardware.cpp.
|
protectedpure virtual |
Stops the hardware to read.
Implemented in semf::Stm32SpiSlave.
|
overridevirtual |
Stops the write process as fast as possible without destroying anything. The writeStopped
Signal gets emitted if the call was successful.
StopWrite_IsNotWriting | If slave is not currently reading. |
Implements semf::app::Communication.
Definition at line 87 of file spislavehardware.cpp.
|
protectedpure virtual |
Stop the hardware to write.
Implemented in semf::Stm32SpiSlave.
|
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 write is busy. |
Write_DataIsNullptr | If data is nullptr. |
Write_DataSizeIsZero | If dataSize is zero. |
Implements semf::app::Communication.
Definition at line 15 of file spislavehardware.cpp.
|
protectedpure virtual |
Accesses the spi hardware in order to write dataSize
bytes of data.
data | Data location. |
dataSize | Size of data . |
Implemented in semf::Stm32SpiSlave.
|
overridevirtual |
For writing and reading data parallel through the communication hardware 1) For interrupt or one shot dma mode, dataAvailable signal will be fired after successful read/write. 2) For cyclic dma mode, do not use this function.
writeData | data array for write data |
readBuffer | data array for read data |
size | data array size |
WriteRead_IsBusy | If this is busy. |
WriteRead_WriteDataIsNullptr | If writeData is a nullptr. |
WriteRead_ReadBufferIsNullptr | If readBuffer is a nullptr. |
WriteRead_SizeIsZero | If size is zero. |
Implements semf::Spi.
Definition at line 104 of file spislavehardware.cpp.
|
protectedpure virtual |
Accesses the spi hardware in order to perform a full duplex read/write.
writeData | Data to write. |
readBuffer | Buffer to read. |
size | Size of both buffers. |
Implemented in semf::Stm32SpiSlave.