10#define EXT_I2C_TIMEOUT_MS 3u
12static int32_t
xfer(
void *h, uint16_t reg, uint16_t regsz, uint8_t *d, uint16_t len,
int write)
14 const uint16_t a8 = (uint16_t)((uintptr_t)h << 1);
16 const HAL_StatusTypeDef
st = write
20 return st == HAL_OK ? 0 : -1;
23static int32_t
wr16(
void *h, uint16_t reg,
const uint8_t *d, uint16_t
n) {
return xfer(h, reg, I2C_MEMADD_SIZE_16BIT, (uint8_t *)d,
n, 1); }
24static int32_t
rd16(
void *h, uint16_t reg, uint8_t *d, uint16_t
n) {
return xfer(h, reg, I2C_MEMADD_SIZE_16BIT, d,
n, 0); }
25static int32_t
wr8(
void *h, uint8_t reg,
const uint8_t *d, uint16_t
n) {
return xfer(h, reg, I2C_MEMADD_SIZE_8BIT, (uint8_t *)d,
n, 1); }
26static int32_t
rd8(
void *h, uint8_t reg, uint8_t *d, uint16_t
n) {
return xfer(h, reg, I2C_MEMADD_SIZE_8BIT, d,
n, 0); }
27static void dly(uint32_t
ms) { osDelay(
ms); }
31 b->write =
wr16;
b->read =
rd16;
b->delay_ms =
dly;
b->handle = (
void *)(uintptr_t)addr7;
36 b->write =
wr8;
b->read =
rd8;
b->delay_ms =
dly;
b->handle = (
void *)(uintptr_t)addr7;
#define EXT_I2C_TIMEOUT_MS
void ext_i2c_flow_bus(sensor_bus_t *b, uint8_t addr7)
8-bit registers
static int32_t xfer(void *h, uint16_t reg, uint16_t regsz, uint8_t *d, uint16_t len, int write)
static int32_t wr16(void *h, uint16_t reg, const uint8_t *d, uint16_t n)
static int32_t rd16(void *h, uint16_t reg, uint8_t *d, uint16_t n)
static void dly(uint32_t ms)
void ext_i2c_tof_bus(vl53_bus_t *b, uint8_t addr7)
16-bit registers
static int32_t rd8(void *h, uint8_t reg, uint8_t *d, uint16_t n)
static int32_t wr8(void *h, uint8_t reg, const uint8_t *d, uint16_t n)
HAL binding of the expansion (Qwiic) devices on I2C1.
int imu_i2c_lock(void)
0 = taken (or no kernel yet), -1 = timeout
void imu_i2c_unlock(void)
I2C_HandleTypeDef * imu_i2c_handle(void)
STM32 HAL (STM32WB55) binding of the sensor_bus_t interface + DMA burst read of the FIFO with task no...
static USBD_StatusTypeDef st(HAL_StatusTypeDef h)