Regarding the INT1 vs INT2 for FIFO usage in the API: Ok, no sure if the API definitions have been fully updated or not, but after a deeper look at function "bma4_map_interrupt" in "bma4.cpp", it seems it can only target the INT1 output. Here is the originally provided interrupt masks and mapping function: /**\name INTERRUPT MASKS */
#define BMA4_FIFO_FULL_INT UINT16_C(0x0100)
#define BMA4_FIFO_WM_INT UINT16_C(0x0200)
#define BMA4_DATA_RDY_INT UINT16_C(0x0400)
#define BMA4_MAG_DATA_RDY_INT UINT16_C(0x2000)
#define BMA4_ACCEL_DATA_RDY_INT UINT16_C(0x8000)
/*!
* @brief API sets the interrupt to either interrupt1 or
* interrupt2 pin in the sensor.
*/
int8_t bma4_map_interrupt(uint8_t int_line, uint16_t int_map, uint8_t enable, struct bma4_dev *dev)
{
int8_t rslt;
uint8_t data[3] = { 0, 0, 0 };
uint8_t index[2] = { BMA4_INT_MAP_1_ADDR, BMA4_INT_MAP_2_ADDR };
/* Check the dev structure as NULL */
rslt = null_pointer_check(dev);
if (rslt == BMA4_OK)
{
rslt = bma4_read_regs(BMA4_INT_MAP_1_ADDR, data, 3, dev);
if (rslt == BMA4_OK)
{
if (enable == TRUE)
{
/* Feature interrupt mapping */
data[int_line] = (uint8_t)(int_map & (0x00FF));
/* Hardware interrupt mapping */
data[2] = (uint8_t)((int_map & (0xFF00)) >> 8); // <------------------------ does not allow for INT2
}
else
{
/* Feature interrupt un-mapping */
data[int_line] &= (~(uint8_t)(int_map & (0x00FF)));
/* Hardware interrupt un-mapping */
data[2] &= (~(uint8_t)((int_map & (0xFF00)) >> 8)); // <------------------------ does not allow for INT2
}
rslt = bma4_write_regs(index[int_line], &data[int_line], 1, dev);
if (rslt == BMA4_OK)
{
rslt = bma4_write_regs(BMA4_INT_MAP_DATA_ADDR, &data[2], 1, dev);
}
}
}
return rslt;
} The 'int_line' argument has no influnce on the data being sent to 0x58 (INT_MAP_DATA), data[2]. After changing 'int_map' from 0x0200 to 0x2000 ( see datasheet below ) the INT2 mapping is successful, so it is basically ignored. From the datasheet (Rev 3.0_112020): The function seems to be modifiable to correct this by simply changing the amount of bit shifting based on the line selected, as follows: // ...
/* Hardware interrupt mapping */
data[2] = (uint8_t)((int_map & (0xFF00)) >> (4 * (2 - int_line))); // Shift 8 bits for INT1, 4 for INT2
//... Please correct me if I have misunderstood the correct use of this API function though. 🙂 Cheers, Michael.
... View more