Replies: 3 comments 6 replies
-
Why not create a generic i2c HAL? |
Beta Was this translation helpful? Give feedback.
-
Hi, @hiperiondev. Main idea is to keep compatibility as much as possible with every i2c component already written. If we change to a new generic HAL, every component must be rewritten to accomodate to this new HAL. I think we need to do minimal possible changes that not suppose big breaking change. It's only my opinion, :) |
Beta Was this translation helpful? Give feedback.
-
Maybe this project can help: https://github.com/lewisxhe/SensorLib |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Guidelines to port.
I have been porting i2c lib to i2c master trying to do minimal changes. I get working code (need more exhaustive test) with same write/read api. I have tested ads111x and ds3231 examples with a real device and they work.
However, there is a challenge to solve with
i2c_dev_t
structure. On every i2c device constructor, there is an init descriptor function likexxxx_init_desc(...)
. In .c code, descriptor is filled. With i2c drive legacy,i2c_dev_t
has a member (i2c_config_t cfg
) but in i2c_master that struct doesn't exist.With i2c_master,
i2c_dev_t
only needi2c_master_dev_handle_t
and optionally,i2c_master_bus_handle
. The definition with new driver could be:This struct change implies that every i2c component must rewrite its initializer with the new structure, something like:
An alternative could be create new global "init/constructor" in i2cdev.h with a new global config structure. In this way, components only need to call common initializer and descriptor/device initialization will be done in i2c_dev_t component. Something like:
i2c_dev.h
i2c_legacy.c
xxxx_component.c
Obviously, every i2c component must rewrite its initializer to accomodate to this change.
I'm open to any suggestion.
Regards.
Beta Was this translation helpful? Give feedback.
All reactions