A simple IO demo using the MCP23S17 library

Dependencies:   mbed MCP23S17

Demo for Microchip MCP23S17 16-bit SPI I/O expander chip on mbed LPC1768 using hardware SPI functions. See comments in main.cpp for pin usage. This chip is still available in a DIP package, so it is easy to try on a breadboard. A complete datasheet for the Microchip MCP23SA17 SPI I/O port expander chip can be found at http://ww1.microchip.com/downloads/en/DeviceDoc/20001952c.pdf

Import programMCP23S17_Basic_IO_Demo

A simple IO demo using the MCP23S17 library

Revision:
1:70e1ebe47253
Parent:
0:12f4911d7ba0
Child:
2:934a0500abde
--- a/main.cpp	Thu Jan 27 03:16:18 2011 +0000
+++ b/main.cpp	Fri Jan 28 01:44:27 2011 +0000
@@ -22,16 +22,22 @@
 // mbed p20 is connected to ~chipSelect on the MCP23S17
 MCP23S17 chip = MCP23S17(spi, p20, writeOpcode);
 
+// Optional software reset - mbed p20 to MCP23S17 reset pin
+// DigitalOut reset(p20);
+
 DigitalOut led1(LED1); // mbed LED1 is used for test status display
 
 int main() {
-//  Nothing has to be connected to the MCP23S17 reset pin since it has a power on reset circuit.
-//  It can be used for a software forced reset by pulling it low with an mbed GPIO pin.
-//  But just leave it unconnected for this simple demo code. It is possible to lock up the chip
-//  if you happen to reset the mbed in the middle of an SPI transfer (not too likely). 
-//  If it happens just remove and attach the USB cable to reset by cycling the power.
+//  The MCP23S17 reset pin can just be pulled high, since it has a power on reset circuit.
+//  The reset pin can be used for a software forced reset by pulling it low with an mbed GPIO pin.
+//  But just leave it pulled high for this simple demo code.
 //  After a power on reset, both IO ports default to input mode
 //
+//  Here is the optional code for a software reset
+//  reset = 0;
+//  wait_us(1);
+//  reset = 1;
+//
 //  Set all 8 Port A bits to output direction
     chip.direction(PORT_A, 0x00);
 //  Set all 8 Port B bits to input direction