semf
i2cscanner.h
Go to the documentation of this file.
1
10#ifndef SEMF_COMMUNICATION_I2CSCANNER_H_
11#define SEMF_COMMUNICATION_I2CSCANNER_H_
12
15
16namespace semf
17{
32{
33public:
37 enum class ErrorCode : uint8_t
38 {
39 StartScan_IsBusy = 0
40 };
41
46 explicit I2cScanner(I2cMasterHardware& hardware);
47 explicit I2cScanner(const I2cScanner& other) = delete;
48 virtual ~I2cScanner() = default;
49
58 void startScan(uint16_t firstAddress = 0, uint16_t lastAddress = 0x7F);
59
66
67private:
72 void testAddress();
77 void onI2cAcknowledge();
82 void onI2cNotAcknowledge(Error thrown);
83
85 I2cMasterHardware& m_hardware;
87 uint16_t m_addressBegin = 0;
89 uint16_t m_addressEnd = 0;
91 uint16_t m_addressIterator = 0;
93 SEMF_SLOT(m_onI2cAcknowledgeSlot, I2cScanner, *this, onI2cAcknowledge);
95 SEMF_SLOT(m_onI2cNotAcknowledgeSlot, I2cScanner, *this, onI2cNotAcknowledge, Error);
97 static constexpr Error::ClassID kSemfClassId = Error::ClassID::I2cScanner;
98};
99} /* namespace semf */
100#endif /* SEMF_COMMUNICATION_I2CSCANNER_H_ */
Class for representing errors. Every error should have a unique source code. As a user feel encourage...
Definition: error.h:22
ClassID
Semf class IDs.
Definition: error.h:28
For using the I2C in master mode.
This class scans a given address range on an I2C master hardware to identify available devices.
Definition: i2cscanner.h:32
I2cScanner(I2cMasterHardware &hardware)
Constructor.
Definition: i2cscanner.cpp:15
ErrorCode
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring...
Definition: i2cscanner.h:38
Signal< uint16_t > deviceFound
Definition: i2cscanner.h:61
void startScan(uint16_t firstAddress=0, uint16_t lastAddress=0x7F)
Starts scan process for the address range from firstAddress to lastAddress. For all found devices,...
Definition: i2cscanner.cpp:20
Signal< Error > error
Definition: i2cscanner.h:65
I2cScanner(const I2cScanner &other)=delete
virtual ~I2cScanner()=default