Forked MMA7660 , extend implementation by using i2c asynch API, to sleep while waiting for transfer -> blocking asynch :-D
Fork of MMA7660 by
Diff: MMA7660.h
- Revision:
- 5:556829f081f6
- Parent:
- 2:a8e20db7901e
--- a/MMA7660.h Tue May 13 18:14:34 2014 +0000
+++ b/MMA7660.h Tue May 05 07:23:40 2015 +0000
@@ -83,8 +83,9 @@
* @param sda - I2C data pin
* @param scl - I2C clock pin
* @param active - true (default) to enable the device, false to keep it standby
+ * @param asynch - use asynch i2c - the API is blocking which does not break the current app
*/
- MMA7660(PinName sda, PinName scl, bool active = true);
+ MMA7660(PinName sda, PinName scl, bool active = true, bool asynch = false);
/**
* Tests if communication is possible with the MMA7660
@@ -168,6 +169,8 @@
private:
+ void callback(int event);
+
/**
* Writes data to the device
*
@@ -201,6 +204,9 @@
I2C _i2c;
bool active;
float samplerate;
+ volatile bool callback_done;
+ event_callback_t event;
+ const bool asynch;
};
