#ifndef _I2C_SLAVE_H #define _I2C_SLAVE_H #include /** * @brief I2c master struct. * * @param i2c_inst Instance i2c master initialized on */ typedef struct i2c_master { i2c_inst_t *i2c_inst; } i2c_master_t; /** * @brief I2c slave struct. * * @param i2c_inst Instance i2c slave initialized on * @param reg Currently pointed register * @param reg_written Communication option * @param buffer Memory buffer for communication */ typedef struct i2c_slave { i2c_inst_t *i2c_inst; uint8_t reg; bool reg_written; uint8_t buffer[256]; } i2c_slave_t; /** * @brief Init an i2c instance as master. * * @param i2c_master Pointer to a i2c master struct * @param i2c_inst Instance to initialise master on */ void init_i2c_master(i2c_master_t *i2c_master, i2c_inst_t *i2c_inst); /** * @brief Reset an i2c master to default settings. * * @param i2c_master Pointer to the i2c master struct to exit */ void exit_i2c_master(i2c_master_t *i2c_master); /** * @brief Init an i2c instance as slave. * * @param i2c_slave Pointer to an i2c slave struct * @param i2c_inst Instance to initialise slave on * @param address The address of the slave */ void init_i2c_slave(i2c_slave_t *i2c_slave, i2c_inst_t *i2c_inst, uint8_t address); /** * @brief Reset an i2c slave to default settings. * * @param i2c_slave Pointer to the i2c slave struct to exit */ void exit_i2c_slave(i2c_slave_t *i2c_slave); #endif // _I2C_SLAVE_H