Hello everyone!
I am trying to implement a free fall detector using the IOT sensor, I want the any motion detection to be replaced by the free fall detection interrupt.
I tried and tried but it keeps not working, and here is my code :
in user sensor.c :
void user_bmi160_config_low-g_intr( void ) {
bmi160_set_low_g_enable(BMI160_ENABLE);
bmi160_set_low_high_g_source(0x01);
/* BMI160 Datasheet pg 63, int1 is hi level active with output - push pull */
bmi160_set_intr_1_output_enable(BMI160_ENABLE);
bmi160_set_intr_1_output_level(BMI160_LEVEL_HIGH);
bmi160_set_intr_1_output_odrn_pshpll(BMI160_OPEN_DRAIN);
bmi160_set_intr_1_output_edge_level(BMI160_EDGE);
bmi160_set_intrs_latched(BMI160_LATCH_DUR_2_5_MILLI_SEC);
bmi160_set_low_g_intr_1(BMI160_ENABLE);
bmi160_set_reg_int_map_0(0x01);
bmi160_set_reg_int_map_1(0x00);
bmi160_set_reg_int_map_2(0x00);
bmi160_set_low_g_threshold(0xff);
bmi160_set_low_g_mode(0x00);
}
and in user_platform.c: I change it to inspect the low-g interrupt :
#定义BMI160_INT_STATUS1_LOWG_INT_FLAG (
void wkup_intr_non_connected_cb( void )
{
uint8_t bmi160_int_status=0;
if(GetBits16(SYS_STAT_REG, PER_IS_DOWN)){
periph_init();
}
arch_ble_ext_wakeup_off();
//bmi160_get_reg_int_status_2(&bmi160_int_status );
bmi160_get_reg_int_status_1(&bmi160_int_status );
//bmi160_get_reg_int_status_0(&bmi160_int_status );
DBG_MSG1("WOKE UP SF %x\r\n",(int)bmi160_int_status);
#ifdef USE_low_g_WAKEUP
if( bmi160_int_status&BMI160_INT_STATUS1_LOWG_INT_FLAG ){
wrbl_env.adv_mode = ADV_MODE_FAST;
bmi160_soft_reset();
EXECUTE_DEFAULT_OPERATION_VOID(default_operation_adv);
}
#else
if( bmi160_int_status&0x08 ){
wrbl_env.adv_mode = ADV_MODE_FAST;
bmi160_set_sensor_state(ACC_SUSPEND);
bmi160_set_sensor_state(GYR_SUSPEND);
EXECUTE_DEFAULT_OPERATION_VOID(default_operation_adv);
}
#endif
}
Any help is highly appreciated
Thanks.
Hi mnd munzer,
When you mention that its not working, you see the interrupt triggering and the device doesn't wake up ? Does the free fall interrupt occurs ?
Thanks MT_dialog
Well, actually it is supposed to start advertising if a free fall happens, so I am supposing the interrupt is not happening at all
Thanks.
Hi mhd munzer,
Well you will have to debug this and check if the interrupt is occurs or not in order to know for sure. If the interrupt triggers and the device doens't wake up it might be the polarity of the interrupt or perhaps the interrupt is triggered and you never reach the start advertise function, there are quite a few things that can go wrong between triggering an interrupt and start advertising.
Thanks MT_dialog