semf
|
I2cSlaveHardware
implementation for STM32.
More...
#include <stm32i2cslave.h>
Public Member Functions | |
Stm32I2cSlave (I2C_HandleTypeDef &hwHandle) | |
Constructor. More... | |
Stm32I2cSlave (const Stm32I2cSlave &other)=delete | |
virtual | ~Stm32I2cSlave ()=default |
void | init () override |
void | deinit () override |
void | stopRead () override |
void | stopWrite () override |
void | setFrequency (uint32_t hz) override |
Sets the speed (I2C baud rate). More... | |
Public Member Functions inherited from semf::I2cSlaveHardware | |
virtual | ~I2cSlaveHardware ()=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... | |
uint8_t | address () const override |
Returns the I2C slave device address. More... | |
void | setAddress (uint8_t address) override |
Sets the address of the slave. More... | |
void | setFrequency (uint32_t hz) override |
Sets the speed (I2C baud rate). More... | |
void | startListening () |
Starts to react on getting addressed. More... | |
void | stopListening () |
Quits reacting on getting addressed. More... | |
bool | isListening () const |
Returns the listening flag. More... | |
Public Member Functions inherited from semf::I2c | |
virtual | ~I2c ()=default |
virtual void | setFrequency (uint32_t hz)=0 |
Sets the speed (I2C baud rate). More... | |
virtual uint8_t | address () const =0 |
Returns the I2C slave device address. More... | |
virtual void | setAddress (uint8_t address)=0 |
Public Member Functions inherited from semf::CommunicationHardwareSynchronousSlave | |
virtual | ~CommunicationHardwareSynchronousSlave ()=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 void | systemIsrRead (I2C_HandleTypeDef &hwHandle) |
System-wide isr for data reception on an I2C-bus. More... | |
static void | systemIsrWritten (I2C_HandleTypeDef &hwHandle) |
System-wide isr for data transmission on an I2C-bus. More... | |
static void | systemIsrListen (I2C_HandleTypeDef &hwHandle) |
System-wide isr for end of listening on an I2C-bus. More... | |
static void | systemIsrError (I2C_HandleTypeDef &hwHandle) |
static void | systemIsrAddressing (I2C_HandleTypeDef &hwHandle, uint8_t direction, uint16_t addrMatchCode) |
Protected Member Functions | |
void | readHardware (uint8_t buffer[], size_t bufferSize) override |
Hardware will read data. After finished read operation, onDataAvailable() function will be called. More... | |
void | writeHardware (const uint8_t data[], size_t dataSize) override |
Hardware will write data. After finished write operation, onDataWritten() function will be called. More... | |
void | startListeningHardware () override |
void | stopListeningHardware () override |
void | setAddressHardware (uint8_t address) override |
Sets the address of the i2c hardware. More... | |
virtual uint32_t | hardwareFrame (CommunicationHardware::Frame frame) const |
Converts the frame information from semf to STM. More... | |
I2C_HandleTypeDef * | hardwareHandle () |
Returns the hardware Handle. More... | |
Protected Member Functions inherited from semf::I2cSlaveHardware | |
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. After finished write operation, onDataWritten() function will be called. More... | |
virtual void | readHardware (uint8_t buffer[], size_t bufferSize)=0 |
Hardware will read data. After finished read operation, onDataAvailable() function will be called. More... | |
virtual void | startListeningHardware ()=0 |
virtual void | stopListeningHardware ()=0 |
virtual void | setAddressHardware (uint8_t address)=0 |
Sets the address of the i2c hardware. More... | |
void | setListening (bool listening) |
Sets the listening flag. More... | |
virtual void | setFrequencyHardware (uint32_t hz)=0 |
Configures the frequency of the bus. More... | |
void | onDataWritten () |
Is called after data are written by the hardware. Will emit dataWritten signal. More... | |
void | onDataAvailable () |
Is called after data is available in the hardware. Will emit dataAvailable signal. More... | |
void | onError (Error thrown) |
Is called if an error occurred by hardware read or write access. Will emit error signal. More... | |
Additional Inherited Members | |
Public Attributes inherited from semf::I2cSlaveHardware | |
Signal | readExpected |
Signal | writeExpected |
Public Attributes inherited from semf::app::Communication | |
Signal | dataWritten |
Signal | dataAvailable |
Signal | writeStopped |
Signal | readStopped |
Signal< Error > | error |
I2cSlaveHardware
implementation for STM32.
Definition at line 23 of file stm32i2cslave.h.
|
strong |
Error IDs for this class. Error ID identify a unique error() / onError call (excluding transferring).
Definition at line 27 of file stm32i2cslave.h.
|
explicit |
|
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 47 of file stm32i2cslave.cpp.
|
protectedvirtual |
Converts the frame information from semf to STM.
frame | Frame information. |
Definition at line 276 of file stm32i2cslave.cpp.
|
protected |
Returns the hardware Handle.
Definition at line 296 of file stm32i2cslave.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 23 of file stm32i2cslave.cpp.
|
overrideprotectedvirtual |
Hardware will read data. After finished read operation, onDataAvailable()
function will be called.
buffer | Buffer to store received data in. |
bufferSize | Size of data . |
ReadHardware_HalError | If the ST-HAL returns a hal error. |
ReadHardware_HalBusy | If the ST-HAL returns a hal busy. |
ReadHardware_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::I2cSlaveHardware.
Definition at line 167 of file stm32i2cslave.cpp.
|
overrideprotectedvirtual |
Sets the address of the i2c hardware.
address | Address of the slave. |
Implements semf::I2cSlaveHardware.
Definition at line 269 of file stm32i2cslave.cpp.
|
overridevirtual |
Sets the speed (I2C baud rate).
hz | Frequency in hz. |
SetFrequency_IsBusy | If this is busy. |
Reimplemented from semf::I2cSlaveHardware.
Definition at line 81 of file stm32i2cslave.cpp.
|
overrideprotectedvirtual |
Hardware will react on getting addressed.
StartListeningHardware_HalError | If the ST-HAL returns a hal error. |
StartListeningHardware_HalBusy | If the ST-HAL returns a hal busy. |
StartListeningHardware_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::I2cSlaveHardware.
Definition at line 219 of file stm32i2cslave.cpp.
|
overrideprotectedvirtual |
Hardware will ignore getting addressed.
StopListeningHardware_HalError | If the ST-HAL returns a hal error. |
StopListeningHardware_HalBusy | If the ST-HAL returns a hal busy. |
StopListeningHardware_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::I2cSlaveHardware.
Definition at line 244 of file stm32i2cslave.cpp.
|
overridevirtual |
Stops the read process as fast as possible without destroying anything. The readStopped
Signal gets emitted if the call was successful.
Implements semf::app::Communication.
Definition at line 71 of file stm32i2cslave.cpp.
|
overridevirtual |
Stops the write process as fast as possible without destroying anything. The writeStopped
Signal gets emitted if the call was successful.
Implements semf::app::Communication.
Definition at line 76 of file stm32i2cslave.cpp.
|
static |
|
static |
|
static |
System-wide isr for end of listening on an I2C-bus.
hwHandle | Native handle. |
SystemIsrListen_EnableListenHalError | If the ST-HAL returns a hal error. |
SystemIsrListen_EnableListenHalBusy | If the ST-HAL returns a hal busy. |
SystemIsrListen_EnableListenHalTimeout | If the ST-HAL returns a hal timeout. |
Definition at line 114 of file stm32i2cslave.cpp.
|
static |
System-wide isr for data reception on an I2C-bus.
hwHandle | Native handle. |
Definition at line 92 of file stm32i2cslave.cpp.
|
static |
System-wide isr for data transmission on an I2C-bus.
hwHandle | Native handle. |
Definition at line 103 of file stm32i2cslave.cpp.
|
overrideprotectedvirtual |
Hardware will write data. After finished write operation, onDataWritten()
function will be called.
data | Array of data to write. |
dataSize | Size of data . |
WriteHardware_HalError | If the ST-HAL returns a hal error. |
WriteHardware_HalBusy | If the ST-HAL returns a hal busy. |
WriteHardware_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::I2cSlaveHardware.
Definition at line 193 of file stm32i2cslave.cpp.