M5Unified
m5::I2C_Class Class Reference

#include <I2C_Class.hpp>

Public Member Functions

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
 

Detailed Description

Definition at line 19 of file I2C_Class.hpp.

Member Function Documentation

◆ 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_numI2C number. (I2C_NUM_0 or I2C_NUM_1).
pin_sdaSDA pin number.
pin_sclSCL pin number.
Returns
success(true) or failed(false).

Definition at line 21 of file I2C_Class.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ 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
addressslave addr.
regregister number.
dataerase bit data.
Returns
success(true) or failed(false).

Definition at line 95 of file I2C_Class.cpp.

Here is the caller graph for this function:

◆ 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
addressslave addr.
regregister number.
dataadd bit data.
Returns
success(true) or failed(false).

Definition at line 90 of file I2C_Class.cpp.

Here is the caller graph for this function:

◆ getPort()

i2c_port_t m5::I2C_Class::getPort ( void  ) const
inline

Definition at line 126 of file I2C_Class.hpp.

Here is the caller graph for this function:

◆ getSCL()

int8_t m5::I2C_Class::getSCL ( void  ) const
inline

Definition at line 128 of file I2C_Class.hpp.

Here is the caller graph for this function:

◆ getSDA()

int8_t m5::I2C_Class::getSDA ( void  ) const
inline

Definition at line 127 of file I2C_Class.hpp.

Here is the caller graph for this function:

◆ isEnabled()

bool m5::I2C_Class::isEnabled ( void  ) const
inline

Definition at line 130 of file I2C_Class.hpp.

◆ read()

bool m5::I2C_Class::read ( std::uint8_t *  result,
std::size_t  length 
) const

Receive multiple bytes of data.

Parameters
[out]resultread data array.
lengthdata array length.
Returns
success(true) or failed(false).

Definition at line 62 of file I2C_Class.cpp.

Here is the caller graph for this function:

◆ 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
addressslave addr.
regregister number.
[out]resultread data array.
lengthdata array length.
Returns
success(true) or failed(false).

Definition at line 75 of file I2C_Class.cpp.

Here is the caller graph for this function:

◆ 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
addressslave addr.
regregister number.
Returns
read value.

Definition at line 85 of file I2C_Class.cpp.

Here is the caller graph for this function:

◆ 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
addressslave addr.
readbit of read flag. true=read / false=write.
Returns
success(true) or failed(false).

Definition at line 42 of file I2C_Class.cpp.

Here is the call graph for this function:

◆ scanID()

void m5::I2C_Class::scanID ( bool *  result) const

execute I2C scan. (for 7bit address)

Parameters
[out]resultdata array needs 120 Bytes.

Definition at line 100 of file I2C_Class.cpp.

Here is the call graph for this function:

◆ 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_numI2C number. (I2C_NUM_0 or I2C_NUM_1).
pin_sdaSDA pin number.
pin_sclSCL pin number.

Definition at line 13 of file I2C_Class.cpp.

Here is the caller graph for this function:

◆ 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
addressslave addr.
readbit of read flag. true=read / false=write.
Returns
success(true) or failed(false).

Definition at line 37 of file I2C_Class.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ 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]datawrite data array.
lengthdata 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
datawrite data.
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
addressslave addr.
regregister number.
[in]datawrite data array.
lengthdata array length.
Returns
success(true) or failed(false).

Definition at line 67 of file I2C_Class.cpp.

Here is the caller graph for this function:

◆ 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
addressslave addr.
regregister number.
datawrite data.
Returns
success(true) or failed(false).

Definition at line 80 of file I2C_Class.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: