keybrd library is an open source library for creating custom-keyboard firmware.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Este repositório está arquivado. Você pode visualizar os arquivos e realizar clone, mas não poderá realizar push nem abrir issues e pull requests.

PortRead_MCP23S17.cpp 858B

12345678910111213141516171819202122232425262728
  1. #include "PortRead_MCP23S17.h"
  2. /* begin() is called from Scanner_IOE::begin().
  3. Configures port to to read (input with pullup enabled).
  4. */
  5. void PortRead_MCP23S17::begin(const uint8_t strobeOn)
  6. {
  7. if (strobeOn == LOW) //if active low
  8. {
  9. pullUp = readPins;
  10. }
  11. else
  12. {
  13. pullUp = 0;
  14. }
  15. transfer(port.DEVICE_ADDR << 1, port.num, readPins); //write, configure IODIR, 0=output, 1=input
  16. transfer(port.DEVICE_ADDR << 1, port.num + 0x0C, pullUp); //write, configure GPPU,
  17. //0=pull-up disabled, 1=pull-up enabled
  18. }
  19. /* read() returns portState.
  20. Only portState bits of readPins are valid.
  21. */
  22. uint8_t PortRead_MCP23S17::read()
  23. {
  24. return transfer( (port.DEVICE_ADDR << 1) | 1, port.num + 0x12, 0); //read from GPIO
  25. }