semf
|
I2cMasterHardware
implementation for STM32.
More...
#include <stm32i2cmaster.h>
Public Member Functions | |
Stm32I2cMaster (I2C_HandleTypeDef &hwHandle) | |
Constructor. More... | |
Stm32I2cMaster (const Stm32I2cMaster &other)=delete | |
virtual | ~Stm32I2cMaster ()=default |
void | init () override |
void | deinit () override |
void | stopWrite () override |
void | stopRead () override |
void | setFrequency (uint32_t hz) override |
Sets the speed (I2C baud rate). More... | |
void | checkAddress (uint8_t address) override |
Checks if the given address is available on the bus. Emits address found if successful (ACK). error signal will be emitted, if no slave answers (NACK). More... | |
void | isrRead (I2C_HandleTypeDef &i2c) |
Interrupt service routine for i2c object receive. More... | |
void | isrWritten (I2C_HandleTypeDef &i2c) |
Interrupt service routine for i2c object transmit. More... | |
void | isrError (I2C_HandleTypeDef &i2c) |
Interrupt service routine for i2c object error. More... | |
void | isrAbort (I2C_HandleTypeDef &i2c) |
Interrupt service routine for i2c object abort. More... | |
Public Member Functions inherited from semf::I2cMasterHardware | |
virtual | ~I2cMasterHardware ()=default |
virtual void | checkAddress (uint8_t address)=0 |
Checks if the given address is available on the bus. Emits address found if successful (ACK). error signal will be emitted, if no slave answers (NACK). More... | |
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... | |
uint8_t | address () const override |
Returns the I2C slave device address. More... | |
void | setAddress (uint8_t address) override |
void | setFrame (CommunicationHardware::Frame frame) override |
Sets the selected usage of start and stop condition. 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::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< Stm32I2cMaster > * | queue () |
Get the list with all i2c. More... | |
static void | systemIsrRead (I2C_HandleTypeDef &i2c) |
System-wide interrupt service routine for i2c receive. More... | |
static void | systemIsrWritten (I2C_HandleTypeDef &i2c) |
System-wide interrupt service routine for i2c transmit. More... | |
static void | systemIsrError (I2C_HandleTypeDef &i2c) |
System-wide interrupt service routine for i2c error. More... | |
static void | systemIsrAbort (I2C_HandleTypeDef &i2c) |
System-wide interrupt service routine for process canceling. More... | |
Protected Member Functions | |
I2C_HandleTypeDef * | hardwareHandle () |
Returns the hardware handle. More... | |
virtual uint32_t | hardwareFrame (CommunicationHardware::Frame frame) const |
Converts the frame information from semf to STM. More... | |
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... | |
Protected Member Functions inherited from semf::I2cMasterHardware | |
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 | setFrequencyHardware (uint32_t hz)=0 |
Configures the frequency of the bus. More... | |
void | onDataWritten () |
void | onDataAvailable () |
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::I2cMasterHardware | |
semf::Signal | addressFound |
Public Attributes inherited from semf::app::Communication | |
Signal | dataWritten |
Signal | dataAvailable |
Signal | writeStopped |
Signal | readStopped |
Signal< Error > | error |
I2cMasterHardware
implementation for STM32.
Definition at line 24 of file stm32i2cmaster.h.
|
strong |
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring).
Definition at line 28 of file stm32i2cmaster.h.
|
explicit |
Constructor.
hwHandle | i2c hardware interface |
Definition at line 18 of file stm32i2cmaster.cpp.
|
explicitdelete |
|
virtualdefault |
|
overridevirtual |
Checks if the given address is available on the bus. Emits address
found if successful (ACK). error
signal will be emitted, if no slave answers (NACK).
address | 7 bit I2C slave address. |
Implements semf::I2cMasterHardware.
Definition at line 149 of file stm32i2cmaster.cpp.
|
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 50 of file stm32i2cmaster.cpp.
|
protectedvirtual |
Converts the frame information from semf to STM.
frame | Frame information. |
Definition at line 230 of file stm32i2cmaster.cpp.
|
protected |
Returns the hardware handle.
Definition at line 225 of file stm32i2cmaster.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 25 of file stm32i2cmaster.cpp.
void semf::Stm32I2cMaster::isrAbort | ( | I2C_HandleTypeDef & | i2c | ) |
Interrupt service routine for i2c object abort.
i2c | Hardware handler. |
Definition at line 215 of file stm32i2cmaster.cpp.
void semf::Stm32I2cMaster::isrError | ( | I2C_HandleTypeDef & | i2c | ) |
Interrupt service routine for i2c object error.
i2c | Hardware handler. |
IsrError_HalError | If an unexpected error occures. |
Definition at line 206 of file stm32i2cmaster.cpp.
void semf::Stm32I2cMaster::isrRead | ( | I2C_HandleTypeDef & | i2c | ) |
Interrupt service routine for i2c object receive.
i2c | Hardware handler. |
Definition at line 188 of file stm32i2cmaster.cpp.
void semf::Stm32I2cMaster::isrWritten | ( | I2C_HandleTypeDef & | i2c | ) |
Interrupt service routine for i2c object transmit.
i2c | Hardware handler. |
Definition at line 197 of file stm32i2cmaster.cpp.
|
static |
Get the list with all i2c.
Definition at line 158 of file stm32i2cmaster.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 timeout. |
ReadHardware_HalTimeout | If the ST-HAL returns a hal busy. |
Implements semf::I2cMasterHardware.
Definition at line 256 of file stm32i2cmaster.cpp.
|
overridevirtual |
Sets the speed (I2C baud rate).
hz | Frequency in hz. |
SetFrequency_IsBusy | If this is busy. |
Implements semf::I2c.
Definition at line 135 of file stm32i2cmaster.cpp.
|
overridevirtual |
Stops the read process as fast as possible without destroying anything. The readStopped
Signal gets emitted if the call was successful.
StopRead_HalError | If the ST-HAL returns a hal error. |
StopRead_HalBusy | If the ST-HAL returns a hal busy. |
StopRead_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::app::Communication.
Definition at line 105 of file stm32i2cmaster.cpp.
|
overridevirtual |
Stops the write process as fast as possible without destroying anything. The writeStopped
Signal gets emitted if the call was successful.
StopWrite_HalError | If the ST-HAL returns a hal error. |
StopWrite_HalBusy | If the ST-HAL returns a hal busy. |
StopWrite_HalTimeout | If the ST-HAL returns a hal timeout. |
Implements semf::app::Communication.
Definition at line 75 of file stm32i2cmaster.cpp.
|
static |
System-wide interrupt service routine for process canceling.
i2c | Hardware handler. |
Definition at line 182 of file stm32i2cmaster.cpp.
|
static |
System-wide interrupt service routine for i2c error.
i2c | Hardware handler. |
Definition at line 176 of file stm32i2cmaster.cpp.
|
static |
System-wide interrupt service routine for i2c receive.
i2c | Hardware handler. |
Definition at line 164 of file stm32i2cmaster.cpp.
|
static |
System-wide interrupt service routine for i2c transmit.
i2c | Hardware handler. |
Definition at line 170 of file stm32i2cmaster.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 timeout. |
WriteHardware_HalTimeout | If the ST-HAL returns a hal busy. |
Implements semf::I2cMasterHardware.
Definition at line 291 of file stm32i2cmaster.cpp.