pdf-icon

I2C

Using the M5Stack library's encapsulated I2C communication API to access slave devices. Initialization is required through Wire.begin(21, 22); before use. PORT-A pins (G21,G22) are used by default.

writeCommand

Function:

Write a command to a specified slave device.

Syntax:

bool writeCommand(uint8_t address, uint8_t subAddress)

Parameter Type Description
address uint8_t Slave address
subAddress uint8_t Register address

Return Value:

Value Description
true Success
false Failure

writeByte

Function:

Write a byte to a specified register address.

Syntax: bool writeByte(uint8_t address, uint8_t subAddress, uint8_t data)

Parameter Type Description
address uint8_t Slave address
subAddress uint8_t Register address
data uint8_t Data

Return Value:

Value Description
true Success
false Failure

writeBytes

Function:

Write multiple bytes to a specified register address.

Syntax: bool writeBytes(uint8_t address, uint8_t subAddress, uint8_t *data, uint8_t length)

Parameter Type Description
address uint8_t Slave address
subAddress uint8_t Register address
data uint8_t * Pointer to data
length uint8_t Length of data

Return Value:

Value Description
true Success
false Failure

readByte

Function Overloading

Function:

Read a byte from a specified slave address.

Syntax: bool readByte(uint8_t address, uint8_t *result)

Parameter Type Description
address uint8_t Slave address
result uint8_t * Pointer to data

Return Value:

Value Description
true Success
false Failure

Function:

Read a byte from a specified register address.

Syntax:

bool readByte(uint8_t address, uint8_t subAddress, uint8_t *result)

Parameter Type Description
address uint8_t Slave address
subAddress uint8_t Register address
result uint8_t * Pointer to data

Return Value:

Value Description
true Success
false Failure

readBytes

Function Overloading

Function:

Read multiple bytes from a specified slave address.

Syntax:

bool readBytes(uint8_t address, uint8_t count, uint8_t *dest)

Parameter Type Description
address uint8_t Slave address
count uint8_t Number of bytes requested
result uint8_t * Pointer to destination

Return Value:

Value Description
true Success
false Failure

Function:

Read multiple bytes from a specified register address.

Syntax:

bool readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t *dest)

| Parameter |

On This Page