10#ifndef SEMF_COMMUNICATION_SOFTI2CMASTER_H_
11#define SEMF_COMMUNICATION_SOFTI2CMASTER_H_
37 StopConditionSetSda_NackError = 0
56 void writeHardware(
const uint8_t data[],
size_t size)
override;
57 void readHardware(uint8_t buffer[],
size_t bufferSize)
override;
62 void resartConditionSetSdaResetScl();
64 void resartConditionSetScl();
68 void startConditionResetSda();
70 void startConditionResetScl();
76 void writeByteSetSdaDataBit();
78 void writeByteSetScl();
83 void writeByteResetScl();
89 void readByteReadSdaDataBit();
91 void readByteSetScl();
96 void readByteResetScl();
100 void checkAcknowledgeSetSdaInput();
102 void checkAcknowledgeSetScl();
104 void checkAcknowledgeResetScl();
106 void setAcknowledgeSetSdaOutput();
108 void setAcknowledgeSetScl();
110 void setAcknowledgeResetScl();
112 void finishAcknowledge();
114 void finishAcknowledgeWriteOperation();
116 void finishAcknowledgeReadOperation();
120 void stopConditionResetSda();
122 void stopConditionSetScl();
127 void stopConditionSetSda();
128 void setFrequency(uint32_t hz);
137 uint8_t* m_data =
nullptr;
139 size_t m_dataSize = 0;
141 size_t m_dataIndex = 0;
143 uint8_t m_activeByte = 0;
145 bool m_writingAddress =
false;
147 int8_t m_bitIndex = 7;
154 bool m_lastOperationWasWrite =
false;
156 bool m_acknowledgeBit =
false;
158 bool m_acknowledgeError =
false;
160 SEMF_SLOT(m_timemoutSlot,
SoftI2cMaster, *
this, resartConditionSetScl);
162 static constexpr Error::ClassID kSemfClassId = Error::ClassID::SoftI2cMaster;
@ FirstAndLast
start AND stop condition
Interface class for using a GPIO pin of the microcontroller.
For using the I2C in master mode.
This class used two GPIOs (SCL and SDA) and a Timer and implements a software I2C Master interface.
void stopWrite() override
virtual ~SoftI2cMaster()=default
SoftI2cMaster(Gpio &scl, Gpio &sda, app::Timer &timer)
Constructor.
SoftI2cMaster(const SoftI2cMaster &other)=delete
void writeHardware(const uint8_t data[], size_t size) override
Hardware will write data. After finished write operation, onDataWritten() function will be called.
void readHardware(uint8_t buffer[], size_t bufferSize) override
Hardware will read data. After finished read operation, onDataAvailable() function will be called.
ErrorCode
Error IDs for this class. Error ID identify a unique error() / onError call (excluding transferring).
Class for using timer hardware.