Closed peterleif closed 2 years ago
Hi Etsushi (@peterleif ), Great suggestion - thank you. Would you like to send a Pull Request with the changes? Best wishes, Paul
Hi Paul (@PaulZC ), I would like to send a PR. I don't have an Arduino test environment, so please forgive me for not being able to do adequate testing.
Best wishes, Etsushi
Merged in v1.2.8. Closing...
Subject of the issue
This library implements a mechanism to reduce the amount of I2C traffic by caching the previously used register bank and skip the bank change operation when it is not required.
Currently, no initialization method for
ICM_20948_Device_t
is provided and therefore all members including_last_bank
is initialized as0
(if declared as a global or static variable).It means that if the first register access uses register bank 0 no bank change operation is performed.
This behavior can be problematic if the MCU is reset while the power to ICM-20948 is kept on. Suppose the MCU is performing register access using bank 2, for example, and then the MCU resets, and the first register access after the reset is intended to use register bank 0. Since the register bank change operation is skipped, the register access is recognized as access to the register bank 2.
To prevent this problem, I would suggest implementing an initialization method for
ICM_20948_Device_t
that sets an invalid value (e.g.4
) to_last_bank
so the first register bank change operation is performed 100%.Your workbench
Steps to reproduce
ICM_20948_Device_t
as a global variableExpected behavior
The MCU should access bank 0 after the reset.
Actual behavior
The MCU accesses bank 2 since no bank change operation is performed after the reset.