Skip to content

Commit 773a800

Browse files
committed
Add functions to check if new IMU data are available
1 parent 10d1056 commit 773a800

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

libraries/CurieIMU/src/BMI160.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,3 +2386,21 @@ uint8_t BMI160Class::getRegister(uint8_t reg) {
23862386
void BMI160Class::setRegister(uint8_t reg, uint8_t data) {
23872387
reg_write(reg, data);
23882388
}
2389+
2390+
/** Check if new gyroscope data is available
2391+
* @return True if new data is available, else false.
2392+
*/
2393+
bool BMI160Class::gyroDataReady()
2394+
{
2395+
return reg_read_bits(BMI160_RA_STATUS, BMI160_STATUS_DRDY_GYR, 1);
2396+
}
2397+
2398+
/** Check if new accelerometer data is available
2399+
* @return True if new data is available, else false.
2400+
*/
2401+
bool BMI160Class::accelDataReady()
2402+
{
2403+
return reg_read_bits(BMI160_RA_STATUS, BMI160_STATUS_DRDY_ACC, 1);
2404+
}
2405+
2406+

libraries/CurieIMU/src/BMI160.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,9 @@ class BMI160Class {
652652
uint8_t getInterruptLatch();
653653
void setInterruptLatch(uint8_t latch);
654654
void resetInterrupt();
655+
656+
bool gyroDataReady();
657+
bool accelDataReady();
655658

656659
protected:
657660
virtual int serial_buffer_transfer(uint8_t *buf, unsigned tx_cnt, unsigned rx_cnt);

0 commit comments

Comments
 (0)