Closed uilter closed 3 years ago
Hi, I figure out how to set it.
iis3dwb_pin_int1_route_t int1_route = {0x00};
iis3dwb_xl_full_scale_set(&hAcc, IIS3DWB_2g);
iis3dwb_block_data_update_set(&hAcc, 1);
iis3dwb_fifo_watermark_set(&hAcc, 0x1FF);
iis3dwb_fifo_stop_on_wtm_set(&hAcc, 1);
iis3dwb_fifo_mode_set(&hAcc, IIS3DWB_STREAM_TO_FIFO_MODE);
iis3dwb_fifo_timestamp_decimation_set(&hAcc, IIS3DWB_NO_DECIMATION);
iis3dwb_fifo_xl_batch_set(&hAcc, IIS3DWB_XL_BATCHED_AT_26k7Hz);
iis3dwb_xl_data_rate_set(&hAcc, IIS3DWB_XL_ODR_26k7Hz);
int1_route.fifo_th = 1;
int1_route.fifo_ovr = 1;
int1_route.fifo_full = 1;
int1_route.fifo_bdr = 1;
iis3dwb_pin_int1_route_set(&hAcc, &int1_route);
When the interrupt occurs, just need read the fifo like it.
iis3dwb_fifo_status_get(&hAcc, &statusFifo2);
if(statusFifo2.fifo_wtm_ia)
{
iis3dwb_fifo_data_level_get(&hAcc, &num);
waterLevel = num / 3;
fifoLevel = waterLevel;
while(waterLevel-- > 0 || i < fifoLevel)
{
iis3dwb_fifo_out_raw_get(&hAcc, data_raw_acceleration.u8bit);
acceleration_mg[i++] = iis3dwb_from_fs2g_to_mg(data_raw_acceleration.i16bit[0]);
acceleration_mg[i++] = iis3dwb_from_fs2g_to_mg(data_raw_acceleration.i16bit[1]);
acceleration_mg[i++] = iis3dwb_from_fs2g_to_mg(data_raw_acceleration.i16bit[2]);
}
/* Reset FIFO */
iis3dwb_fifo_mode_set(&hAcc, IIS3DWB_BYPASS_MODE);
iis3dwb_fifo_mode_set(&hAcc, IIS3DWB_STREAM_TO_FIFO_MODE);
}
@uilter
Good you were able to solve it by yourself. From our side we need for sure to add more examples, for example using FIFO as you suggested. Thanks!
Hi, I'm trying to use the iis3dwb as FIFO mode with a watermark.
I'm using a custom board. I double checked the hardware and guaranteed this board works well. I'm able to read/write the sensor using SPI interface and generate interrupt with wake-up int source.
In this mode the interrupt INT1 not works. This is my init code:
Please, could you guide me to find where is my mistake? If possible, can anyone add a sample code for fifo mode with watermark? It will be nice!
Many thanks for this library.