12345678910111213141516171819202122232425262728293031323334353637383940 |
- #include "RowPort_MCP23018.h"
-
- /*
- configures column port's IODIR, GPIO.
- */
- RowPort_MCP23018::RowPort_MCP23018(IOExpanderPort& port)
- : port(port), IODIR(port.num), GPIO(port.num + 0x12)
- {}
-
- void RowPort_MCP23018::begin()
- {
- Wire.beginTransmission(port.ADDR);
- Wire.write(IODIR);
- Wire.write(0); //0=configure as output (for strobe pins and LED pins)
- Wire.endTransmission();
- }
-
- /*
- sets activePin pin output to low.
- activePin is port mask, where active-low pin is 1.
- */
- void RowPort_MCP23018::setActivePinLow(const uint8_t activePin)
- {
- Wire.beginTransmission(port.ADDR);
- Wire.write(GPIO);
- Wire.write(port.outputVal &= ~activePin);
- Wire.endTransmission();
- }
-
- /*
- sets activePin pin output to high, does not reset the other pins because they might be used by LEDs.
- activePin is port mask, where active-high pin is 1.
- */
- void RowPort_MCP23018::setActivePinHigh(const uint8_t activePin)
- {
- Wire.beginTransmission(port.ADDR);
- Wire.write(GPIO);
- Wire.write(port.outputVal |= activePin);
- Wire.endTransmission();
- }
|