Added code to manage Orientation, FreeFall and Motion Detection. Data is also available via IRQ.
Dependents: Test_FRDM_MMA8451Q AccelTest FRDM-KL46-Template KL25Z_Demo ... more
Fork of MMA8451Q by
Revision 11:13e2af71e2cf, committed 2013-08-25
- Comitter:
- clemente
- Date:
- Sun Aug 25 21:53:40 2013 +0000
- Parent:
- 10:fa532bf396fb
- Commit message:
- changed the name of the pointer to user callback function.
Changed in this revision
MMA8451Q.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r fa532bf396fb -r 13e2af71e2cf MMA8451Q.cpp --- a/MMA8451Q.cpp Thu Aug 22 15:21:47 2013 +0000 +++ b/MMA8451Q.cpp Sun Aug 25 21:53:40 2013 +0000 @@ -54,13 +54,13 @@ * * FreeFall --+ +-- Fall_IRQ -----+ * \ / \ -* +-- MMA8451Q_Int2.fall ---+ +--- user2_fptr +* +-- MMA8451Q_Int2.fall ---+ +--- MMA8451Q_usr2_fptr * / \ / * Motion ----+ +-- Motion_IRQ ---+ * * :: The Orientation Detect use the IRQ1 * -* Orientation Detect -- MMA8451Q_Int1.fall --- Orientation_IRQ --- user1_fptr +* Orientation Detect -- MMA8451Q_Int1.fall --- Orientation_IRQ --- MMA8451Q_usr1_fptr * * * :: The data ready use the IRQ2 @@ -68,8 +68,8 @@ * Data Ready -- MMA8451Q_Int2.fall --- DataReady_IRQ --- usr2_fptr * */ -void (*user2_fptr)(void); // Pointers to user function called after -void (*user1_fptr)(void); // IRQ assertion. +void (*MMA8451Q_usr2_fptr)(void); // Pointers to user function called after +void (*MMA8451Q_usr1_fptr)(void); // IRQ assertion. // InterruptIn MMA8451Q_Int1( PTA14); // INT1 @@ -79,8 +79,8 @@ MMA8451Q_Int1.fall( NULL); MMA8451Q_Int2.fall( NULL); - user2_fptr = NULL; - user1_fptr = NULL; + MMA8451Q_usr2_fptr = NULL; + MMA8451Q_usr1_fptr = NULL; Reset(); Active(); @@ -90,8 +90,8 @@ { MMA8451Q_Int1.fall( NULL); MMA8451Q_Int2.fall( NULL); - user2_fptr = NULL; - user1_fptr = NULL; + MMA8451Q_usr2_fptr = NULL; + MMA8451Q_usr1_fptr = NULL; } void MMA8451Q::Reset( void) @@ -148,7 +148,7 @@ data[1] = 0x21; writeRegs(data, 2); - user2_fptr = fptr; + MMA8451Q_usr2_fptr = fptr; MMA8451Q_Int2.fall( this, &MMA8451Q::Fall_IRQ); } @@ -163,7 +163,7 @@ // Read the Motion/Freefall Function to clear the interrupt readRegs( REG_FF_MT_SRC, &t, 1); // Run the user supplied function - user2_fptr(); + MMA8451Q_usr2_fptr(); } } @@ -214,7 +214,7 @@ data[1] = 0x19; writeRegs(data, 2); - user2_fptr = fptr; + MMA8451Q_usr2_fptr = fptr; MMA8451Q_Int2.fall( this, &MMA8451Q::Motion_IRQ); } @@ -230,7 +230,7 @@ // Read the Motion/Freefall Function to clear the interrupt readRegs( REG_FF_MT_SRC, &t, 1); // Run the user supplied function - user2_fptr(); + MMA8451Q_usr2_fptr(); } } @@ -343,7 +343,7 @@ // Step 11: Put the device in Active Mode Active(); - user1_fptr = fptr; + MMA8451Q_usr1_fptr = fptr; MMA8451Q_Int1.fall( this, &MMA8451Q::Orientation_IRQ); } @@ -362,7 +362,7 @@ OrientationState = t; OrientationStateUpdated = 1; // Run the user supplied function - user1_fptr(); + MMA8451Q_usr1_fptr(); } } @@ -401,7 +401,7 @@ data[1] = ((ODR<<3) | 0x01); writeRegs(data, 2); - user2_fptr = fptr; + MMA8451Q_usr2_fptr = fptr; MMA8451Q_Int2.fall( this, &MMA8451Q::DataReady_IRQ); } @@ -417,7 +417,7 @@ // Read the DataReady_IRQ Function to clear the interrupt readRegs( REG_FF_MT_SRC, &t, 1); // Run the user supplied function - user2_fptr(); + MMA8451Q_usr2_fptr(); } }