From f24ea7aa76cb39e0c957e93894a55f1de345302e Mon Sep 17 00:00:00 2001 From: wolfv6 Date: Fri, 23 Sep 2016 14:52:09 -0600 Subject: [PATCH] add refPortWrite.begin(strobeOn) to Scanner_IOE::begin(), update unit tests --- src/PortMCP23S17.cpp | 14 +++----------- src/Scanner_IOE.cpp | 4 +--- tutorials/breadboard_keyboard_supplies.ods | Bin 17707 -> 17707 bytes .../PortMCP23S17_bb.JPG} | Bin .../PortMCP23S17_read.ino} | 13 ++++++------- .../PortMCP23S17_write.ino} | 18 ++++++++---------- 6 files changed, 18 insertions(+), 31 deletions(-) rename unit_tests/{PortRead_MCP23S17/PortRead_MCP23S17_bb.JPG => PortMCP23S17_read/PortMCP23S17_bb.JPG} (100%) rename unit_tests/{PortRead_MCP23S17/PortRead_MCP23S17.ino => PortMCP23S17_read/PortMCP23S17_read.ino} (68%) rename unit_tests/{PortWrite_MCP23S17/PortWrite_MCP23S17.ino => PortMCP23S17_write/PortMCP23S17_write.ino} (60%) diff --git a/src/PortMCP23S17.cpp b/src/PortMCP23S17.cpp index 99141c5..312e013 100644 --- a/src/PortMCP23S17.cpp +++ b/src/PortMCP23S17.cpp @@ -22,6 +22,9 @@ strobeOn is logic level of strobe on, HIGH or LOW MCP23S17 SPI interface is 10 MHz max. The electrical limitation to bus speed is bus capacitance and the length of the wires involved. Longer wires require lower clock speeds. + +begin() is called from Scanner_IOE::begin() twice, once each for refPortWrite and refPortRead. +The first 4 lines only need to be called once, but seem to work OK if called a second time. */ void PortMCP23S17::begin(const uint8_t strobeOn) { @@ -41,10 +44,6 @@ void PortMCP23S17::begin(const uint8_t strobeOn) { pullUp = 0; } -//todo -Keyboard.print(" strobeOn="); Keyboard.print(strobeOn); -Keyboard.print(" readPins="); Keyboard.print(readPins, BIN); -Keyboard.print(" pullUp="); Keyboard.println(pullUp, BIN); transfer(port.DEVICE_ADDR << 1, port.num, readPins); //configure IODIR transfer(port.DEVICE_ADDR << 1, port.num + 0x0C, pullUp); //configure GPPU @@ -65,13 +64,6 @@ void PortMCP23S17::write(const uint8_t pin, const bool logicLevel) { port.outputVal |= pin; //set pin output to high } -//todo -//Keyboard.print(" readPins="); Keyboard.print(readPins, BIN); -Keyboard.print(" pin="); Keyboard.print(pin, BIN); -Keyboard.print(" logicLevel="); Keyboard.print(logicLevel); -Keyboard.print(" outputVal="); Keyboard.println(port.outputVal, BIN); -//Keyboard.print(" ="); Keyboard.print(); -//delay(200); transfer(port.DEVICE_ADDR << 1, port.num + 0x12, port.outputVal); //set GPIO port to outputVal } diff --git a/src/Scanner_IOE.cpp b/src/Scanner_IOE.cpp index 07425b1..6951553 100644 --- a/src/Scanner_IOE.cpp +++ b/src/Scanner_IOE.cpp @@ -13,6 +13,7 @@ Initiates communication protocal and configs ports. void Scanner_IOE::begin() { refPortRead.begin(strobeOn); + refPortWrite.begin(strobeOn); } /* scan() is called on every iteration of sketch loop(). @@ -23,13 +24,10 @@ read_pins_t Scanner_IOE::scan(const uint8_t strobePin) { uint8_t readState; //bits, 1 means key is pressed, 0 means released -delay(2000);//todo //strobe on refPortWrite.write(strobePin, strobeOn); delayMicroseconds(3); //time to stabilize voltage - //delayMicroseconds(300); //todo -delay(2000); //read the port pins readState = refPortRead.read(); diff --git a/tutorials/breadboard_keyboard_supplies.ods b/tutorials/breadboard_keyboard_supplies.ods index fdb7d1581254effa59e2f4da60b7dce80d196253..d7b3dec754e3cbd2cb13543e083f93008a5131e2 100644 GIT binary patch delta 4167 zcmY*ccQ{pd{oDKd_F1bm3Zpa%gIH4y3!4H2!Uus$GUJK0F-tP5Eu0{~ z0W}O^1eQE=B`5+q0LAbb$#Ug}&wa&vjC#9n^R9A^J0^ieb73JWK@QjFbPA{S6!mv) z3z6&RxpAwK92^`=KLs zOIQR6kBdN%hQ{ffy)e~y%0uVIBgn!>2wUdE1mycoy4@%66Gm!29nF=$uG$^JWI3GG zx06>WS7K2~c)NNQQRDcwc*oCLq&an4M@VkcRnfLK>t$}@)tyBC{zM~!N!=42mS_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