...
Code Block |
---|
typedef void (*I2C_WriteFuncPtr)(int device_addr, int reg_addr, int data);
typedef int (*I2C_ReadFuncPtr)(int device_addr, int reg_addr);
static I2C_WriteFuncPtr local_I2C_Write = NULL;
static I2C_ReadFuncPtr local_I2C_Read = NULL;
void lsm6dso_init(I2C_WriteFuncPtr write_func, I2C_ReadFuncPtr read_func)
{
local_I2C_Write = write_func;
local_I2C_Read = read_func;
}
int lsmdso_read_reg(uint8_t reg)
{
return local_I2C_Read(...);
}
(main.c)
lsm6dso_init(HAL_i2c_MemWrite, HAL_i2c_MemRead); |
While this is obviously more work, it means that these drivers should succeed for the foreseeable future and for all different chip sets in use right now, without having to change
...