This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
2016-09-11 15:54:10 +00:00
|
|
|
/* unit test for PortWrite_MCP23S17
|
|
|
|
Picture of hardware is in unit_tests/PortRead_MCP23S17/PortRead_MCP23S17_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-01 02:29:59 +00:00
|
|
|
MCP23S17 on 3.3v does not output enough power to reliable light LEDs
|
|
|
|
LED lights w/o resistor
|
|
|
|
LED not light with 56 ohm resistor
|
|
|
|
*/
|
|
|
|
#include "PortIOE.h"
|
|
|
|
#include "PortWrite_MCP23S17.h"
|
|
|
|
|
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-01 02:29:59 +00:00
|
|
|
PortIOE portA(0, 0);
|
|
|
|
|
|
|
|
PortWrite_MCP23S17 portAWrite(portA); //PortAWrite needed for begin()
|
|
|
|
|
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);
|
|
|
|
portAWrite.begin();
|
|
|
|
//Keyboard.print("start blinking");
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
portAWrite.write(~0, HIGH); //set all GPIOA pins HIGH
|
|
|
|
delay(2000);
|
|
|
|
|
|
|
|
portAWrite.write(~0, LOW); //set all GPIOA pins LOW
|
|
|
|
delay(2000);
|
|
|
|
}
|