Slave Device
Overview of basic functions for I2C communication with Feelix.
Define the address of the slave and index. The index should correspond to the position in the slaves array in the master code uint8_t slaves[] = { SLAVE_0_ADDRESS }
#define SLAVE_0_ADDRESS 0x70
#define SLAVE_INDEX 0Initialization
Initialize Feelix as slave device after Feelix.init() in void setup()
/* initialize Feelix as slave device*/
feelix.init_I2C_Slave(
SLAVE_0_ADDRESS, //address of slave device
SLAVE_INDEX, //index of slave defined in initializer master device (uint8_t slaves[])
&callback_I2C_Request, //callback that fires when master requests data
DEBUG, //(optional)
// bool debug (set to false before production)
callbackArr, //(optional)
// array with callback functions (functionPtr)
callbackLength); //(optional)
// size of arrayInitialize Feelix as slave device after Feelix.init() in void setup()
/* initialize Feelix as slave device*/
feelix.init_I2C_Master(
slaves[], //index of slave defined in initializer master device (uint8_t slaves[])
CLOCK_SPEED::SLOW_MODE, //Clock frequency
&callback_I2C_Request, //callback that fires when master requests data
DEBUG, //(optional)
// bool debug (set to false before production)
callbackArr, //(optional)
// array with callback functions (functionPtr)
callbackLength); //(optional)
// size of arrayReply to master
Reply with device parameters on master request
Receive data from master
Create callback functions to receive data from master
Create callback array to store all callbacks. The master can use the index of the callback function in the array to trigger a specific callback on the slave side.
Last updated
Was this helpful?
