29#ifndef PROTOCORE_I2C_H
30#define PROTOCORE_I2C_H
37#ifndef PROTOCORE_I2C_HZ
38#define PROTOCORE_I2C_HZ 100000u
42#ifndef PROTOCORE_I2C_TIMEOUT_MS
43#define PROTOCORE_I2C_TIMEOUT_MS 50u
47#ifndef PROTOCORE_I2C_BUS
48#define PROTOCORE_I2C_BUS 0u
52#define PROTOCORE_I2C_HZ_STANDARD 100000u
53#define PROTOCORE_I2C_HZ_FAST 400000u
54#define PROTOCORE_I2C_HZ_FAST_PLUS 1000000u
57#define PROTOCORE_I2C_ADDR10(a) ((uint16_t)(PROTOCORE_I2C_ADDR_10BIT | ((a) & PROTOCORE_I2C_ADDR_MASK)))
60#define PROTOCORE_I2C_SCAN_FIRST 0x08u
61#define PROTOCORE_I2C_SCAN_LAST 0x77u
70 return protocore_platform_i2c_begin(bus, sda, scl, hz) != 0;
106 uint8_t *r,
size_t rlen)
108 return protocore_platform_i2c_write_read(bus, addr, w, (uint32_t)wlen, r, (uint32_t)rlen,
113EMBED_INLINE embed_bool
protocore_i2c_write_read(uint16_t addr,
const uint8_t *w,
size_t wlen, uint8_t *r,
size_t rlen)
121 return protocore_platform_i2c_set_clock(bus, hz) != 0;
182 return protocore_platform_i2c_recover(bus, sda, scl) != 0;
236 uint8_t *r,
size_t rlen)
#define PROTOCORE_I2C_SDA_PIN
Shared I2C bus pins for the sensor / peripheral drivers (RTC, SHT3x, MPR121, ADS1115,...
#define PROTOCORE_I2C_SCL_PIN
EMBED_INLINE embed_bool protocore_i2c_write_read(uint16_t addr, const uint8_t *w, size_t wlen, uint8_t *r, size_t rlen)
EMBED_INLINE embed_bool protocore_i2c_write_on(uint8_t bus, uint16_t addr, const uint8_t *buf, size_t len)
#define PROTOCORE_I2C_TIMEOUT_MS
Per-transfer timeout in milliseconds.
EMBED_INLINE embed_bool protocore_i2c_recover_on(uint8_t bus, int sda, int scl)
EMBED_INLINE embed_bool protocore_i2c_general_call_on(uint8_t bus, const uint8_t *buf, size_t len)
EMBED_INLINE size_t protocore_i2c_scan_on(uint8_t bus, uint8_t *out, size_t cap)
EMBED_INLINE size_t protocore_i2c_scan(uint8_t *out, size_t cap)
EMBED_INLINE embed_bool protocore_i2c_general_call(const uint8_t *buf, size_t len)
#define PROTOCORE_I2C_HZ
Bus clock for the shared peripheral bus; 100 kHz standard mode.
#define PROTOCORE_I2C_SCAN_FIRST
Lowest and highest 7-bit addresses a scan reports; 0x00 - 0x07 and 0x78 - 0x7F are reserved.
EMBED_INLINE embed_bool protocore_i2c_recover(void)
#define PROTOCORE_I2C_SCAN_LAST
EMBED_INLINE embed_bool protocore_i2c_probe(uint16_t addr)
EMBED_INLINE embed_bool protocore_i2c_write(uint16_t addr, const uint8_t *buf, size_t len)
EMBED_INLINE embed_bool protocore_i2c_read(uint16_t addr, uint8_t *buf, size_t len)
EMBED_BEGIN_DECLS EMBED_INLINE embed_bool protocore_i2c_begin_on(uint8_t bus, int sda, int scl, uint32_t hz)
EMBED_INLINE embed_bool protocore_i2c_read_on(uint8_t bus, uint16_t addr, uint8_t *buf, size_t len)
EMBED_INLINE embed_bool protocore_i2c_write_read_on(uint8_t bus, uint16_t addr, const uint8_t *w, size_t wlen, uint8_t *r, size_t rlen)
EMBED_INLINE embed_bool protocore_i2c_set_clock_on(uint8_t bus, uint32_t hz)
#define PROTOCORE_I2C_BUS
Controller the plain verbs drive.
EMBED_INLINE embed_bool protocore_i2c_set_clock(uint32_t hz)
EMBED_INLINE embed_bool protocore_i2c_begin(void)
EMBED_INLINE embed_bool protocore_i2c_probe_on(uint8_t bus, uint16_t addr)