05-03-2020 06:31 PM - edited 05-03-2020 06:34 PM
Hello,
Introduction about BMA400 Auto Wakeup and Auto Low Power
By following the above guide I tried to configure BMA400 to generate two interrupts:
Both of the interrupts work alone. However, when I try to enable both, only the last configured interrupt works.
case 1:
case 2:
Here is the code:
#define NUMBER_OF_DEVICE_CONFIG 2
uint8_t power_mode;
struct bma400_device_conf conf[NUMBER_OF_DEVICE_CONFIG];
/* Interrupt configuration structure */
struct bma400_int_enable int_en;
/* Selecting auto wakeup on wakeup interrupt event */
conf[0].type = BMA400_AUTOWAKEUP_INT;
/* Selecting auto low power mode*/
conf[1].type = BMA400_AUTO_LOW_POWER;
/* Get the previously set settings */
_rslt = bma400_get_device_conf(conf, NUMBER_OF_DEVICE_CONFIG, &_bma);
print_rslt(_rslt);
conf[0].param.wakeup.wakeup_ref_update = BMA400_EVERY_TIME_UPDATE;
conf[0].param.wakeup.sample_count = BMA400_SAMPLE_COUNT_2;
conf[0].param.wakeup.wakeup_axes_en = BMA400_XYZ_AXIS_EN;
conf[0].param.wakeup.int_wkup_threshold = 3;
conf[0].param.wakeup.int_chan = BMA400_INT_CHANNEL_1;
/* Enable auto low power on Gen1 trigger */
conf[1].param.auto_lp.auto_low_power_trigger = BMA400_AUTO_LP_GEN1_TRIGGER;
/* Set the configurations in sensor */
_rslt = bma400_set_device_conf(conf, NUMBER_OF_DEVICE_CONFIG, &_bma);
print_rslt(_rslt);
#define NUMBER_OF_SENSOR_CONFIG 2
struct bma400_sensor_conf conf[NUMBER_OF_SENSOR_CONFIG];
/* Select the type of configuration to be modified */
conf[0].type = BMA400_ACCEL;
conf[1].type = BMA400_GEN1_INT;
/* Get the accelerometer configurations which are set in the sensor */
_rslt = bma400_get_sensor_conf(conf, NUMBER_OF_SENSOR_CONFIG, &_bma);
print_rslt(_rslt);
/* Modify the desired configurations as per macros
* available in bma400_defs.h file */
// conf[0].param.accel.odr = BMA400_ODR_100HZ;
conf[0].param.accel.range = BMA400_4G_RANGE;
conf[0].param.accel.data_src=BMA400_DATA_SRC_ACCEL_FILT_1;
conf[0].param.accel.filt1_bw = BMA400_ACCEL_FILT1_BW_1;
// inactivity
conf[1].param.gen_int.gen_int_thres = 3; // x 8mg
conf[1].param.gen_int.gen_int_dur = 100; // x ODR
conf[1].param.gen_int.axes_sel = BMA400_XYZ_AXIS_EN;
conf[1].param.gen_int.data_src=BMA400_DATA_SRC_ACC_FILT2;
conf[1].param.gen_int.criterion_sel = BMA400_INACTIVITY_INT;
conf[1].param.gen_int.evaluate_axes = BMA400_ALL_AXES_INT;
conf[1].param.gen_int.ref_update = BMA400_EVERY_TIME_UPDATE;
conf[1].param.gen_int.hysteresis = BMA400_HYST_0_MG;
conf[1].param.gen_int.int_chan = BMA400_INT_CHANNEL_2;
/* Set the desired configurations to the sensor */
_rslt = bma400_set_sensor_conf(conf, NUMBER_OF_SENSOR_CONFIG, &_bma);
print_rslt(_rslt);
#define NUMBER_OF_INTERRUPT 2
struct bma400_int_enable int_select[NUMBER_OF_INTERRUPT];
int_select[0].type = BMA400_GEN1_INT_EN;
int_select[0].conf = BMA400_ENABLE;
int_select[1].type = BMA400_AUTO_WAKEUP_EN;
int_select[1].conf = BMA400_ENABLE;
_rslt = bma400_enable_interrupt(int_select, NUMBER_OF_INTERRUPT, &_bma);
print_rslt(_rslt);
_rslt = bma400_set_power_mode(BMA400_LOW_POWER_MODE, &_bma);
print_rslt(_rslt);
05-06-2020 01:06 AM