14 #define __attribute__(a) 31 #define DEF_CI2C_NB_RETRIES 3 32 #define DEF_CI2C_TIMEOUT 100 78 typedef bool (*
ci2c_fct_ptr) (
void*,
const uint16_t, uint8_t*,
const uint16_t);
205 I2C_STATUS
I2C_write(
I2C_SLAVE * slave,
const uint16_t reg_addr, uint8_t * data,
const uint16_t bytes);
225 I2C_STATUS
I2C_read(
I2C_SLAVE * slave,
const uint16_t reg_addr, uint8_t * data,
const uint16_t bytes);
261 bool I2C_wr8(
const uint8_t dat);
267 uint8_t
I2C_rd8(
const bool ack);
#define __attribute__(a)
GCC attribute (ignored by Doxygen)
Definition: ci2c.h:14
enum enI2C_SPEED I2C_SPEED
bool I2C_slave_get_reg_size(const I2C_SLAVE *slave)
Get I2C register map size (for access)
Definition: ci2c.h:147
I2C OK.
Definition: ci2c.h:62
void I2C_slave_init(I2C_SLAVE *slave, const uint8_t sl_addr, const I2C_INT_SIZE reg_sz)
Init an I2C slave structure for cMI2C communication.
Definition: ci2c.c:61
struct StructI2CSlave I2C_SLAVE
uint8_t I2C_slave_get_addr(const I2C_SLAVE *slave)
Get I2C slave address.
Definition: ci2c.h:139
uint16_t I2C_slave_get_reg_addr(const I2C_SLAVE *slave)
Get I2C current register address (addr may passed this way in procedures if contigous accesses) ...
Definition: ci2c.h:155
uint8_t addr
Slave address.
Definition: ci2c.h:90
I2C Bus busy.
Definition: ci2c.h:63
I2C rw bit (write)
Definition: ci2c.h:40
uint16_t reg_addr
Internal current register address.
Definition: ci2c.h:95
ci2c_fct_ptr rd
Slave read function pointer.
Definition: ci2c.h:93
I2C Standard (100KHz)
Definition: ci2c.h:50
bool I2C_slave_set_reg_size(I2C_SLAVE *slave, const I2C_INT_SIZE reg_sz)
Change I2C registers map size (for access)
Definition: ci2c.c:100
Slave internal address registers space is 8bits wide.
Definition: ci2c.h:73
struct StructI2CSlave::@2 cfg
uint16_t timeout
i2c timeout (ms)
Definition: ci2c.c:43
bool I2C_start(void)
Send start condition.
Definition: ci2c.c:283
I2C rw bit (read)
Definition: ci2c.h:41
I2C_STATUS I2C_read(I2C_SLAVE *slave, const uint16_t reg_addr, uint8_t *data, const uint16_t bytes)
This function reads data from the address specified and stores this data in the area provided by the ...
Definition: ci2c.c:262
enI2C_STATUS
I2C slave status.
Definition: ci2c.h:61
enI2C_SPEED
I2C bus speed.
Definition: ci2c.h:49
enum enI2C_STATUS I2C_STATUS
uint8_t I2C_rd8(const bool ack)
Receive byte from bus.
Definition: ci2c.c:340
uint16_t I2C_set_speed(const uint16_t speed)
Change I2C frequency.
Definition: ci2c.c:168
uint8_t I2C_set_retries(const uint8_t retries)
Change I2C message retries (in case of failure)
Definition: ci2c.c:199
Internal address registers not applicable for slave.
Definition: ci2c.h:72
void I2C_init(const uint16_t speed)
Enable I2c module on arduino board (including pull-ups, enabling of ACK, and setting clock frequency)...
Definition: ci2c.c:122
I2C_STATUS I2C_read_next(I2C_SLAVE *slave, uint8_t *data, const uint16_t bytes)
This inline is a wrapper to I2C_read in case of contigous operations.
Definition: ci2c.h:234
uint16_t I2C_set_timeout(const uint16_t timeout)
Change I2C ack timeout.
Definition: ci2c.c:188
void I2C_slave_set_rw_func(I2C_SLAVE *slave, const ci2c_fct_ptr func, const I2C_RW rw)
Redirect slave I2C read/write function (if needed for advanced use)
Definition: ci2c.c:77
bool(* ci2c_fct_ptr)(void *, const uint16_t, uint8_t *, const uint16_t)
i2c read/write function pointer typedef
Definition: ci2c.h:78
I2C_STATUS I2C_write_next(I2C_SLAVE *slave, uint8_t *data, const uint16_t bytes)
This inline is a wrapper to I2C_write in case of contigous operations.
Definition: ci2c.h:214
bool I2C_sndAddr(I2C_SLAVE *slave, const I2C_RW rw)
Send I2C address.
Definition: ci2c.c:360
void I2C_uninit()
Disable I2c module on arduino board (releasing pull-ups, and TWI control)
Definition: ci2c.c:139
I2C Not Acknowledge.
Definition: ci2c.h:64
ci2c slave config and control parameters
Definition: ci2c.h:85
I2C_STATUS status
Status of the last communications.
Definition: ci2c.h:96
I2C_INT_SIZE reg_size
Slave internal registers size.
Definition: ci2c.h:91
bool I2C_stop(void)
Send stop condition.
Definition: ci2c.c:301
ci2c_fct_ptr wr
Slave write function pointer.
Definition: ci2c.h:92
enum enI2C_INT_SIZE I2C_INT_SIZE
I2C High Speed (3.4MHz): will set speed to Fast Mode (up to 400KHz on avr)
Definition: ci2c.h:53
void I2C_reset(void)
I2C bus reset (Release SCL and SDA lines and re-enable module)
Definition: ci2c.c:157
I2C Fast mode + (1MHz): will set speed to Fast Mode (up to 400KHz on avr)
Definition: ci2c.h:52
I2C Fast Mode (400KHz)
Definition: ci2c.h:51
bool I2C_is_busy(void)
Get I2C busy status.
Definition: ci2c.c:209
I2C_SPEED speed
i2c bus speed
Definition: ci2c.c:41
bool I2C_wr8(const uint8_t dat)
Send byte on bus.
Definition: ci2c.c:317
Slave internal address registers space is 16bits wide.
Definition: ci2c.h:74
enI2C_RW
I2C RW bit enumeration.
Definition: ci2c.h:39
enI2C_INT_SIZE
I2C slave internal address registers size.
Definition: ci2c.h:71
uint8_t retries
i2c message retries when fail
Definition: ci2c.c:42
bool I2C_slave_set_addr(I2C_SLAVE *slave, const uint8_t sl_addr)
Change I2C slave address.
Definition: ci2c.c:88
I2C_STATUS I2C_write(I2C_SLAVE *slave, const uint16_t reg_addr, uint8_t *data, const uint16_t bytes)
This function writes the provided data to the address specified.
Definition: ci2c.c:251