Mbed OS Reference
Loading...
Searching...
No Matches
Synchronous I2C Hardware Abstraction Layer for slave

Functions

void i2c_slave_mode (i2c_t *obj, int enable_slave)
 Configure I2C as slave or master. More...
 
int i2c_slave_receive (i2c_t *obj)
 Check to see if the I2C slave has been addressed. More...
 
int i2c_slave_read (i2c_t *obj, char *data, int length)
 Read specified number of bytes from an I2C master. More...
 
int i2c_slave_write (i2c_t *obj, const char *data, int length)
 Configure I2C as slave or master. More...
 
void i2c_slave_address (i2c_t *obj, int idx, uint32_t address, uint32_t mask)
 Configure I2C address. More...
 

Detailed Description

Function Documentation

◆ i2c_slave_mode()

void i2c_slave_mode ( i2c_t obj,
int  enable_slave 
)

Configure I2C as slave or master.

Parameters
objThe I2C object
enable_slaveEnable i2c hardware so you can receive events with i2c_slave_receive

◆ i2c_slave_receive()

int i2c_slave_receive ( i2c_t obj)

Check to see if the I2C slave has been addressed.

Parameters
objThe I2C object
Returns
The status - 1 - read addresses, 2 - write to all slaves, 3 write addressed, 0 - the slave has not been addressed

◆ i2c_slave_read()

int i2c_slave_read ( i2c_t obj,
char *  data,
int  length 
)

Read specified number of bytes from an I2C master.

Parameters
objThe I2C object
dataThe buffer for receiving
lengthNumber of bytes to read
Returns
non-zero if a value is available, or zero on error

◆ i2c_slave_write()

int i2c_slave_write ( i2c_t obj,
const char *  data,
int  length 
)

Configure I2C as slave or master.

Parameters
objThe I2C object
dataThe buffer for sending
lengthNumber of bytes to write
Returns
number of bytes actually written to the master, or negative value on error.

◆ i2c_slave_address()

void i2c_slave_address ( i2c_t obj,
int  idx,
uint32_t  address,
uint32_t  mask 
)

Configure I2C address.

Parameters
objThe I2C object
idxCurrently not used
addressThe address to be set (8-bit, always a read address)
maskCurrently not used