Skip to content

Commit

Permalink
handle motion status change properly for BLOCKING imu
Browse files Browse the repository at this point in the history
  • Loading branch information
corruptbear committed Jun 29, 2024
1 parent 0f45f18 commit 747b3ae
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions software/firmware/src/peripherals/src/imu.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,15 @@ static void imu_isr(void *args)
#else
// Read the device motion status and trigger the registered callback
const uint8_t interrupt_status = i2c_read8(BNO055_INTR_STAT_ADDR);
const bool in_motion = interrupt_status & ACC_AM;

if ((in_motion != previously_in_motion) && motion_change_callback!=NULL)
motion_change_callback(in_motion);
previously_in_motion = in_motion;
const bool in_motion_fired = interrupt_status & ACC_AM;
const bool no_motion_fired = interrupt_status & ACC_NM;
//print("interrupt status (blocking)%u\n",interrupt_status);
if ((in_motion_fired && !previously_in_motion) || (no_motion_fired && previously_in_motion))
{
previously_in_motion = !previously_in_motion;
if (motion_change_callback!=NULL)
motion_change_callback(previously_in_motion);
}
if (interrupt_status & (ACC_BSX_DRDY | MAG_DRDY | GYR_DRDY))
{
if (data_ready_callback!=NULL)
Expand Down

0 comments on commit 747b3ae

Please sign in to comment.