TwiMaster is now based on the NRFX TWI driver, as it handles more edge cases and workarounds for errors on the bus.

Reset the TWI bus after the soft-reset of the motion sensor to workaround issues on the TWI bus.
This commit is contained in:
Jean-François Milants
2021-04-08 20:07:24 +02:00
parent 1d7576de64
commit 9ac4be8b75
7 changed files with 67 additions and 207 deletions

View File

@@ -35,12 +35,9 @@ Bma421::Bma421(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster{twiMaster},
}
void Bma421::Init() {
auto ret = bma4_soft_reset(&bma);
if(ret != BMA4_OK) return;
if(not isResetOk) return; // Call SoftReset (and reset TWI device) first!
nrf_delay_ms(1);
ret = bma423_init(&bma);
auto ret = bma423_init(&bma);
if(ret != BMA4_OK) return;
ret = bma423_write_config_file(&bma);
@@ -109,3 +106,11 @@ bool Bma421::IsOk() const {
void Bma421::ResetStepCounter() {
bma423_reset_step_counter(&bma);
}
void Bma421::SoftReset() {
auto ret = bma4_soft_reset(&bma);
if(ret == BMA4_OK) {
isResetOk = true;
nrf_delay_ms(1);
}
}