8#ifndef __WIREWRAPPER_H__
9 #define __WIREWRAPPER_H__
14 #define __attribute__(a)
17#if defined(__AVR_ATtiny25__) | defined(__AVR_ATtiny45__) | defined(__AVR_ATtiny85__) | defined(__AVR_AT90Tiny26__) | defined(__AVR_ATtiny26__)
35#define DEF_CI2C_NB_RETRIES 3
36#define DEF_CI2C_TIMEOUT 100
60#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ESP8266_ESP01)
85typedef bool (*
ci2c_fct_ptr) (
void*,
const uint16_t, uint8_t*,
const uint16_t);
184 #if !defined(__TINY__) && !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ESP8266_ESP01) && !defined(ARDUINO_ARCH_ESP32)
I2C_SPEED speed
i2c bus speed
Definition WireWrapper.cpp:22
uint8_t retries
i2c message retries when fail
Definition WireWrapper.cpp:23
uint16_t timeout
i2c timeout (ms)
Definition WireWrapper.cpp:24
enum enI2C_INT_SIZE I2C_INT_SIZE
uint8_t I2C_slave_get_addr(const I2C_SLAVE *slave)
Get I2C slave address.
Definition WireWrapper.h:146
enum enI2C_SPEED I2C_SPEED
struct StructI2CSlave I2C_SLAVE
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 WireWrapper.h:162
bool I2C_slave_set_reg_size(I2C_SLAVE *slave, const I2C_INT_SIZE reg_sz)
Change I2C registers map size (for access)
Definition WireWrapper.cpp:81
enI2C_SPEED
I2C bus speed.
Definition WireWrapper.h:53
@ I2C_HS
I2C High Speed (3.4MHz)
Definition WireWrapper.h:57
@ I2C_FMP
I2C Fast mode + (1MHz)
Definition WireWrapper.h:56
@ I2C_STD
I2C Standard (100KHz)
Definition WireWrapper.h:54
@ I2C_FM
I2C Fast Mode (400KHz)
Definition WireWrapper.h:55
enI2C_STATUS
I2C slave status.
Definition WireWrapper.h:68
@ I2C_BUSY
I2C Bus busy.
Definition WireWrapper.h:70
@ I2C_NACK
I2C Not Acknowledge.
Definition WireWrapper.h:71
@ I2C_OK
I2C OK.
Definition WireWrapper.h:69
void I2C_uninit()
Disable I2c module on arduino board (releasing pull-ups, and TWI control)
Definition WireWrapper.h:182
uint16_t I2C_set_speed(const uint16_t speed)
Change I2C frequency.
Definition WireWrapper.cpp:113
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 WireWrapper.cpp:196
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 WireWrapper.cpp:58
#define __attribute__(a)
GCC attribute (ignored by Doxygen)
Definition WireWrapper.h:14
enI2C_RW
I2C RW bit enumeration.
Definition WireWrapper.h:43
@ I2C_READ
I2C rw bit (read)
Definition WireWrapper.h:45
@ I2C_WRITE
I2C rw bit (write)
Definition WireWrapper.h:44
enI2C_INT_SIZE
I2C slave internal address registers size.
Definition WireWrapper.h:78
@ I2C_NO_REG
Internal address registers not applicable for slave.
Definition WireWrapper.h:79
@ I2C_8B_REG
Slave internal address registers space is 8bits wide.
Definition WireWrapper.h:80
@ I2C_16B_REG
Slave internal address registers space is 16bits wide.
Definition WireWrapper.h:81
void I2C_init(const uint16_t speed)
Enable I2c module on arduino board (including pull-ups, enabling of ACK, and setting clock frequency)
Definition WireWrapper.cpp:103
bool I2C_is_busy(void)
Get I2C busy status.
Definition WireWrapper.cpp:154
bool I2C_slave_get_reg_size(const I2C_SLAVE *slave)
Get I2C register map size (for access)
Definition WireWrapper.h:154
uint16_t I2C_set_timeout(const uint16_t timeout)
Change I2C ack timeout.
Definition WireWrapper.cpp:133
bool I2C_slave_set_addr(I2C_SLAVE *slave, const uint8_t sl_addr)
Change I2C slave address.
Definition WireWrapper.cpp:69
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 WireWrapper.cpp:207
uint8_t I2C_set_retries(const uint8_t retries)
Change I2C message retries (in case of failure)
Definition WireWrapper.cpp:144
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 WireWrapper.h:228
enum enI2C_STATUS I2C_STATUS
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 WireWrapper.cpp:42
bool(* ci2c_fct_ptr)(void *, const uint16_t, uint8_t *, const uint16_t)
i2c read/write function pointer typedef
Definition WireWrapper.h:85
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 WireWrapper.h:248
ci2c slave config and control parameters
Definition WireWrapper.h:92
I2C_INT_SIZE reg_size
Slave internal registers size.
Definition WireWrapper.h:98
uint16_t reg_addr
Internal current register address.
Definition WireWrapper.h:102
ci2c_fct_ptr rd
Slave read function pointer.
Definition WireWrapper.h:100
ci2c_fct_ptr wr
Slave write function pointer.
Definition WireWrapper.h:99
uint8_t addr
Slave address.
Definition WireWrapper.h:97
I2C_STATUS status
Status of the last communications.
Definition WireWrapper.h:103
struct StructI2CSlave::@076007147036367262217310042054352022123346340177 cfg