keybrd library is an open source library for creating custom-keyboard firmware.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.

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. }