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.

PortRead_MCP23S17.h 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef PORTREAD_MCP23S17_H
  2. #define PORTREAD_MCP23S17_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <SPI.h>
  6. #include <PortReadInterface.h>
  7. #include "PortIOE.h"
  8. #include "Scanner_IOE.h"
  9. /* One MCP23S17 I/O expander port connected to matrix columns.
  10. Instantiation todo
  11. ------------
  12. readPins parameter is port's bitwise pin configuration
  13. 1=configure as input (for pins connected to column)
  14. 0=configure as output (for LED or not connected to a column)
  15. Example instantiation for column port 0, with pins 2 and 3 connected to columns:
  16. PortIOE port0(0, 0);
  17. PortRead_MCP23S17 colPort0(port0, 2<<0 | 1<<3 );
  18. Example instantiation for column port 1, with pins 2 and 3 connected to columns:
  19. PortIOE port1(1, 0);
  20. PortRead_MCP23S17 colPort1(port1, 2<<0 | 1<<3 );
  21. readPins are read from pin 0 on up.
  22. */
  23. class PortRead_MCP23S17 : public PortReadInterface
  24. {
  25. private:
  26. PortIOE& port;
  27. uint8_t pullUp; //bitwise, 1 means internal pull-up resistor enabled
  28. const uint8_t readPins; //bitwise, 1 means internal pull-up resistor enabled
  29. public:
  30. PortRead_MCP23S17(PortIOE& port, const uint8_t readPins)
  31. : port(port), readPins(readPins) {}
  32. void begin(const uint8_t strobeOn);
  33. virtual uint8_t read();
  34. };
  35. #endif