keybrd library is an open source library for creating custom-keyboard firmware.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

PortRead_MCP23S17.cpp 984B

123456789101112131415161718192021222324252627
  1. #include "PortRead_MCP23S17.h"
  2. /* begin() is called from Scanner_IOE::begin().
  3. Configures read pins to input with pullup enabled.
  4. */
  5. void PortRead_MCP23S17::begin(const uint8_t strobeOn)
  6. {
  7. if (strobeOn == LOW) //if active low, use internal pull-up resistors
  8. {
  9. pullUp = readPins;
  10. }
  11. else //active high requires external pull-down resistors
  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. Only portState pins with pull resistors are valid.
  20. */
  21. uint8_t PortRead_MCP23S17::read()
  22. {
  23. return transfer( (port.DEVICE_ADDR << 1) | 1, port.num + 0x12, 0); //read from GPIO
  24. }