10-25-2021 08:59 AM
Hi,
I'm trying to access the tap interrupts of the BMA456, but am running into some issues. I am largely using the APIs found here.
I can successful configure the board to output accelerometer data using the accelerometer example (this utilises the BMA4_DATA_RDY_INT interrupt). However, I recieve no triggers when I attempt to poll the interrupts for either single or double taps. I suspect that there is a fairly trivial issue in my configuration or my order of operations that I've missed in the documentation. I've included the important code from test function below (without the error catching functions).
Any help would be greatly appreciated!
Cheers,
Michael.
int8_t rslt = BMA4_OK;
uint16_t int_status = 0;
uint8_t iteration = 10;
spi_init(clk, miso, mosi, ss);
bma.intf = BMA4_SPI_INTF;
bma.bus_read = spi_read;
bma.bus_write = spi_write;
bma.intf_ptr = &dev_addr; // Assign device address to interface pointer
bma.delay_us = delay_us;
bma.read_write_len = 8;
bma.resolution = 16;
bma.feature_len = BMA456_FEATURE_SIZE;
bma.variant = BMA45X_VARIANT;
// Verify chip ID
rslt |= bma456_init(&bma);
// Configuration
rslt |= bma456_write_config_file(&bma);
// Accelerometer
rslt |= bma4_set_accel_enable(BMA4_ENABLE, &bma);
// Interrupts
rslt |= bma456_map_interrupt(BMA4_INTR1_MAP, BMA456_SINGLE_TAP_INT | BMA456_DOUBLE_TAP_INT, BMA4_ENABLE, &bma);
// Enabling features
rslt = bma456_feature_enable((BMA456_SINGLE_TAP | BMA456_DOUBLE_TAP), BMA4_ENABLE, &bma);
//Do Single or Double Tap the board
while (1)
{
/* Read interrupt status */
rslt = bma456_read_int_status(&int_status, &bma);
bma4_error_codes_print_result("bma456_read_int_status", rslt);
/* Enters only if the obtained interrupt is single-tap */
if ((rslt == BMA4_OK) && (int_status & BMA456_SINGLE_TAP_INT))
{
printf("Single tap interrupt occurred\n");
iteration--;
}
/* Enters only if the obtained interrupt is double-tap */
else if ((rslt == BMA4_OK) && (int_status & BMA456_DOUBLE_TAP_INT))
{
printf("Double tap interrupt occurred\n");
iteration--;
}
int_status = 0;
/* Break out of the loop when iteration has reached zero */
if (iteration == 0)
{
printf("Iterations are done. Exiting !");
break;
}
}
Solved! Go to Solution.
10-25-2021 04:00 PM - edited 10-25-2021 04:25 PM
10-26-2021 08:47 AM
Hi BSTRobin,
Thanks for getting back to me, I'll give a try and let you know how I go.
Cheers,
Michael.
11-01-2021 07:28 AM
Hi,
Thanks! I got the BMA456 tap functions running based on the example you provided me.
I know when I was getting start in writing this, I found some aspects a little slow to get going so I thought I'd include my test code as an example, in case it helps anyone. It is designed to run on an ESP32 with the arduino framework, communicates over SPI, use interrupts and largely comprises chunks from the Bosch examples.
Cheers,
Michael
11-02-2021 09:09 AM
Hello Weaver,
Good. Thanks for your kindly sharing in community.