keybrd library is an open source library for creating custom-keyboard firmware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

RowPort_MCP23018.h 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef ROWPORT_MCP23018_H
  2. #define ROWPORT_MCP23018_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <Wire.h>
  6. #include <RowPort.h>
  7. #include "IOExpanderPort.h"
  8. /* One MCP23018 I/O expander port connected to matrix rows.
  9. begin() configures column port's IODIR, GPIO.
  10. This should normally be called only once.
  11. Instantiation
  12. ------------
  13. Example instantiation for row port A:
  14. IOExpanderPort portA(0, ~0);
  15. RowPort_MCP23018 rowPortA(portA);
  16. Example instantiation for row port B:
  17. IOExpanderPort portB(1, ~0);
  18. RowPort_MCP23018 rowPortB(portB);
  19. Diode orientation
  20. ----------------
  21. Rows, columns, and diode orientation are explained in Matrix.h
  22. MCP23018 data sheet
  23. ------------------
  24. http://ww1.microchip.com/downloads/en/DeviceDoc/22103a.pdf
  25. */
  26. class RowPort_MCP23018 : public RowPort
  27. {
  28. private:
  29. IOExpanderPort& port;
  30. const uint8_t IODIR; //Input/Ouput Direction register address
  31. const uint8_t GPIO; //General Purpose Input/Ouput register address
  32. public:
  33. //The constructor initialization list is in .cpp
  34. RowPort_MCP23018(IOExpanderPort& port);
  35. void begin();
  36. virtual void setActivePinLow(const uint8_t activePin); //activePin is a port mask
  37. virtual void setActivePinHigh(const uint8_t activePin);
  38. };
  39. #endif