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.

RowScanner_SPIShiftRegisters.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef ROWSCANNER_SPI_SHIFTREGISTERS_H
  2. #define ROWSCANNER_SPI_SHIFTREGISTERS_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <config_keybrd.h>
  6. #include <SPI.h>
  7. #include <RowPort.h>
  8. #include <ColPort.h>
  9. /* RowScanner_SPIShiftRegisters reads shift registers.
  10. shift registers 74HC165 Parallel-In-Serial-Out (PISO)
  11. in sketch:
  12. const uint8_t RowScanner_SPIShiftRegisters::SHIFT_LOAD = 10;
  13. call begin() from setup()
  14. Upto 4 shift registers can be in a daisy chained.
  15. The shift registers are active high:
  16. 10k pull-down resistors are grounded
  17. connect controller's MISO pin to shift register's QH pin
  18. The shift register needs 5 wires.
  19. In addition, each row needs to be connected to a strobe pin from controller.
  20. The two parts of a split keyboard can be connected by one of:
  21. * eSATA cable (has 7 wires, good for 2 rows)
  22. * Ethernet cable (has 8 wires, good for 3 rows)
  23. */
  24. class RowScanner_SPIShiftRegisters
  25. {
  26. private:
  27. static const uint8_t SHIFT_LOAD; //controller's pin number that is connected to shift register's SHIFT_LOAD pin
  28. const uint8_t STROBE_PIN; //Arduino pin number connected to this row
  29. const uint8_t BYTE_COUNT; //number of bytes to read from shift registers
  30. uint8_t KEY_COUNT;
  31. public:
  32. RowScanner_SPIShiftRegisters(const uint8_t STROBE_PIN, uint8_t KEY_COUNT);
  33. virtual read_pins_t scan(uint8_t& KEY_COUNT);
  34. void begin();
  35. };
  36. #endif