Command processor to access I2C and SPI Takes URI coded commands and returns JSON array

Fork of SerialInterface by Greg Steiert

Revision:
4:0bd9ec504040
Parent:
3:601b78524967
Child:
5:9e27e2a46fa6
--- a/SerialInterface.cpp	Thu Dec 08 16:32:03 2016 +0000
+++ b/SerialInterface.cpp	Thu Dec 08 21:43:36 2016 +0000
@@ -14,10 +14,12 @@
 }
 
 // Initialize SerialInterface
-void SerialInterface::init(I2C* i2c, SPI* spi)
+void SerialInterface::init(I2C* i2c, SPI* spi, DigitalOut* ssel)
 {
     _i2c = i2c;  // save pointer to I2C interface
     _spi = spi;  // save pointer to SPI interface
+    _ssel = ssel;  // save pointer to Select pin
+    *_ssel = 1;  // deselect SPI port
 }
 
 /* I2C
@@ -85,12 +87,14 @@
     } else {
         sprintf(resp, "[");
         resp++;
+        *_ssel = 0;
         while(dcnt < _args[0]) {
             dcnt++;
             dataIn = (*_spi).write(_args[dcnt]);
             sprintf(resp, "0x%02X,", dataIn);
             resp += 5;
         }
+        *_ssel = 1;
         sprintf((resp-1), "]");
     }
 }