|
| | master_bus (enum port port, gpio sda, gpio scl, freq::hertz frequency) |
| | Creates a new I2C master bus.
|
| |
| | ~master_bus () |
| |
| | master_bus (const master_bus &)=delete |
| |
| master_bus & | operator= (const master_bus &)=delete |
| |
| | master_bus (master_bus &&)=delete |
| |
| master_bus & | operator= (master_bus &&)=delete |
| |
| void | lock () const |
| | Acquires exclusive access to the bus.
|
| |
| bool | try_lock () const noexcept |
| | Tries to acquire exclusive access without blocking.
|
| |
| void | unlock () const |
| | Releases exclusive access to the bus.
|
| |
| i2c_master_bus_handle_t | handle () const |
| | Returns the underlying ESP-IDF bus handle.
|
| |
| enum port | port () const |
| | Returns the I2C port.
|
| |
| freq::hertz | frequency () const |
| | Returns the bus clock frequency in Hz.
|
| |
| std::vector< uint8_t > | scan_devices () const |
| | Scans for devices on the bus.
|
| |
| template<typename Rep , typename Period > |
| std::vector< uint8_t > | scan_devices (const std::chrono::duration< Rep, Period > &timeout) const |
| | Scans for devices on the bus.
|
| |
| void | probe (uint8_t address) const |
| | Probes for a device at the specified address.
|
| |
| template<typename Rep , typename Period > |
| void | probe (uint8_t address, const std::chrono::duration< Rep, Period > &timeout) const |
| | Probes for a device at the specified address.
|
| |
| result< void > | try_probe (uint8_t address) const |
| | Probes for a device at the specified address.
|
| |
| template<typename Rep , typename Period > |
| result< void > | try_probe (uint8_t address, const std::chrono::duration< Rep, Period > &timeout) const |
| | Probes for a device at the specified address.
|
| |
I2C master bus controller with thread-safe device access.
Represents an I2C bus operating in master mode. Satisfies the Lockable named requirement for use with std::lock_guard and std::unique_lock.
Definition at line 64 of file master.hpp.
template<typename Rep , typename Period >
| void idfxx::i2c::master_bus::probe |
( |
uint8_t |
address, |
|
|
const std::chrono::duration< Rep, Period > & |
timeout |
|
) |
| const |
|
inline |
Probes for a device at the specified address.
- Parameters
-
| address | 7-bit device address. |
| timeout | Maximum time to wait for response. |
- Note
- Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
- Exceptions
-
| std::system_error | if the device does not acknowledge or on error. |
Definition at line 163 of file master.hpp.
References idfxx::timeout, and idfxx::unwrap().
template<typename Rep , typename Period >
| std::vector< uint8_t > idfxx::i2c::master_bus::scan_devices |
( |
const std::chrono::duration< Rep, Period > & |
timeout | ) |
const |
|
inline |
Scans for devices on the bus.
Probes addresses 0x08-0x77 and returns those that acknowledge.
- Parameters
-
| timeout | Maximum time to wait for each probe. |
- Returns
- Addresses of responding devices.
Definition at line 138 of file master.hpp.
References idfxx::timeout.