Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMI160 enable both INTerrupts

    BMI160 enable both INTerrupts

    gianmariai
    Occasional Visitor

    Hello,
    starting from standard kernel module from MangoH (here is original code), I'm tring to enable both INTerrupts of BMI160,
    INT1 must signal anymotion/significant motion
    INT2 must signal Step Detect

    I've added parts in bold to following code, but it seems not working.. someone maybe already done and can help.

    Regads,
    Gian


    static int bmi160_setup_sigmot_int(struct bmi160_data *data) {

    int ret = 0;
    Route any motion/significant motion interrupt to int1
    ret = regmap_write(
    data->regmap,
    BMI160_REG_INT_MAP_0,
    BMI160_INT_MAP_0_INT1_ANYM_SIGMOT); //route anymotion to INT1
    if (ret < 0)
    return ret;

    ret = regmap_write(
    data->regmap,
    BMI160_REG_INT_MAP_1,
    0);
    if (ret < 0)
    return ret;

    //Route Single Tap interrupt to int2
    ret = regmap_write(
    data->regmap,
    BMI160_REG_INT_MAP_2,
    BMI160_INT_MAP_2_INT2_STAP); //route single tap to INT2
    if (ret < 0)
    return ret;

    ret = regmap_write(
    data->regmap,
    BMI160_REG_INT_LATCH,
    (FIELD_PREP(BMI160_INT_LATCH_MODE,
    BMI160_INT_LATCH_MODE_TMP_2560_MS)));
    if (ret < 0)
    return ret;

    //Enable edge interrupt on INT1 pin
    ret = regmap_write(
    data->regmap,
    BMI160_REG_INT_OUT_CTRL,
    (BMI160_INT_OUT_CTRL_INT1_EDGE |
    BMI160_INT_OUT_CTRL_INT1_LVL |
    BMI160_INT_OUT_CTRL_INT1_OUTPUT_EN));
    if (ret < 0)
    return ret;

    // Enable edge interrupt on INT2 pin
    ret = regmap_write(
    data->regmap,
    BMI160_REG_INT_OUT_CTRL,
    (BMI160_INT_OUT_CTRL_INT2_EDGE |
    BMI160_INT_OUT_CTRL_INT2_LVL |
    BMI160_INT_OUT_CTRL_INT2_OUTPUT_EN));
    if (ret < 0)
    return ret;

    ret = regmap_write(
    data->regmap,
    BMI160_REG_INT_EN_0,
    (BMI160_INT_EN_0_ANYM_X|
    BMI160_INT_EN_0_ANYM_Y|
    BMI160_INT_EN_0_ANYM_Z));
    if (ret < 0)
    return ret;

    return ret;
    }

    1 REPLY 1

    BSTRobin
    Community Moderator
    Community Moderator

    Hi gianmariai,

    It is recommended that you refer to the sensor API to configure the sensor BMI160. This is a reference example.
    https://github.com/BoschSensortec/BMI160_driver/blob/master/examples/tap/tap.c

    Open_BMI160_TAP(dev, BMI160_ENABLE);
    Enable_MCU_INT1_Pin();

    int8_t Open_BMI160_TAP(struct bmi160_dev *dev, uint8_t feature_enable)
    {
    int8_t rslt = BMI160_OK;
    struct bmi160_int_settg int_config;

    if (feature_enable > 0)
    {
    /* Select the Interrupt channel/pin */
    int_config.int_channel = BMI160_INT_CHANNEL_1; /* Interrupt channel/pin 1 */

    /* Select the interrupt channel/pin settings */
    int_config.int_pin_settg.output_en = BMI160_ENABLE; /* Enabling interrupt pins to act as output pin */
    int_config.int_pin_settg.output_mode = BMI160_DISABLE; /* Choosing push-pull mode for interrupt pin */
    int_config.int_pin_settg.output_type = BMI160_ENABLE; /* Choosing active low output */
    int_config.int_pin_settg.edge_ctrl = BMI160_DISABLE; /* Choosing edge triggered output */
    int_config.int_pin_settg.input_en = BMI160_DISABLE; /* Disabling interrupt pin to act as input */
    int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE; /* non-latched output */

    /* Select the Interrupt type */
    int_config.int_type = BMI160_ACC_SINGLE_TAP_INT; /* Choosing tap interrupt */

    /* Select the Any-motion interrupt parameters */
    int_config.int_type_cfg.acc_tap_int.tap_en = BMI160_ENABLE; /* 1- Enable tap, 0- disable tap */
    int_config.int_type_cfg.acc_tap_int.tap_thr = 2; /* Set tap threshold */
    int_config.int_type_cfg.acc_tap_int.tap_dur = 2; /* Set tap duration */
    int_config.int_type_cfg.acc_tap_int.tap_shock = 0; /* Set tap shock value */
    int_config.int_type_cfg.acc_tap_int.tap_quiet = 0; /* Set tap quiet duration */
    int_config.int_type_cfg.acc_tap_int.tap_data_src=1; /* data source 0 : filter or 1 : pre-filter */

    /* Set the Any-motion interrupt */
    rslt = bmi160_set_int_config(&int_config, dev); /* sensor is an instance of the structure bmi160_dev */
    PDEBUG("bmi160_set_int_config(tap enable) status:%d\r\n", rslt);
    }
    else
    {
    /* Select the Interrupt channel/pin */
    int_config.int_channel = BMI160_INT_CHANNEL_1;
    int_config.int_pin_settg.output_en = BMI160_DISABLE; /* Disabling interrupt pins to act as output pin */
    int_config.int_pin_settg.edge_ctrl = BMI160_DISABLE; /* Choosing edge triggered output */

    /* Select the Interrupt type */
    int_config.int_type = BMI160_ACC_SINGLE_TAP_INT; /* Choosing Tap interrupt */
    int_config.int_type_cfg.acc_tap_int.tap_en = BMI160_DISABLE; /* 1- Enable tap, 0- disable tap */

    /* Set the Data ready interrupt */
    rslt = bmi160_set_int_config(&int_config, dev); /* sensor is an instance of the structure bmi160_dev */
    PDEBUG("bmi160_set_int_config(tap disable) status:%d\r\n", rslt);
    }

    return rslt;
    }

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist