semf
semf::I2cScanner Class Reference

This class scans a given address range on an I2C master hardware to identify available devices. More...

#include <i2cscanner.h>

Collaboration diagram for semf::I2cScanner:
Collaboration graph

Public Types

enum class  ErrorCode : uint8_t { StartScan_IsBusy = 0 }
 Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring). More...
 

Public Member Functions

 I2cScanner (I2cMasterHardware &hardware)
 Constructor. More...
 
 I2cScanner (const I2cScanner &other)=delete
 
virtual ~I2cScanner ()=default
 
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, the deviceFound signal including the address of the found device is emitted. After all addresses are tested, the finished signal is emitted. More...
 

Public Attributes

Signal< uint16_t > deviceFound
 
Signal finished
 
Signal< Errorerror
 

Detailed Description

This class scans a given address range on an I2C master hardware to identify available devices.

This is done by setting an empty write command to every address and evaluating the I2cMasterHardware dataWritten and error signal.

startScan() function call will start the scan process. For every available device, the deviceFound signal is emitted. After the total address range is tested, the finished signal is emitted.

See also
I2cScannerPrinter

Definition at line 31 of file i2cscanner.h.

Member Enumeration Documentation

◆ ErrorCode

enum class semf::I2cScanner::ErrorCode : uint8_t
strong

Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring).

Enumerator
StartScan_IsBusy 

Definition at line 37 of file i2cscanner.h.

Constructor & Destructor Documentation

◆ I2cScanner() [1/2]

semf::I2cScanner::I2cScanner ( I2cMasterHardware hardware)
explicit

Constructor.

Parameters
hardwareI2C communication hardware to scan on.

Definition at line 15 of file i2cscanner.cpp.

◆ I2cScanner() [2/2]

semf::I2cScanner::I2cScanner ( const I2cScanner other)
explicitdelete

◆ ~I2cScanner()

virtual semf::I2cScanner::~I2cScanner ( )
virtualdefault

Member Function Documentation

◆ startScan()

void semf::I2cScanner::startScan ( uint16_t  firstAddress = 0,
uint16_t  lastAddress = 0x7F 
)

Starts scan process for the address range from firstAddress to lastAddress. For all found devices, the deviceFound signal including the address of the found device is emitted. After all addresses are tested, the finished signal is emitted.

Parameters
firstAddressFirst I2C address of the address range to get tested.
lastAddressLast I2C address of the address range to get tested.
Exceptions
StartScan_IsBusyIf this is allready scanning.

Definition at line 20 of file i2cscanner.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ deviceFound

Signal<uint16_t> semf::I2cScanner::deviceFound

Signal is emitted after an device is found while scanning. The signal delivers the I2C address of the found device.

Definition at line 61 of file i2cscanner.h.

◆ error

Signal<Error> semf::I2cScanner::error

Signal is emitted if startScan() function is called and I2C hardware is busy.

Definition at line 65 of file i2cscanner.h.

◆ finished

Signal semf::I2cScanner::finished

Signal is emitted after all addresses in the given address range by startScan() function are tested.

Definition at line 63 of file i2cscanner.h.