Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Running BMA490L on Arduino

    Running BMA490L on Arduino

    kazkibergetic
    New Poster

    Hello,

    How can I run BMA490L on Arduino?

    Thank you.

    6 REPLIES 6

    Yanchao
    Community Moderator
    Community Moderator

    Hi,

    We provide BMA490L-Sensor-API at github. You could import this api in arduino code.

    Best regards.

    Minhwan
    Community Moderator
    Community Moderator

    Hello, 

     

    Here is the example for Arduino Due. 

    Please let me know if you have any questions. 

    Thanks, 

    Awesome, thank you. Do you use interrupts in your code? 

    Hello kazkibergetic, 

     

    No, however you can use BMA4 interrupt for BMA490L as below. 

    Thanks 🙂 

    /**\name OUTPUT TYPE ENABLE POSITION AND MASK*/
    #define BMA4_INT_EDGE_CTRL_MASK UINT8_C(0x01)
    #define BMA4_INT_EDGE_CTRL_POS UINT8_C(0x00)
    #define BMA4_INT_LEVEL_MASK UINT8_C(0x02)
    #define BMA4_INT_LEVEL_POS UINT8_C(0x01)
    #define BMA4_INT_OPEN_DRAIN_MASK UINT8_C(0x04)
    #define BMA4_INT_OPEN_DRAIN_POS UINT8_C(0x02)
    #define BMA4_INT_OUTPUT_EN_MASK UINT8_C(0x08)
    #define BMA4_INT_OUTPUT_EN_POS UINT8_C(0x03)
    #define BMA4_INT_INPUT_EN_MASK UINT8_C(0x10)
    #define BMA4_INT_INPUT_EN_POS UINT8_C(0x04)

    /**\name INTERRUPT ENABLE REGISTERS*/
    #define BMA4_INT1_IO_CTRL_ADDR UINT8_C(0X53)
    #define BMA4_INT2_IO_CTRL_ADDR UINT8_C(0X54)

    /**\name LATCH DURATION REGISTERS*/
    #define BMA4_INTR_LATCH_ADDR UINT8_C(0X55)

    /*!
    * @brief Interrupt Pin Configuration structure
    */
    struct bma4_int_pin_config {
    /*! Trigger condition of interrupt pin */
    uint8_t edge_ctrl;
    /*! Level of interrupt pin */
    uint8_t lvl;
    /*! Behaviour of interrupt pin to open drain */
    uint8_t od;
    /*! Output enable for interrupt pin */
    uint8_t output_en;
    /*! Input enable for interrupt pin */
    uint8_t input_en;
    };

    /*! @brief This function sets the electrical behaviour of interrupt pin1 or
    pin2 in the sensor.
    */
    uint16_t bma4_set_int_pin_config(const struct bma4_int_pin_config *int_pin_config, uint8_t int_line,
    struct bma490l_dev *dev)
    {
    uint16_t rslt = 0;
    uint8_t interrupt_address_array[2] = {BMA4_INT1_IO_CTRL_ADDR, BMA4_INT2_IO_CTRL_ADDR};
    uint8_t data = 0;

    /* Check the bma4 structure as NULL */
    if (dev == NULL) {
    rslt |= BMA490L_E_NULL_PTR;
    } else {
    if (int_line <= 1) {
    data = ((uint8_t)((int_pin_config->edge_ctrl & BMA4_INT_EDGE_CTRL_MASK) |
    ((int_pin_config->lvl << 1) & BMA4_INT_LEVEL_MASK) |
    ((int_pin_config->od << 2) & BMA4_INT_OPEN_DRAIN_MASK) |
    ((int_pin_config->output_en << 3) & BMA4_INT_OUTPUT_EN_MASK) |
    ((int_pin_config->input_en << 4) & BMA4_INT_INPUT_EN_MASK)));

    rslt |= bma490l_write_regs(interrupt_address_array[int_line], &data, 1, dev);
    } else {
    rslt |= BMA490L_E_INT_LINE_INVALID;
    }
    }

    return rslt;
    }

     

    main()

    {

    int_pin_config.edge_ctrl = 0x01; // 0 = level, 1 = edge
    int_pin_config.lvl = 0x01; // 0 = active low, 1 = active high
    int_pin_config.od = 0x0; // 0 = push-pull, 1 = open drain
    int_pin_config.output_en = 0x01; // 0 = output disabled, 1 = output enabled
    int_pin_config.input_en = 0x0; // 0 = input disabled, 1 = input enabled. input used for fifo things
    // INT1 active high, pushpull, output enabled
    rslt = bma4_set_int_pin_config(&int_pin_config, 0, &bma490l_dev);

    /* Make interrupt function */

    }

    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