Hi, I am trying to get the following features working: - step counter - double tap - motion sensor (when accel. any axis exceeds limit trigger interrupt, eg "I am fallen down") With my code below (tests for BMA_OK removed) I get the double tap interrupt and I can read the steps, but I get an anymotion interrupt every time I move the device - even slightly - so it seems that setting the sensitivity fails and the trigger threshold seems to be set extremely low. I would really be grateful if someone could point out what I am doing wrong! Many thanks in advance! ========================== CODE ========================== // accellerator setup void accellerator_setup( int reset_level ) { i2c = new I2CBus(); uint16_t rslt = BMA4_OK; struct bma4_int_pin_config int_config; bma423.dev_addr = BMA4_I2C_ADDR_PRIMARY; bma423.interface = BMA4_I2C_INTERFACE; bma423.bus_read = _i2c_read; bma423.bus_write = _i2c_write; bma423.delay = delay; bma423.read_write_len = 8; bma423.resolution = 12; bma423.feature_len = BMA423_FEATURE_SIZE; rslt = bma423_init(&bma423); rslt |= bma4_set_advance_power_save(BMA4_ENABLE, &bma423); // Wait for sensor time synchronization. Refer the data-sheet for more information delay(5); rslt = bma423_write_config_file(&bma423); rslt = bma4_set_accel_enable(BMA4_ENABLE, &bma423); struct bma4_accel_config accel_conf; accel_conf.odr = BMA4_OUTPUT_DATA_RATE_1600HZ; accel_conf.bandwidth = BMA4_ACCEL_NORMAL_AVG4; accel_conf.range = BMA4_ACCEL_RANGE_2G; accel_conf.perf_mode = BMA4_CONTINUOUS_MODE; rslt |= bma4_set_accel_config(&accel_conf, &bma423); rslt |= bma423_feature_enable(BMA423_STEP_CNTR, BMA4_ENABLE, &bma423); rslt |= bma423_reset_step_counter(&bma423); // must be called once feature is enabled otherwise will not work struct bma423_anymotion_config anymotion_conf; anymotion_conf.threshold = 0x200; // 0xAA 83mg; 0x400 500g; anymotion_conf.duration = 5; // X*20ms anymotion_conf.nomotion_sel = 0; // 0 Anymotion, 1 Nomotion rslt |= bma423_set_any_motion_config(&anymotion_conf, &bma423); rslt |= bma423_anymotion_enable_axis(BMA423_ALL_AXIS_EN, &bma423); rslt |= bma423_feature_enable(BMA423_ANY_MOTION, BMA4_ENABLE, &bma423); // double tap detection (should be on by default) rslt |= bma423_feature_enable(BMA423_WAKEUP, BMA4_ENABLE, &bma423); rslt |= bma423_tap_selection(0, &bma423); // 0 = double tap, 1 = single tap rslt |= bma423_wakeup_set_sensitivity(7, &bma423); // 0 = most sensitive, 7 = least sensitive rslt |= bma4_set_interrupt_mode(BMA4_LATCH_MODE, &bma423); rslt |= bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_ANY_NO_MOTION_INT | BMA423_WAKEUP_INT, BMA4_ENABLE, &bma423); // anymotion and double tap // need verification for interrupt functionality int_config.edge_ctrl = BMA4_LEVEL_TRIGGER; int_config.lvl = BMA4_ACTIVE_HIGH; // this must be hogh as the main code triggers on HIGH on ext1 bits int_config.od = BMA4_PUSH_PULL; int_config.output_en = BMA4_OUTPUT_ENABLE; int_config.input_en = BMA4_INPUT_DISABLE; rslt |= bma4_set_int_pin_config(&int_config, BMA4_INTR1_MAP, &bma423); }
... View more