Skip to content

Commit d9d1bf9

Browse files
committed
Adding readFIFO
1 parent a7bdc27 commit d9d1bf9

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

src/ICM_20948.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,12 @@ ICM_20948_Status_e ICM_20948::getFIFOcount(uint16_t *count)
946946
return status;
947947
}
948948

949+
ICM_20948_Status_e ICM_20948::readFIFO(uint8_t *data)
950+
{
951+
status = ICM_20948_read_FIFO(&_device, data);
952+
return status;
953+
}
954+
949955
// DMP
950956

951957
ICM_20948_Status_e ICM_20948::enableDMP(bool enable)

src/ICM_20948.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class ICM_20948
168168
ICM_20948_Status_e resetFIFO(void);
169169
ICM_20948_Status_e setFIFOmode(bool snapshot = false); // Default to Stream (non-Snapshot) mode
170170
ICM_20948_Status_e getFIFOcount(uint16_t *count);
171+
ICM_20948_Status_e readFIFO(uint8_t *data);
171172

172173
//DMP
173174
ICM_20948_Status_e enableDMP(bool enable = true);

src/util/ICM_20948_C.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,28 @@ ICM_20948_Status_e ICM_20948_get_FIFO_count(ICM_20948_Device_t *pdev, uint16_t *
992992
return retval;
993993
}
994994

995+
ICM_20948_Status_e ICM_20948_read_FIFO(ICM_20948_Device_t *pdev, uint8_t *data)
996+
{
997+
ICM_20948_Status_e retval = ICM_20948_Stat_Ok;
998+
999+
ICM_20948_FIFO_R_W_t ctrl;
1000+
retval = ICM_20948_set_bank(pdev, 0);
1001+
if (retval != ICM_20948_Stat_Ok)
1002+
{
1003+
return retval;
1004+
}
1005+
1006+
retval = ICM_20948_execute_r(pdev, AGB0_REG_FIFO_R_W, (uint8_t *)&ctrl, sizeof(ICM_20948_FIFO_R_W_t));
1007+
if (retval != ICM_20948_Stat_Ok)
1008+
{
1009+
return retval;
1010+
}
1011+
1012+
*data = ctrl.FIFO_R_W;
1013+
1014+
return retval;
1015+
}
1016+
9951017
// DMP
9961018

9971019
ICM_20948_Status_e ICM_20948_enable_DMP(ICM_20948_Device_t *pdev, bool enable)

src/util/ICM_20948_C.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ callbacks for the user to respond to interrupt events
247247
ICM_20948_Status_e ICM_20948_reset_FIFO(ICM_20948_Device_t *pdev);
248248
ICM_20948_Status_e ICM_20948_set_FIFO_mode(ICM_20948_Device_t *pdev, bool snapshot);
249249
ICM_20948_Status_e ICM_20948_get_FIFO_count(ICM_20948_Device_t *pdev, uint16_t *count);
250+
ICM_20948_Status_e ICM_20948_read_FIFO(ICM_20948_Device_t *pdev, uint8_t *data);
250251

251252
// DMP
252253

0 commit comments

Comments
 (0)