2016-09-23 20:52:09 +00:00
|
|
|
/* unit test for PortMCP23S17
|
|
|
|
Picture of hardware is in unit_tests/PortMCP23S17_read/PortMCP23S17_bb.JPG
|
2016-09-01 02:29:59 +00:00
|
|
|
The setup is an MCP23S17 I/O expander on a Teensy LC controller.
|
|
|
|
MCP23S17 port-A GPIO pins are not connected to anything.
|
|
|
|
Port-A GPIO-pin ouputs alternate between 0 and 3.3 volts.
|
|
|
|
|
2016-09-11 15:54:10 +00:00
|
|
|
Use a volt meter to measure port-A GPIO-pin outputs.
|
2016-09-23 20:52:09 +00:00
|
|
|
OR low-voltage LED, with forward voltage less than 2 volts.
|
2016-09-01 02:29:59 +00:00
|
|
|
*/
|
|
|
|
#include "PortIOE.h"
|
2016-09-23 20:52:09 +00:00
|
|
|
#include "PortMCP23S17.h"
|
2016-09-01 02:29:59 +00:00
|
|
|
|
2016-09-03 20:25:22 +00:00
|
|
|
const uint8_t PortIOE::DEVICE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins are grounded
|
2016-09-23 20:52:09 +00:00
|
|
|
PortIOE portA(0);
|
2016-09-01 02:29:59 +00:00
|
|
|
|
2016-09-23 20:52:09 +00:00
|
|
|
PortMCP23S17 portAWrite(portA, 0); //PortAWrite needed for begin()
|
2016-09-01 02:29:59 +00:00
|
|
|
|
2016-09-11 15:54:10 +00:00
|
|
|
//const uint8_t GPIOA = 0x12; //LEDs are on port A
|
2016-09-01 02:29:59 +00:00
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
delay(6000);
|
2016-09-23 20:52:09 +00:00
|
|
|
portAWrite.begin(LOW); //HIGH or LOW, not matter if readPins=0
|
|
|
|
Keyboard.print("start writing");
|
2016-09-01 02:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
portAWrite.write(~0, HIGH); //set all GPIOA pins HIGH
|
|
|
|
delay(2000);
|
|
|
|
|
|
|
|
portAWrite.write(~0, LOW); //set all GPIOA pins LOW
|
|
|
|
delay(2000);
|
|
|
|
}
|