keybrd library is an open source library for creating custom-keyboard firmware.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

PortWrite_MCP23S17.h 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef PORTWRITE_MCP23S17_H
  2. #define PORTWRITE_MCP23S17_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <SPI.h>
  6. #include <PortWriteInterface.h>
  7. #include "PortMCP23S17.h"
  8. #include "PortIOE.h"
  9. /* One MCP23S17 I/O expander port connected to matrix rows.
  10. write() can output logiclevel to strobePin, one LED pin, or multiple pins.
  11. This class has Slave Select hardcoded to Arduino Pin 10.
  12. Arduino Pin 10 avoids the speed penalty of digitalWrite.
  13. Instantiation
  14. ------------
  15. Example instantiation:
  16. const uint8_t PortIOE::DEVICE_ADDR = 0x20; //MCP23S17 address, all 3 ADDR pins are grounded
  17. PortIOE port_B(1);
  18. PortWrite_MCP23S17 portWrite_B(port_B);
  19. Diode orientation
  20. ----------------
  21. Diode orientation is explained in keybrd_library_user_guide.md > Diode orientation
  22. MCP23S17 data sheet
  23. ------------------
  24. http://www.onsemi.com/pub_link/Collateral/MCP23S17-D.PDF
  25. */
  26. class PortWrite_MCP23S17 : public PortWriteInterface, public PortMCP23S17
  27. {
  28. private:
  29. PortIOE& port;
  30. public:
  31. PortWrite_MCP23S17(PortIOE& port) : port(port) {}
  32. void begin();
  33. virtual void write(const uint8_t pin, const bool logicLevel);
  34. };
  35. #endif