a
Fork of FRDM_MMA8451Q by
Revision 12:37acb52ade50, committed 2016-12-17
- Comitter:
- rendek4
- Date:
- Sat Dec 17 21:22:50 2016 +0000
- Parent:
- 11:13e2af71e2cf
- Commit message:
- akcelerometer
Changed in this revision
MMA8451Q.cpp | Show annotated file Show diff for this revision Revisions of this file |
MMA8451Q.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 13e2af71e2cf -r 37acb52ade50 MMA8451Q.cpp --- a/MMA8451Q.cpp Sun Aug 25 21:53:40 2013 +0000 +++ b/MMA8451Q.cpp Sat Dec 17 21:22:50 2016 +0000 @@ -1,21 +1,3 @@ -/* Copyright (c) 2010-2011 mbed.org, MIT License -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - #include "MMA8451Q.h" #define REG_STATUS 0x00 @@ -35,39 +17,17 @@ #define REG_P_L_THS 0x14 #define REG_PL_STATUS 0x10 -// #define REG_OUT_X_MSB 0x01 #define REG_OUT_Y_MSB 0x03 #define REG_OUT_Z_MSB 0x05 #define UINT14_MAX 16383 -// #define ZYXDR 0x08 #define ZDR 0x04 #define YDR 0x02 #define XDR 0x01 -/** Interrupt schema -* -* :: The FreeFall and Motion detection share the same IRQ2. -* -* FreeFall --+ +-- Fall_IRQ -----+ -* \ / \ -* +-- MMA8451Q_Int2.fall ---+ +--- MMA8451Q_usr2_fptr -* / \ / -* Motion ----+ +-- Motion_IRQ ---+ -* -* :: The Orientation Detect use the IRQ1 -* -* Orientation Detect -- MMA8451Q_Int1.fall --- Orientation_IRQ --- MMA8451Q_usr1_fptr -* -* -* :: The data ready use the IRQ2 -* -* Data Ready -- MMA8451Q_Int2.fall --- DataReady_IRQ --- usr2_fptr -* -*/ void (*MMA8451Q_usr2_fptr)(void); // Pointers to user function called after void (*MMA8451Q_usr1_fptr)(void); // IRQ assertion. @@ -102,96 +62,34 @@ wait( 0.1); } -void MMA8451Q::FreeFallDetection( void(*fptr)(void)) -{ - // Soft Reset - Reset(); - - // Example Steps for Configuring Linear Freefall Detection - // X AND Y AND Z < 0.2g using MFF Function, 50 Hz ODR - // Step 1: Put the device in Standby Mode: Register 0x2A CTRL_REG1 - unsigned char data[2] = {REG_CTRL_REG_1, 0x20}; - writeRegs(data, 2); - - // Step 2: Configuration Register set for Freefall Detection enabling “AND” condition, OAE = 0, Enabling X, - // Y, Z and the Latch - data[0] = REG_FF_MT_CFG; - data[1] = 0x01; - writeRegs(data, 2); - - // Step 3: Threshold Setting Value for the resulting acceleration < 0.2g - // Note: The step count is 0.063g/count - // • 0.2g/0.063g = 3.17 counts //Round to 3 counts - data[0] = REG_FF_MT_THS; - data[1] = 0x03; - writeRegs(data, 2); - - // Step 4: Set the debounce counter to eliminate false positive readings for 50Hz sample rate with a - // requirement of 120 ms timer, assuming Normal Mode. - // Note: 120 ms/20 ms (steps) = 6 counts - data[0] = REG_FF_MT_CNT; - data[1] = 0x06; - writeRegs(data, 2); - - // Step 5: Enable Motion/Freefall Interrupt Function in the System (CTRL_REG4) - data[0] = REG_CTRL_REG_4; - data[1] = 0x04; - writeRegs(data, 2); - - // Step 6: Route the Motion/Freefall Interrupt Function to INT2 hardware pin (CTRL_REG5) - data[0] = REG_CTRL_REG_5; - data[1] = 0x00; - writeRegs(data, 2); - - // Step 7: Put the device in Active Mode, 50 Hz - data[0] = REG_CTRL_REG_1; - data[1] = 0x21; - writeRegs(data, 2); - - MMA8451Q_usr2_fptr = fptr; - MMA8451Q_Int2.fall( this, &MMA8451Q::Fall_IRQ); -} - -void MMA8451Q::Fall_IRQ( void) -{ - unsigned char t; - - // Determine source of the interrupt by first reading the system interrupt - readRegs( REG_INT_SRC, &t, 1); - // - if ( (t & 0x04) == 0x04) { - // Read the Motion/Freefall Function to clear the interrupt - readRegs( REG_FF_MT_SRC, &t, 1); - // Run the user supplied function - MMA8451Q_usr2_fptr(); - } -} void MMA8451Q::MotionDetection( void(*fptr)(void)) { - // Soft Reset Reset(); + //data sheet MMA8451Q.pdf strana 45 // 6.1 Example Steps for Configuring Motion Detection // X or Y > 3g using MFF Function 4g, 100 Hz ODR, Normal Mode // Step 1: Put the device into Standby Mode: Register 0x2A CTRL_REG1 unsigned char data[2] = {REG_CTRL_REG_1, 0x18}; // Set the device in 100 Hz ODR, Standby writeRegs(data, 2); - + //data sheet MMA8451Q.pdf strana 32 // Step 2: Set Configuration Register for Motion Detection by setting the “OR” condition OAE = 1, enabling // X, Y, and the latch data[0] = REG_FF_MT_CFG; data[1] = 0xD8; writeRegs(data, 2); + //data sheet MMA8451Q.pdf strana 34 // Step 3: Threshold Setting Value for the Motion detection of > 2g // Note: The step count is 0.063g/ count // • 1g/0.063g = 15.8; //Round up to 16 data[0] = REG_FF_MT_THS; - data[1] = 0x10; + data[1] = 0x08; writeRegs(data, 2); + //data sheet MMA8451Q.pdf strana 32 // Step 4: Set the debounce counter to eliminate false readings for 100 Hz sample rate with a requirement // of 100 ms timer. // Note: 100 ms/10 ms (steps) = 10 counts @@ -199,16 +97,19 @@ data[1] = 0x0A; writeRegs(data, 2); + //data sheet MMA8451Q.pdf strana 48 // Step 5: Enable Motion/Freefall Interrupt Function in the System (CTRL_REG4) data[0] = REG_CTRL_REG_4; data[1] = 0x04; writeRegs(data, 2); + //data sheet MMA8451Q.pdf strana 48 // Step 6: Route the Motion/Freefall Interrupt Function to INT2 hardware pin (CTRL_REG5) data[0] = REG_CTRL_REG_5; data[1] = 0x00; writeRegs(data, 2); + // Step 7: Put the device in Active Mode data[0] = REG_CTRL_REG_1; data[1] = 0x19; @@ -216,212 +117,23 @@ MMA8451Q_usr2_fptr = fptr; MMA8451Q_Int2.fall( this, &MMA8451Q::Motion_IRQ); +} -} void MMA8451Q::Motion_IRQ( void) { unsigned char t; - // Determine source of the interrupt by first reading the system interrupt readRegs( REG_INT_SRC, &t, 1); // if ( (t & 0x04) == 0x04) { - // Read the Motion/Freefall Function to clear the interrupt + readRegs( REG_FF_MT_SRC, &t, 1); - // Run the user supplied function + MMA8451Q_usr2_fptr(); } } -void MMA8451Q::OrientationDetect( void(*fptr)(void)) -{ - OrientationDetect( fptr, Z_LOCKOUT_14, Z_BKFR_80, PL_THS_15, PL_HYS_0); -} - -void MMA8451Q::OrientationDetect( void(*fptr)(void), unsigned int Z_LockOut, unsigned int Z_BkFr, unsigned int PL_Thsld, unsigned int PL_Hyst) -{ - unsigned char t; - - // Soft Reset - Reset(); - - // Reset orientation value. - OrientationState = 0; - OrientationStateUpdated = 0; - - // Step 1: Put the part into Standby Mode - Standby(); - - // Step 2: Set the data rate to 50 Hz (for example, but can choose any sample rate). - readRegs( REG_CTRL_REG_1, &t, 1); // Note: Can combine this step with above - t &= 0xC7; // Clear the sample rate bits - t |= 0x20; // Set the sample rate bits to 50 Hz - unsigned char data[2] = {REG_CTRL_REG_1, t}; - writeRegs(data, 2); // Write updated value into the register. - - - // Step 3: Set the PL_EN bit in Register 0x11 PL_CFG. This will enable the orientation detection. - readRegs( REG_DBCNTM, &t, 1); - data[0] = REG_DBCNTM; - data[1] = t | 0x40; - writeRegs(data, 2); - - // Step 4: Set the Back/Front Angle trip points in register 0x13 following the table in the data sheet. - // NOTE: This register is readable in all versions of MMA845xQ but it is only modifiable in the - // MMA8451Q. - readRegs( REG_BKFR, &t, 1); - t &= 0x3F; // Clear bit 7 and 6 - data[0] = REG_BKFR; - data[1] = t | Z_BkFr; - writeRegs(data, 2); // Write in the updated Back/Front Angle - - // Step 5: Set the Z-Lockout angle trip point in register 0x13 following the table in the data sheet. - // NOTE: This register is readable in all versions of MMA845xQ but it is only modifiable in the - // MMA8451Q. - readRegs( REG_BKFR, &t, 1); - t &= 0xF8; // Clear the last three bits of the register - data[0] = REG_BKFR; - data[1] = t | Z_LockOut; - writeRegs(data, 2); // Write in the updated Z-lockout angle - - // Step 6: Set the Trip Threshold Angle - // NOTE: This register is readable in all versions of MMA845xQ but it is only modifiable in the - // MMA8451Q. - // Select the angle desired in the table, and, - // Enter in the values given in the table for the corresponding angle. - // Refer to Figure 7 for the reference frame of the trip angles. - readRegs( REG_P_L_THS, &t, 1); - t &= 0x07; // Clear the Threshold values - data[0] = REG_P_L_THS; - data[1] = t | (PL_Thsld<<3); - writeRegs(data, 2); - - // Step 7: Set the Hysteresis Angle - // NOTE: This register is readable in all versions of MMA845xQ but it is only modifiable in the - // MMA8451Q. - // Select the hysteresis value based on the desired final trip points (threshold + hysteresis) - // Enter in the values given in the table for that corresponding angle. - // Note: Care must be taken. Review the final resulting angles. Make sure there isn’t a resulting trip value - // greater than 90 or less than 0. - // The following are the options for setting the hysteresis. - readRegs( REG_P_L_THS, &t, 1); - t &= 0xF8; // Clear the Hysteresis values - data[0] = REG_P_L_THS; - data[1] = t | PL_Hyst; - writeRegs(data, 2); - - // Step 8: Register 0x2D, Control Register 4 configures all embedded features for interrupt - // detection. - // To set this device up to run an interrupt service routine: - // Program the Orientation Detection bit in Control Register 4. - // Set bit 4 to enable the orientation detection “INT_EN_LNDPRT”. - readRegs( REG_CTRL_REG_4, &t, 1); - data[0] = REG_CTRL_REG_4; - data[1] = t | 0x10; // Set bit 4 - writeRegs(data, 2); - - // Step 9: Register 0x2E is Control Register 5 which gives the option of routing the interrupt to - // either INT1 or INT2 - // Depending on which interrupt pin is enabled and configured to the processor: - // Set bit 4 “INT_CFG_LNDPRT” to configure INT1, or, - // Leave the bit clear to configure INT2. - readRegs( REG_CTRL_REG_5, &t, 1); - data[0] = REG_CTRL_REG_5; - data[1] = t | 0x10; // Set bit 4 to choose the interrupt to route to INT1 - writeRegs(data, 2); - - // Step 10: Set the debounce counter in register 0x12 - // This value will scale depending on the application-specific required ODR. - // If the device is set to go to sleep, reset the debounce counter before the device goes to sleep. This setting - // helps avoid long delays since the debounce will always scale with the current sample rate. The debounce - // can be set between 50 ms - 100 ms to avoid long delays. - data[0] = REG_DBNCE; - data[1] = 0x05; // This sets the debounce counter to 100 ms at 50 Hz - writeRegs(data, 2); - - // Step 11: Put the device in Active Mode - Active(); - - MMA8451Q_usr1_fptr = fptr; - MMA8451Q_Int1.fall( this, &MMA8451Q::Orientation_IRQ); - -} - -void MMA8451Q::Orientation_IRQ( void) -{ - unsigned char t; - - // Determine source of the interrupt by first reading the system interrupt - readRegs( REG_INT_SRC, &t, 1); - // - if ( (t & 0x10) == 0x10) { - // Read the PL State from the Status Register, clear the interrupt - readRegs( REG_PL_STATUS, &t, 1); - // Set the orientation state variable - OrientationState = t; - OrientationStateUpdated = 1; - // Run the user supplied function - MMA8451Q_usr1_fptr(); - } -} - -unsigned char MMA8451Q::GetOrientationState( void) -{ - if ( OrientationStateUpdated) { - OrientationStateUpdated = 0; - return OrientationState; - } - // - return 0; -} - -void MMA8451Q::DataReady( void(*fptr)(void), unsigned char ODR) -{ - // Soft Reset - Reset(); - - // Step 1: Put the device into Standby Mode: Register 0x2A CTRL_REG1 - // Set the device ODR value and Standby - unsigned char data[2] = {REG_CTRL_REG_1, ((ODR<<3) & 0xFE)}; - writeRegs(data, 2); - - // Step 2: Enable Data Ready Interrupt Function in the System (CTRL_REG4) - data[0] = REG_CTRL_REG_4; - data[1] = 0x01; - writeRegs(data, 2); - - // Step 6: Route the Data Ready Interrupt Function to INT2 hardware pin (CTRL_REG5) - data[0] = REG_CTRL_REG_5; - data[1] = 0x00; - writeRegs(data, 2); - - // Step 7: Put the device in Active Mode - data[0] = REG_CTRL_REG_1; - data[1] = ((ODR<<3) | 0x01); - writeRegs(data, 2); - - MMA8451Q_usr2_fptr = fptr; - MMA8451Q_Int2.fall( this, &MMA8451Q::DataReady_IRQ); - -} - -void MMA8451Q::DataReady_IRQ( void) -{ - unsigned char t; - - // Determine source of the interrupt by first reading the system interrupt - readRegs( REG_INT_SRC, &t, 1); - // - if ( (t & 0x01) == 0x01) { - // Read the DataReady_IRQ Function to clear the interrupt - readRegs( REG_FF_MT_SRC, &t, 1); - // Run the user supplied function - MMA8451Q_usr2_fptr(); - } -} - - void MMA8451Q::Active( void) { unsigned char t; @@ -442,12 +154,6 @@ writeRegs(data, 2); } -uint8_t MMA8451Q::getWhoAmI() { - uint8_t who_am_i = 0; - readRegs(REG_WHO_AM_I, &who_am_i, 1); - return who_am_i; -} - float MMA8451Q::getAccX() { return (float(getAccAxis(REG_OUT_X_MSB))/4096.0); } @@ -478,58 +184,6 @@ return acc; } -unsigned int MMA8451Q::getAccRawAllAxis( int16_t * res) -{ - if ( isDataAvailable() & ZYXDR) - { - getAccRawX( &res[0]); - getAccRawY( &res[1]); - getAccRawZ( &res[2]); - return 1; - } else - return 0; -} - -int16_t MMA8451Q::getAccRawX( int16_t * res) -{ - if ( isDataAvailable() & XDR) - { - *res = getAccAxis(REG_OUT_X_MSB); - return 1; - } else - return 0; -} - -int16_t MMA8451Q::getAccRawY( int16_t * res) -{ - if ( isDataAvailable() & YDR) - { - *res = getAccAxis(REG_OUT_Y_MSB); - return 1; - } else - return 0; -} - -int16_t MMA8451Q::getAccRawZ( int16_t * res) -{ - if ( isDataAvailable() & ZDR) - { - *res = getAccAxis(REG_OUT_Z_MSB); - return 1; - } else - return 0; -} - -unsigned int MMA8451Q::isDataAvailable( void) -{ - unsigned char status; - - readRegs( REG_STATUS, &status, 1); - - return (status); - -} - void MMA8451Q::readRegs(int addr, uint8_t * data, int len) { char t[1] = {addr}; m_i2c.write(m_addr, t, 1, true);
diff -r 13e2af71e2cf -r 37acb52ade50 MMA8451Q.h --- a/MMA8451Q.h Sun Aug 25 21:53:40 2013 +0000 +++ b/MMA8451Q.h Sat Dec 17 21:22:50 2016 +0000 @@ -1,101 +1,8 @@ -/* Copyright (c) 2010-2011 mbed.org, MIT License -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - #ifndef MMA8451Q_H #define MMA8451Q_H #include "mbed.h" -/** -* MMA8451Q accelerometer example -* -* @code -* #include "mbed.h" -* #include "MMA8451Q.h" -* -* #define MMA8451_I2C_ADDRESS (0x1d<<1) -* -* int main(void) { -* -* MMA8451Q acc(P_E25, P_E24, MMA8451_I2C_ADDRESS); -* PwmOut rled(LED_RED); -* PwmOut gled(LED_GREEN); -* PwmOut bled(LED_BLUE); -* -* while (true) { -* rled = 1.0 - abs(acc.getAccX()); -* gled = 1.0 - abs(acc.getAccY()); -* bled = 1.0 - abs(acc.getAccZ()); -* wait(0.1); -* } -* } -* @endcode -*/ - -// Z-Lock Threshold Angles -#define Z_LOCKOUT_14 0 // Angle to 14° -#define Z_LOCKOUT_18 1 // Angle to 18° -#define Z_LOCKOUT_21 2 // Angle to 21° -#define Z_LOCKOUT_25 3 // Angle to 25° -#define Z_LOCKOUT_29 4 // Angle to 29° -#define Z_LOCKOUT_33 5 // Angle to 33° -#define Z_LOCKOUT_37 6 // Angle to 37° -#define Z_LOCKOUT_42 7 // Angle to 42° -// Back/Front Orientation Definition -#define Z_BKFR_80 0 // Back and Front trip angle -#define Z_BKFR_75 1 // Back and Front trip angle -#define Z_BKFR_70 2 // Back and Front trip angle -#define Z_BKFR_65 3 // Back and Front trip angle -// Threshold Angle Thresholds Lookup Table -#define PL_THS_15 0x07 // Set Threshold to 15° -#define PL_THS_20 0x09 // Set Threshold to 20° -#define PL_THS_30 0x0C // Set Threshold to 30° -#define PL_THS_35 0x0D // Set Threshold to 35° -#define PL_THS_40 0x0F // Set Threshold to 40° -#define PL_THS_45 0x10 // Set Threshold to 45° -#define PL_THS_55 0x13 // Set Threshold to 55° -#define PL_THS_60 0x14 // Set Threshold to 60° -#define PL_THS_70 0x17 // Set Threshold to 70° -#define PL_THS_75 0x19 // Set Threshold to 75° -// Trip Angles with Hysteresis for 45° Angle -#define PL_HYS_0 0x00 // Set Hysteresis to ±0° -#define PL_HYS_4 0x01 // Set Hysteresis to ±4° -#define PL_HYS_7 0x02 // Set Hysteresis to ±7° -#define PL_HYS_11 0x03 // Set Hysteresis to ±11° -#define PL_HYS_14 0x04 // Set Hysteresis to ±14° -#define PL_HYS_17 0x05 // Set Hysteresis to ±17° -#define PL_HYS_21 0x06 // Set Hysteresis to ±21° -#define PL_HYS_24 0x07 // Set Hysteresis to ±24° -// Landscape/Portrait orientation -#define cLAPO_PU 0 // Portrait Up: Equipment standing vertically in the normal orientation -#define cLAPO_PD 1 // Portrait Down: Equipment standing vertically in the inverted orientation -#define cLAPO_LR 2 // Landscape Right: Equipment is in landscape mode to the right -#define cLAPO_LL 3 // Landscape Left: Equipment is in landscape mode to the left. -// System Output Data Rate for acceleration samples -#define cODR_800HZ 0 // 1.25 ms -#define cODR_400HZ 1 // 2.5 ms -#define cODR_200HZ 2 // 5 ms -#define cODR_100HZ 3 // 10 ms -#define cODR_50HZ 4 // 20 ms -#define cODR_12_5HZ 5 // 80 ms -#define cODR_6_25HZ 6 // 160 ms -#define cODR_1_56HZ 7 // 640 ms - class MMA8451Q { public: @@ -113,76 +20,28 @@ */ ~MMA8451Q(); - /** - * Get the value of the WHO_AM_I register - * - * @returns WHO_AM_I value - */ - uint8_t getWhoAmI(); - - /** - * Get X axis acceleration - * - * @returns X axis acceleration - */ - float getAccX(); - - /** - * Get Y axis acceleration - * - * @returns Y axis acceleration - */ - float getAccY(); - - /** - * Get Z axis acceleration - * - * @returns Z axis acceleration - */ - float getAccZ(); - - /** - * Get XYZ axis acceleration - * - * @param res array where acceleration data will be stored - */ - void getAccAllAxis(float * res); +float getAccX(); + + /** + * Get Y axis acceleration + * + * @returns Y axis acceleration + */ + float getAccY(); - /** - * Get raw value for X axis acceleration - * - * @returns X axis acceleration - */ - int16_t getAccRawX( int16_t * res); - - /** - * Get raw value for Y axis acceleration - * - * @returns Y axis acceleration - */ - int16_t getAccRawY( int16_t * res); - - /** - * Get raw value for Z axis acceleration - * - * @returns Z axis acceleration - */ - int16_t getAccRawZ( int16_t * res); + /** + * Get Z axis acceleration + * + * @returns Z axis acceleration + */ + float getAccZ(); - /** - * Get raw values for XYZ axis acceleration - * - * @param res array where acceleration data will be stored - */ - unsigned int getAccRawAllAxis(int16_t * res); - - /** - * Configure the Accelerometere for free fall detection - * - * @param pointer to the user function to execute after IRQ assertion - * @return none - */ - void FreeFallDetection( void(*fptr)(void)); + /** + * Get XYZ axis acceleration + * + * @param res array where acceleration data will be stored + */ + void getAccAllAxis(float * res); /** * Configure the Accelerometere for motion detection @@ -191,56 +50,8 @@ * @return none */ void MotionDetection( void(*fptr)(void)); - - /** - * Configure the Accelerometere for orientation detection - * - * @param pointer to the user function to execute after IRQ assertion - * @param Z lockout value, Z Backfront, Port/Landscape Thsld, Port/Landscape Hysteresis - * @return none - */ - void OrientationDetect( void(*fptr)(void), unsigned int Z_LockOut, unsigned int Z_BkFr, unsigned int PL_Thsld, unsigned int PL_Hyst); - void OrientationDetect( void(*fptr)(void)); - - /** - * Get the orientation state. - * - * 0x10: PL_STATUS Register (Read Only) - * Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 - * NEWLP LO — — — LAPO[1] LAPO[0] BAFRO - * - * NEWLP - * Landscape/Portrait status change flag. Default value: 0. - * 0: No change, 1: BAFRO and/or LAPO and/or Z-Tilt lockout value has changed - * LO - * Z-Tilt Angle Lockout. Default value: 0. - * 0: Lockout condition has not been detected. - * 1: Z-Tilt lockout trip angle has been exceeded. Lockout has been detected. - * LAPO[1:0](*) - * Landscape/Portrait orientation. Default value: 00 - * 00: Portrait Up: Equipment standing vertically in the normal orientation - * 01: Portrait Down: Equipment standing vertically in the inverted orientation - * 10: Landscape Right: Equipment is in landscape mode to the right - * 11: Landscape Left: Equipment is in landscape mode to the left. - * (*) The default power up state is BAFRO = 0, LAPO = 0, and LO = 0. - * BAFRO - * Back or Front orientation. Default value: 0 - * 0: Front: Equipment is in the front facing orientation. - * 1: Back: Equipment is in the back facing orientation. - */ - unsigned char GetOrientationState( void); /** - * Configure the Accelerometer to generate a IRQ when a new sample is available - * - * @param pointer to the user function to execute after IRQ assertion - * @return none - */ - void DataReady( void(*fptr)(void), unsigned char ODR); - - unsigned int isDataAvailable( void); - - /** * Soft Reset * @param none * @return none @@ -255,13 +66,7 @@ int16_t getAccAxis(uint8_t addr); void Standby( void); void Active( void); - void Fall_IRQ( void); void Motion_IRQ( void); - void Orientation_IRQ( void); - void DataReady_IRQ( void); - // - unsigned char OrientationState; - unsigned char OrientationStateUpdated; }; #endif