Hello,
How can I run BMA490L on Arduino?
Thank you.
Hi,
We provide BMA490L-Sensor-API at github. You could import this api in arduino code.
Best regards.
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 */
}