Slight changes to support specific application

Dependents:   ColourSensor

Fork of PCF8574 by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
jolyon
Date:
Thu Nov 10 16:56:33 2016 +0000
Parent:
1:ec8da0c59403
Commit message:
If device does not ack the return data is 0

Changed in this revision

PCF8574.cpp Show annotated file Show diff for this revision Revisions of this file
PCF8574.h Show annotated file Show diff for this revision Revisions of this file
diff -r ec8da0c59403 -r 6c22af0aafbb PCF8574.cpp
--- a/PCF8574.cpp	Thu Jun 03 13:00:49 2010 +0000
+++ b/PCF8574.cpp	Thu Nov 10 16:56:33 2016 +0000
@@ -23,19 +23,26 @@
 #include "PCF8574.h"
 #include "mbed.h"
 
-PCF8574::PCF8574(PinName sda, PinName scl, int address)
+JPCF8574::JPCF8574(PinName sda, PinName scl, int address)
         : _i2c(sda, scl) {
     _address = address;
 }
 
-int PCF8574::read() {
+int JPCF8574::read() {
     char foo[1];
-    _i2c.read(_address, foo, 1);
+    char Error = 0;
+    Error = _i2c.read(_address, foo, 1);
+    if (Error == 1)
+    {
+        foo[0] = 0;    
+    }
+
     return foo[0];
 }
 
-void PCF8574::write(int data) {
+void JPCF8574::write(int data) {
     char foo[1];
     foo[0] = data;
     _i2c.write(_address, foo, 1);
 }
+
diff -r ec8da0c59403 -r 6c22af0aafbb PCF8574.h
--- a/PCF8574.h	Thu Jun 03 13:00:49 2010 +0000
+++ b/PCF8574.h	Thu Nov 10 16:56:33 2016 +0000
@@ -26,7 +26,7 @@
 #define MBED_PCF8574_H
 
 /** Interface to the popular PCF8574 I2C 8 Bit IO expander */
-class PCF8574 {
+class JPCF8574 {
 public:
     /** Create an instance of the PCF8574 connected to specfied I2C pins, with the specified address.
      *
@@ -34,7 +34,7 @@
      * @param scl The I2C clock pin
      * @param address The I2C address for this PCF8574
      */
-    PCF8574(PinName sda, PinName scl, int address);
+    JPCF8574(PinName sda, PinName scl, int address);
 
     /** Read the IO pin level
      *