LIS2DH - Adding support for the new accelerometer (#216)

+ Creates a new driver for the LIS2DH accelerometer
+ Fixes timing issues since we're already touching a chunk of code

The LIS2DH driver should output similar numbers to the old MMA accelerometer.

Fixes #202
Fixes #189
This commit is contained in:
Ben V. Brown
2018-03-03 15:43:10 +11:00
committed by GitHub
parent 3ce0cc0d99
commit aef8f5f5bb
10 changed files with 221 additions and 119 deletions

View File

@@ -58,17 +58,20 @@ void MMA8652FC::setSensitivity(uint8_t threshold, uint8_t filterTime) {
taskEXIT_CRITICAL();
}
bool MMA8652FC::getOrientation() {
//First read the PL_STATUS registertaskENTER_CRITICAL();
uint8_t MMA8652FC::getOrientation() {
//First read the PL_STATUS register
taskENTER_CRITICAL();
uint8_t plStatus = I2C_RegisterRead(PL_STATUS_REG);
taskEXIT_CRITICAL();
plStatus >>= 1; //We don't need the up/down bit
plStatus &= 0x03; //mask to the two lower bits
//0 == left handed
//1 == right handed
if ((plStatus & 0b10000000) == 0b10000000) {
plStatus >>= 1; //We don't need the up/down bit
plStatus &= 0x03; //mask to the two lower bits
//0 == left handed
//1 == right handed
return !plStatus;
return plStatus==0?2:1;
} else
return 0;
}
void MMA8652FC::getAxisReadings(int16_t *x, int16_t *y, int16_t *z) {
uint8_t tempArr[6];