mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Convert IMU to IRQ for rotation
This moves the rotation detection to use the IRQ2 line. Fixes #44
This commit is contained in:
@@ -44,7 +44,7 @@ void StartUp_Accelerometer(uint8_t sensitivity) {
|
||||
I2C_RegisterWrite( CTRL_REG2, 0x40); // Reset all registers to POR values
|
||||
delayMs(2); // ~1ms delay
|
||||
I2C_RegisterWrite(FF_MT_CFG_REG, 0x78); // Enable motion detection for X and Y axis, latch enabled
|
||||
uint8_t sens = 9 * 6 + 5;
|
||||
uint8_t sens = 9 * 6 + 3;
|
||||
sens -= 6 * sensitivity;
|
||||
|
||||
I2C_RegisterWrite(FF_MT_THS_REG, 0x80 | sens); // Set threshold
|
||||
@@ -52,9 +52,9 @@ void StartUp_Accelerometer(uint8_t sensitivity) {
|
||||
I2C_RegisterWrite(PL_CFG_REG, 0x40); //Enable the orientation detection
|
||||
I2C_RegisterWrite(PL_COUNT_REG, 200); //200 count debounce
|
||||
I2C_RegisterWrite(PL_BF_ZCOMP_REG, 0b01000111); //Set the threshold to 42 degrees
|
||||
I2C_RegisterWrite(P_L_THS_REG, 0b10011100);//Up the trip angles
|
||||
I2C_RegisterWrite( CTRL_REG4, 0x04); // Enable motion interrupt
|
||||
I2C_RegisterWrite( CTRL_REG5, 0x04);// Route motion interrupts to INT1 ->PB5 ->EXTI5
|
||||
I2C_RegisterWrite(P_L_THS_REG, 0b10011100); //Up the trip angles
|
||||
I2C_RegisterWrite( CTRL_REG4, 0x04 | (1<<4)); // Enable motion interrupt & orientation interrupt
|
||||
I2C_RegisterWrite( CTRL_REG5, 0x04);// Route motion interrupts to INT1 ->PB5 ->EXTI5, leaving orientation routed to INT2
|
||||
I2C_RegisterWrite( CTRL_REG1, 0x11); // ODR=800 Hz, Active mode
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user