#include <I2C_Class.hpp>
|
void | setPort (i2c_port_t port_num, int pin_sda, int pin_scl) |
|
bool | begin (i2c_port_t port_num, int pin_sda, int pin_scl) |
|
bool | begin (void) |
|
bool | release (void) const |
|
bool | start (std::uint8_t address, bool read, std::uint32_t freq) const |
|
bool | restart (std::uint8_t address, bool read, std::uint32_t freq) const |
|
bool | stop (void) const |
|
bool | write (std::uint8_t data) const |
|
bool | write (const std::uint8_t *data, std::size_t length) const |
|
bool | read (std::uint8_t *result, std::size_t length) const |
|
bool | writeRegister (std::uint8_t address, std::uint8_t reg, const std::uint8_t *data, std::size_t length, std::uint32_t freq) const |
|
bool | readRegister (std::uint8_t address, std::uint8_t reg, std::uint8_t *result, std::size_t length, std::uint32_t freq) const |
|
bool | writeRegister8 (std::uint8_t address, std::uint8_t reg, std::uint8_t data, std::uint32_t freq) const |
|
std::uint8_t | readRegister8 (std::uint8_t address, std::uint8_t reg, std::uint32_t freq) const |
|
bool | bitOn (std::uint8_t address, std::uint8_t reg, std::uint8_t data, std::uint32_t freq) const |
|
bool | bitOff (std::uint8_t address, std::uint8_t reg, std::uint8_t data, std::uint32_t freq) const |
|
void | scanID (bool *result) const |
|
i2c_port_t | getPort (void) const |
|
int8_t | getSDA (void) const |
|
int8_t | getSCL (void) const |
|
bool | isEnabled (void) const |
|
Definition at line 19 of file I2C_Class.hpp.
◆ begin() [1/2]
bool m5::I2C_Class::begin |
( |
i2c_port_t |
port_num, |
|
|
int |
pin_sda, |
|
|
int |
pin_scl |
|
) |
| |
setup and begin I2C peripheral. (No communication is performed.)
- Parameters
-
port_num | I2C number. (I2C_NUM_0 or I2C_NUM_1). |
pin_sda | SDA pin number. |
pin_scl | SCL pin number. |
- Returns
- success(true) or failed(false).
Definition at line 21 of file I2C_Class.cpp.
◆ begin() [2/2]
bool m5::I2C_Class::begin |
( |
void |
| ) |
|
begin I2C peripheral. (No communication is performed.)
- Returns
- success(true) or failed(false).
Definition at line 27 of file I2C_Class.cpp.
◆ bitOff()
bool m5::I2C_Class::bitOff |
( |
std::uint8_t |
address, |
|
|
std::uint8_t |
reg, |
|
|
std::uint8_t |
data, |
|
|
std::uint32_t |
freq |
|
) |
| const |
Write a 1-byte value to the register by bit erase operation. Performs a series of communications from START to STOP.
- Parameters
-
address | slave addr. |
reg | register number. |
data | erase bit data. |
- Returns
- success(true) or failed(false).
Definition at line 95 of file I2C_Class.cpp.
◆ bitOn()
bool m5::I2C_Class::bitOn |
( |
std::uint8_t |
address, |
|
|
std::uint8_t |
reg, |
|
|
std::uint8_t |
data, |
|
|
std::uint32_t |
freq |
|
) |
| const |
Write a 1-byte value to the register by bit add operation. Performs a series of communications from START to STOP.
- Parameters
-
address | slave addr. |
reg | register number. |
data | add bit data. |
- Returns
- success(true) or failed(false).
Definition at line 90 of file I2C_Class.cpp.
◆ getPort()
i2c_port_t m5::I2C_Class::getPort |
( |
void |
| ) |
const |
|
inline |
◆ getSCL()
int8_t m5::I2C_Class::getSCL |
( |
void |
| ) |
const |
|
inline |
◆ getSDA()
int8_t m5::I2C_Class::getSDA |
( |
void |
| ) |
const |
|
inline |
◆ isEnabled()
bool m5::I2C_Class::isEnabled |
( |
void |
| ) |
const |
|
inline |
◆ read()
bool m5::I2C_Class::read |
( |
std::uint8_t * |
result, |
|
|
std::size_t |
length |
|
) |
| const |
Receive multiple bytes of data.
- Parameters
-
[out] | result | read data array. |
| length | data array length. |
- Returns
- success(true) or failed(false).
Definition at line 62 of file I2C_Class.cpp.
◆ readRegister()
bool m5::I2C_Class::readRegister |
( |
std::uint8_t |
address, |
|
|
std::uint8_t |
reg, |
|
|
std::uint8_t * |
result, |
|
|
std::size_t |
length, |
|
|
std::uint32_t |
freq |
|
) |
| const |
Read multiple bytes value from the register. Performs a series of communications from START to STOP.
- Parameters
-
| address | slave addr. |
| reg | register number. |
[out] | result | read data array. |
| length | data array length. |
- Returns
- success(true) or failed(false).
Definition at line 75 of file I2C_Class.cpp.
◆ readRegister8()
std::uint8_t m5::I2C_Class::readRegister8 |
( |
std::uint8_t |
address, |
|
|
std::uint8_t |
reg, |
|
|
std::uint32_t |
freq |
|
) |
| const |
Read a 1-byte value from the register. Performs a series of communications from START to STOP.
- Parameters
-
address | slave addr. |
reg | register number. |
- Returns
- read value.
Definition at line 85 of file I2C_Class.cpp.
◆ release()
bool m5::I2C_Class::release |
( |
void |
| ) |
const |
release I2C peripheral.
- Returns
- success(true) or failed(false).
Definition at line 32 of file I2C_Class.cpp.
◆ restart()
bool m5::I2C_Class::restart |
( |
std::uint8_t |
address, |
|
|
bool |
read, |
|
|
std::uint32_t |
freq |
|
) |
| const |
Sends the I2C repeated start condition and the address of the slave.
- Parameters
-
address | slave addr. |
read | bit of read flag. true=read / false=write. |
- Returns
- success(true) or failed(false).
Definition at line 42 of file I2C_Class.cpp.
◆ scanID()
void m5::I2C_Class::scanID |
( |
bool * |
result | ) |
const |
execute I2C scan. (for 7bit address)
- Parameters
-
[out] | result | data array needs 120 Bytes. |
Definition at line 100 of file I2C_Class.cpp.
◆ setPort()
void m5::I2C_Class::setPort |
( |
i2c_port_t |
port_num, |
|
|
int |
pin_sda, |
|
|
int |
pin_scl |
|
) |
| |
setup I2C port parameters. (No begin)
- Parameters
-
port_num | I2C number. (I2C_NUM_0 or I2C_NUM_1). |
pin_sda | SDA pin number. |
pin_scl | SCL pin number. |
Definition at line 13 of file I2C_Class.cpp.
◆ start()
bool m5::I2C_Class::start |
( |
std::uint8_t |
address, |
|
|
bool |
read, |
|
|
std::uint32_t |
freq |
|
) |
| const |
Sends the I2C start condition and the address of the slave.
- Parameters
-
address | slave addr. |
read | bit of read flag. true=read / false=write. |
- Returns
- success(true) or failed(false).
Definition at line 37 of file I2C_Class.cpp.
◆ stop()
bool m5::I2C_Class::stop |
( |
void |
| ) |
const |
Sends the I2C stop condition. If an ACK error occurs, return false.
- Returns
- success(true) or failed(false).
Definition at line 47 of file I2C_Class.cpp.
◆ write() [1/2]
bool m5::I2C_Class::write |
( |
const std::uint8_t * |
data, |
|
|
std::size_t |
length |
|
) |
| const |
Send multiple bytes of data.
- Parameters
-
[in] | data | write data array. |
| length | data array length. |
- Returns
- success(true) or failed(false).
◆ write() [2/2]
bool m5::I2C_Class::write |
( |
std::uint8_t |
data | ) |
const |
Send 1 byte of data.
- Parameters
-
- Returns
- success(true) or failed(false).
Definition at line 52 of file I2C_Class.cpp.
◆ writeRegister()
bool m5::I2C_Class::writeRegister |
( |
std::uint8_t |
address, |
|
|
std::uint8_t |
reg, |
|
|
const std::uint8_t * |
data, |
|
|
std::size_t |
length, |
|
|
std::uint32_t |
freq |
|
) |
| const |
Write multiple bytes value to the register. Performs a series of communications from START to STOP.
- Parameters
-
| address | slave addr. |
| reg | register number. |
[in] | data | write data array. |
| length | data array length. |
- Returns
- success(true) or failed(false).
Definition at line 67 of file I2C_Class.cpp.
◆ writeRegister8()
bool m5::I2C_Class::writeRegister8 |
( |
std::uint8_t |
address, |
|
|
std::uint8_t |
reg, |
|
|
std::uint8_t |
data, |
|
|
std::uint32_t |
freq |
|
) |
| const |
Write a 1-byte value to the register. Performs a series of communications from START to STOP.
- Parameters
-
address | slave addr. |
reg | register number. |
data | write data. |
- Returns
- success(true) or failed(false).
Definition at line 80 of file I2C_Class.cpp.
The documentation for this class was generated from the following files: