-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
There seem to be three implementation decisions that make the driver only function with a single BNO080.
- Use of global data at line 429 of sh.c
static sh2_t sh2; - Use of global data at line 150 of shtp.c
static shtp_t shtp; - Hard coded calls to a particular to the HAL without passing any instance information that would allow switching the communications channel.
Are there any other spots I missed?
It would seem to be quite a big job to fix this. A couple of possibilities:
- Add functions to create an instance of the sensor returning a handle. The caller would be responsible for allocating memory perhaps? All calls would take the handle to identify the instance intended for the call. (This would be a fair bit of work and would be a breaking change to the library). Global data is the root of all evil LOL!
- Replace the global data access with access via a pointer (search and replace . operator with ->). Once that is done it would be possible to swap (via additional functions) which instance the library is working with. For the example code, great care would be needed to avoid threading issues. All extant instances would have to be operated from one task.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels