Forked from romilly. Changed the way SPI handler is injected in constructor

Fork of MCP23S17 by Romilly Cocking

Revision:
10:ca0429a15915
Parent:
9:068b1e8909bb
--- a/MCP23S17.cpp	Sat Aug 28 09:48:38 2010 +0000
+++ b/MCP23S17.cpp	Sun Mar 02 18:15:17 2014 +0000
@@ -8,7 +8,8 @@
 #include "mbed.h"
 #include "MCP23S17.h"
 
-MCP23S17::MCP23S17(SPI& spi, PinName ncs, char writeOpcode) : _spi(spi), _ncs(ncs) {
+MCP23S17::MCP23S17(SPI* spi, PinName ncs, char writeOpcode) : _ncs(ncs) {
+    _spi = spi;
     _writeOpcode = writeOpcode;
     _readOpcode = _writeOpcode | 1; // low order bit = 1 for read
     _init();
@@ -16,9 +17,9 @@
 
 char MCP23S17::_read(char address) {
     _ncs = 0;
-    _spi.write(_readOpcode);
-    _spi.write(address);
-    char result = _spi.write(0);
+    _spi->write(_readOpcode);
+    _spi->write(address);
+    char result = _spi->write(0);
     _ncs = 1;
     return result;
 }
@@ -29,9 +30,9 @@
 
 void MCP23S17::_write(char address, char data) {
     _ncs = 0;
-    _spi.write(_writeOpcode);
-    _spi.write(address);
-    _spi.write(data);
+    _spi->write(_writeOpcode);
+    _spi->write(address);
+    _spi->write(data);
     _ncs = 1;
 }