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,
122 return protocore_platform_i2c_set_clock(bus, hz) != 0;
183 return protocore_platform_i2c_recover(bus, sda, scl) != 0;
237 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
#define PROTOCORE_INLINE
Linkage for a leaf primitive whose body is cheaper than the call that reaches it.
PROTOCORE_INLINE proto_bool protocore_i2c_probe_on(uint8_t bus, uint16_t addr)
PROTOCORE_INLINE proto_bool protocore_i2c_write_on(uint8_t bus, uint16_t addr, const uint8_t *buf, size_t len)
PROTOCORE_INLINE proto_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)
PROTOCORE_INLINE proto_bool protocore_i2c_set_clock_on(uint8_t bus, uint32_t hz)
PROTOCORE_INLINE proto_bool protocore_i2c_write(uint16_t addr, const uint8_t *buf, size_t len)
#define PROTOCORE_I2C_TIMEOUT_MS
Per-transfer timeout in milliseconds.
PROTOCORE_INLINE proto_bool protocore_i2c_write_read(uint16_t addr, const uint8_t *w, size_t wlen, uint8_t *r, size_t rlen)
PROTOCORE_INLINE proto_bool protocore_i2c_general_call(const uint8_t *buf, size_t len)
PROTOCORE_BEGIN_DECLS PROTOCORE_INLINE proto_bool protocore_i2c_begin_on(uint8_t bus, int sda, int scl, uint32_t hz)
PROTOCORE_INLINE proto_bool protocore_i2c_begin(void)
#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.
PROTOCORE_INLINE proto_bool protocore_i2c_read(uint16_t addr, uint8_t *buf, size_t len)
PROTOCORE_INLINE proto_bool protocore_i2c_read_on(uint8_t bus, uint16_t addr, uint8_t *buf, size_t len)
#define PROTOCORE_I2C_SCAN_LAST
PROTOCORE_INLINE proto_bool protocore_i2c_recover(void)
PROTOCORE_INLINE proto_bool protocore_i2c_probe(uint16_t addr)
PROTOCORE_INLINE proto_bool protocore_i2c_set_clock(uint32_t hz)
PROTOCORE_INLINE proto_bool protocore_i2c_general_call_on(uint8_t bus, const uint8_t *buf, size_t len)
#define PROTOCORE_I2C_BUS
Controller the plain verbs drive.
PROTOCORE_INLINE size_t protocore_i2c_scan(uint8_t *out, size_t cap)
PROTOCORE_INLINE size_t protocore_i2c_scan_on(uint8_t bus, uint8_t *out, size_t cap)
PROTOCORE_INLINE proto_bool protocore_i2c_recover_on(uint8_t bus, int sda, int scl)
#define PROTO_FALSE
the false value
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTO_TRUE
the true value, spelled so a caller never writes a bare 1
#define PROTOCORE_END_DECLS