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-B pins are alternately grounded and energized.
|
|
|
|
output is: 10101010
|
|
|
|
*/
|
2016-09-11 15:54:10 +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 portB(IOE_ADDR, 1, ~0); //read all pins
|
2016-09-01 02:29:59 +00:00
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
2016-10-30 08:30:13 +00:00
|
|
|
uint8_t BitPattern; //reading of port B
|
2016-09-01 02:29:59 +00:00
|
|
|
|
|
|
|
delay(6000);
|
2016-10-30 08:30:13 +00:00
|
|
|
portB.begin(HIGH); //HIGH or LOW, does not matter
|
2016-09-01 02:29:59 +00:00
|
|
|
|
2016-10-30 08:30:13 +00:00
|
|
|
BitPattern = portB.read();
|
|
|
|
Keyboard.print("BitPattern = ");
|
|
|
|
Keyboard.println(BitPattern, BIN); //prints 10101010
|
2016-09-01 02:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() { }
|