A device driver for the Freescale MPR121 capactive touch IC. Not optimized for any particular system, just a starting point to get the chip up in running in no time. Changes to registers init() method will tailor the library for end system use.

Dependents:   Seeed_Grove_I2C_Touch_Example MPR121_HelloWorld mbed_petbottle_holder_shikake test_DEV-10508 ... more

Datasheet:

http://cache.freescale.com/files/sensors/doc/data_sheet/MPR121.pdf

Information

Must add pull-ups to the I2C bus!!

Revision:
6:b6bb38744edd
Parent:
5:3934358ec2b7
Parent:
4:c1bc00c5e8e5
--- a/MPR121.cpp	Fri Aug 15 23:00:13 2014 +0000
+++ b/MPR121.cpp	Fri Aug 15 23:04:08 2014 +0000
@@ -194,9 +194,9 @@
     uint8_t result = 0;
 
     result = _i2c->write(_i2c_addr, buf, 2);
-
-    if(result && DEBUG) {
-        debug("I2c write failed\n");
+    if(result && DEBUG)
+    {
+        debug("I2C write failed\n");
     }
 
     return;
@@ -208,10 +208,11 @@
     uint8_t result = 1;
 
     result &= _i2c->write(_i2c_addr, buf, 1, true);
-    result &= _i2c->read(_i2c_addr, &data, 1);
-
-    if(result && DEBUG) {
-        debug("I2c read failed\n");
+    result &= _i2c->read(_i2c_addr, &data, 1); 
+    
+    if(result && DEBUG)
+    {
+        debug("I2C read failed\n");
     }
 
     return data;