4180 lab 1
Dependencies: mbed MCP23S17 PinDetect USBDevice
Revision 8:a5689a2b6af3, committed 2020-01-21
- Comitter:
- emilywilson
- Date:
- Tue Jan 21 20:20:16 2020 +0000
- Parent:
- 7:b7720a8623b5
- Child:
- 9:be04caf5f990
- Commit message:
- part 7 changes
Changed in this revision
| part7.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/part7.h Tue Jan 21 20:02:09 2020 +0000
+++ b/part7.h Tue Jan 21 20:20:16 2020 +0000
@@ -30,8 +30,7 @@
// Optional software reset - mbed p14 to MCP23S17 reset pin
// DigitalOut reset(p14);
-DigitalOut myled(p26);
-DigitalIn pb(p22);
+int pb;
int run_part7() {
// The MCP23S17 reset pin can just be pulled high, since it has a power on reset circuit.
@@ -48,14 +47,13 @@
chip.direction(PORT_A, 0x00);
// Set all 8 Port B bits to input direction
chip.direction(PORT_B, 0xFF);
- myled=0;
// Start Loopback test sending out and reading back values
// loopback test uses A0 and B0 pins - so use a wire to jumper those two pins on MCP23S17 together
while (1) {
// write value of pushbutton to Port A
+ pb = chip.read(PORT_B) & 0x01;
chip.write(PORT_A, !pb);
wait(.5);
// read back value from MCP23S17 Port B and display B0 on myled
- myled = chip.read(PORT_B)& 0x01;
}
}