semf
|
SpiMasterHardware
implementation for STM32.
More...
#include <stm32spimaster.h>
Public Member Functions | |
Stm32SpiMaster (SPI_HandleTypeDef &hwHandle, uint32_t spiClockFrequencyHz=0) | |
Constructor. More... | |
Stm32SpiMaster (SPI_HandleTypeDef &hwHandle, Gpio &chipSelectPin, uint32_t spiClockFrequencyHz=0) | |
Constructor. More... | |
Stm32SpiMaster (const Stm32SpiMaster &other)=delete | |
virtual | ~Stm32SpiMaster ()=default |
void | init () override |
void | deinit () override |
void | setFrequency (uint32_t hz) override |
Sets the speed. More... | |
void | isrRead (SPI_HandleTypeDef &spi) |
Interrupt service routine for spi object receive. More... | |
void | isrWritten (SPI_HandleTypeDef &spi) |
void | isrWrittenAndRead (SPI_HandleTypeDef &spi) |
Interrupt service routine for spi object receive and transmit. More... | |
void | isrError (SPI_HandleTypeDef &spi) |
Interrupt service routine for spi object error. More... | |
void | isrAborted (SPI_HandleTypeDef &spi) |
handles the abort callback More... | |
Public Member Functions inherited from semf::SpiMasterHardware | |
SpiMasterHardware ()=default | |
SpiMasterHardware (Gpio &chipSelectPin) | |
virtual | ~SpiMasterHardware ()=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 | setFrame (CommunicationHardware::Frame frame) override |
Sets the selected usage of start and stop condition. More... | |
void | setFormat (uint8_t bits, TransmissionMode transmission, WireMode wire) override |
Sets the format for the spi slave device. More... | |
void | stopWrite () override |
void | stopRead () override |
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... | |
virtual void | setChipSelectPin (Gpio &chipSelectPin) |
Sets a new chip select pin read and write operations. More... | |
void | enableChipSelect () |
void | disableChipSelect () |
virtual void | setFrequency (uint32_t hz)=0 |
Sets the speed. More... | |
Public Member Functions inherited from semf::Spi | |
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... | |
Public Member Functions inherited from semf::CommunicationHardwareSynchronousMaster | |
virtual | ~CommunicationHardwareSynchronousMaster ()=default |
Type | type () const override |
Returns the hardware type. 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... | |
Public Member Functions inherited from semf::LinkedQueue< T >::Node | |
virtual | ~Node ()=default |
T * | next () const |
Returns a pointer to the next element in a queue. More... | |
void | setNext (T *next) |
Sets a pointer to the next element in a list. More... | |
bool | isInQueue (LinkedQueue &queue) |
Returns if a node is part of this LinkedQueue . More... | |
Static Public Member Functions | |
static LinkedQueue< Stm32SpiMaster > * | queue () |
Get the list with all spi. More... | |
static void | systemIsrRead (SPI_HandleTypeDef &spi) |
System-wide interrupt service routine for spi receive. More... | |
static void | systemIsrWritten (SPI_HandleTypeDef &spi) |
System-wide interrupt service routine for spi transmit. More... | |
static void | systemIsrWrittenAndRead (SPI_HandleTypeDef &spi) |
System-wide interrupt service routine for spi receive and transmit. More... | |
static void | systemIsrError (SPI_HandleTypeDef &spi) |
System-wide interrupt service routine for spi error. More... | |
static void | systemIsrAbort (SPI_HandleTypeDef &spi) |
System-wide interrupt service routine for spi abort. More... | |
Protected Member Functions | |
void | writeHardware (const uint8_t data[], size_t dataSize) override |
Hardware will write data. More... | |
void | readHardware (uint8_t buffer[], size_t bufferSize) override |
Hardware will read data. More... | |
void | writeReadHardware (const uint8_t writeData[], uint8_t readBuffer[], size_t size) override |
Hardware will read and write data parallel. More... | |
void | setFormatHardware (uint8_t bits, TransmissionMode transmission, WireMode wire) override |
Configures the hardware for insuring the given configuration. More... | |
void | stopWriteHardware () override |
void | stopReadHardware () override |
Protected Member Functions inherited from semf::SpiMasterHardware | |
void | setBusy (bool isBusy) |
Sets the busy flag. More... | |
CommunicationHardware::Frame | frame () const |
Returns the actual frame mode setting. More... | |
virtual void | writeHardware (const uint8_t data[], size_t dataSize)=0 |
Hardware will write data. More... | |
virtual void | readHardware (uint8_t buffer[], size_t bufferSize)=0 |
Hardware will read data. More... | |
virtual void | writeReadHardware (const uint8_t writeData[], uint8_t readBuffer[], size_t size)=0 |
Hardware will read and write data parallel. More... | |
virtual void | setFormatHardware (uint8_t bits, TransmissionMode transmission, WireMode wire)=0 |
Configures the hardware for insuring the given configuration. More... | |
virtual void | stopWriteHardware ()=0 |
virtual void | stopReadHardware ()=0 |
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... | |
void | setTransmissionMode (TransmissionMode mode) |
Sets the transmission mode. More... | |
void | setWireMode (WireMode mode) |
Sets the wire mode. More... | |
Additional Inherited Members | |
Public Attributes inherited from semf::app::Communication | |
Signal | dataWritten |
Signal | dataAvailable |
Signal | writeStopped |
Signal | readStopped |
Signal< Error > | error |
SpiMasterHardware
implementation for STM32.
Definition at line 24 of file stm32spimaster.h.
|
strong |
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring).
Definition at line 28 of file stm32spimaster.h.
|
explicit |
Constructor.
hwHandle | Hardware spi handle. |
spiClockFrequencyHz | Frequency of the clock running the SPI module in Hz. |
Definition at line 18 of file stm32spimaster.cpp.
semf::Stm32SpiMaster::Stm32SpiMaster | ( | SPI_HandleTypeDef & | hwHandle, |
Gpio & | chipSelectPin, | ||
uint32_t | spiClockFrequencyHz = 0 |
||
) |
Constructor.
hwHandle | SPI hardware interface. |
chipSelectPin | Gpio for chip select. |
spiClockFrequencyHz | Frequency of the clock running the SPI module in Hz. |
Definition at line 26 of file stm32spimaster.cpp.
|
explicitdelete |
|
virtualdefault |
|
overridevirtual |
Deinitializes the hardware
Deinit_HalError | If the ST-HAL returns a hal error. |
Deinit_HalBusy | If the ST-HAL returns a hal busy. |
Deinit_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::CommunicationHardware.
Definition at line 60 of file stm32spimaster.cpp.
|
overridevirtual |
Initializes the hardware.
Init_HalError | If the ST-HAL returns a hal error. |
Init_HalBusy | If the ST-HAL returns a hal busy. |
Init_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::CommunicationHardware.
Definition at line 35 of file stm32spimaster.cpp.
void semf::Stm32SpiMaster::isrAborted | ( | SPI_HandleTypeDef & | spi | ) |
handles the abort callback
spi | Hardware handler. |
Definition at line 244 of file stm32spimaster.cpp.
void semf::Stm32SpiMaster::isrError | ( | SPI_HandleTypeDef & | spi | ) |
Interrupt service routine for spi object error.
spi | Hardware handler. |
IsrError_Isr | If an unexpected error occurres. |
Definition at line 235 of file stm32spimaster.cpp.
void semf::Stm32SpiMaster::isrRead | ( | SPI_HandleTypeDef & | spi | ) |
Interrupt service routine for spi object receive.
spi | Hardware handler. |
Definition at line 183 of file stm32spimaster.cpp.
void semf::Stm32SpiMaster::isrWritten | ( | SPI_HandleTypeDef & | spi | ) |
void semf::Stm32SpiMaster::isrWrittenAndRead | ( | SPI_HandleTypeDef & | spi | ) |
Interrupt service routine for spi object receive and transmit.
spi | Hardware handler. |
Definition at line 214 of file stm32spimaster.cpp.
|
static |
Get the list with all spi.
Definition at line 147 of file stm32spimaster.cpp.
|
overrideprotectedvirtual |
Hardware will read data.
buffer | data array |
bufferSize | data array size |
Implements semf::SpiMasterHardware.
Definition at line 280 of file stm32spimaster.cpp.
|
overrideprotectedvirtual |
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. |
SetFormatHardware_BitsNotSupported | If value for bit is not supported (8 and 16 are allowed). |
Implements semf::SpiMasterHardware.
Definition at line 299 of file stm32spimaster.cpp.
|
overridevirtual |
Sets the speed.
hz | Frequency in hz. |
SetFrequency_IsBusy | If this is busy. |
SetFrequency_SpiClockIsZero | If spiClockFrequencyHz is not initialized. |
Implements semf::SpiMasterHardware.
Definition at line 85 of file stm32spimaster.cpp.
|
overrideprotectedvirtual |
Forces the hardware to stop a reading process
StopReadHardware_HalError | If the ST-HAL returns a hal error. |
StopReadHardware_HalBusy | If the ST-HAL returns a hal busy. |
StopReadHardware_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::SpiMasterHardware.
Definition at line 372 of file stm32spimaster.cpp.
|
overrideprotectedvirtual |
Forces the hardware to stop a writing process.
StopWriteHardware_HalError | If the ST-HAL returns a hal error. |
StopWriteHardware_HalBusy | If the ST-HAL returns a hal busy. |
StopWriteHardware_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::SpiMasterHardware.
Definition at line 347 of file stm32spimaster.cpp.
|
static |
System-wide interrupt service routine for spi abort.
spi | Hardware handler. |
Definition at line 177 of file stm32spimaster.cpp.
|
static |
System-wide interrupt service routine for spi error.
spi | Hardware handler. |
Definition at line 171 of file stm32spimaster.cpp.
|
static |
System-wide interrupt service routine for spi receive.
spi | Hardware handler. |
Definition at line 153 of file stm32spimaster.cpp.
|
static |
System-wide interrupt service routine for spi transmit.
spi | Hardware handler. |
Definition at line 159 of file stm32spimaster.cpp.
|
static |
System-wide interrupt service routine for spi receive and transmit.
spi | Hardware handler. |
Definition at line 165 of file stm32spimaster.cpp.
|
overrideprotectedvirtual |
Hardware will write data.
data | data array |
dataSize | data array size |
Write_HalError | If the ST-HAL returns a hal error. |
Write_HalBusy | If the ST-HAL returns a hal busy. |
Write_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::SpiMasterHardware.
Definition at line 254 of file stm32spimaster.cpp.
|
overrideprotectedvirtual |
Hardware will read and write data parallel.
writeData | memory where to write from |
readBuffer | memory where to store read data |
size | data array size |
Implements semf::SpiMasterHardware.
Definition at line 289 of file stm32spimaster.cpp.