10#ifndef SEMF_COMMUNICATION_I2CSLAVEHARDWARE_H_
11#define SEMF_COMMUNICATION_I2CSLAVEHARDWARE_H_
35 Read_BufferSizeIsZero,
38 StartListening_IsBusy,
51 void write(
const uint8_t data[],
size_t dataSize)
override;
59 void read(uint8_t buffer[],
size_t bufferSize)
override;
63 uint8_t
address()
const override;
159 bool m_isBusy =
false;
163 bool m_listening =
false;
165 uint8_t m_address = 0;
167 static constexpr Error::ClassID kSemfClassId = Error::ClassID::I2cSlaveHardware;
@ FirstAndLast
start AND stop condition
This interface standardized the read and write interface for synchronous slave hardware,...
Class for representing errors. Every error should have a unique source code. As a user feel encourage...
Interface for I2C specific functionalities, which are not solved in a generic way in CommunicationHar...
This class can be used for using the I2C bus as a slave. Call startListening() for receiving I/O-requ...
void onError(Error thrown)
Is called if an error occurred by hardware read or write access. Will emit error signal.
void startListening()
Starts to react on getting addressed.
virtual void readHardware(uint8_t buffer[], size_t bufferSize)=0
Hardware will read data. After finished read operation, onDataAvailable() function will be called.
ErrorCode
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring...
void read(uint8_t buffer[], size_t bufferSize) override
For reading data, dataAvailable signal will be emitted after successful read.
bool isBusyReading() const override
Communication hardware is busy reading at the moment.
bool isBusyWriting() const override
Communication hardware is busy writing at the moment.
void write(const uint8_t data[], size_t dataSize) override
For writing data, dataWritten signal will be emitted after successful write.
virtual void writeHardware(const uint8_t data[], size_t dataSize)=0
Hardware will write data. After finished write operation, onDataWritten() function will be called.
void onDataWritten()
Is called after data are written by the hardware. Will emit dataWritten signal.
void stopListening()
Quits reacting on getting addressed.
uint8_t address() const override
Returns the I2C slave device address.
void setFrequency(uint32_t hz) override
Sets the speed (I2C baud rate).
void setBusy(bool isBusy)
Sets the busy flag.
void setFrame(CommunicationHardware::Frame frame) override
Sets the selected usage of start and stop condition.
virtual void stopListeningHardware()=0
bool isListening() const
Returns the listening flag.
virtual void startListeningHardware()=0
virtual ~I2cSlaveHardware()=default
CommunicationHardware::Frame frame() const
Returns the actual frame mode setting.
virtual void setFrequencyHardware(uint32_t hz)=0
Configures the frequency of the bus.
virtual void setAddressHardware(uint8_t address)=0
Sets the address of the i2c hardware.
void setListening(bool listening)
Sets the listening flag.
void onDataAvailable()
Is called after data is available in the hardware. Will emit dataAvailable signal.
void setAddress(uint8_t address) override
Sets the address of the slave.
Signal for lightweight signal/slot implementation. One signal can be connected to multiple slots and ...