2016-10-30 08:30:13 +00:00
|
|
|
/* unit test for Port_MCP23S17
|
2016-09-23 20:52:09 +00:00
|
|
|
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-10-30 08:30:13 +00:00
|
|
|
Use a volt meter to measure port-A GPIO-pin outputs or red LED.
|
2016-09-01 02:29:59 +00:00
|
|
|
*/
|
2016-10-30 08:30:13 +00:00
|
|
|
#include "Port_MCP23S17.h"
|
2016-09-01 02:29:59 +00:00
|
|
|
|
2016-10-30 08:30:13 +00:00
|
|
|
const uint8_t IOE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins grounded
|
|
|
|
Port_MCP23S17 portA(IOE_ADDR , 0, 0); //PortAWrite needed for begin()
|
2016-09-01 02:29:59 +00:00
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
delay(6000);
|
2016-10-30 08:30:13 +00:00
|
|
|
Keyboard.println("start setup");
|
|
|
|
portA.begin(LOW); //HIGH or LOW, not matter if readPins=0
|
|
|
|
Keyboard.println("start loop");
|
2016-09-01 02:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
2016-10-30 08:30:13 +00:00
|
|
|
portA.write(~0, HIGH); //set all GPIOA pins HIGH
|
2016-09-01 02:29:59 +00:00
|
|
|
delay(2000);
|
|
|
|
|
2016-10-30 08:30:13 +00:00
|
|
|
portA.write(~0, LOW); //set all GPIOA pins LOW
|
2016-09-01 02:29:59 +00:00
|
|
|
delay(2000);
|
|
|
|
}
|