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.

PortRead_PCA9655E.cpp 865B

1234567891011121314151617181920212223242526
  1. #include "PortRead_PCA9655E.h"
  2. /* begin() is called from Scanner_IOE::begin().
  3. Configures read pins to input.
  4. */
  5. void PortRead_PCA9655E::begin(const uint8_t strobeOn)
  6. {
  7. Wire.beginTransmission(port.DEVICE_ADDR);
  8. Wire.write(port.num + 6); //configuration byte command
  9. Wire.write(readPins); //0=output (for LED), 1=input (for read)
  10. Wire.endTransmission();
  11. }
  12. /* read() returns portState.
  13. Only portState bits of readPins are valid.
  14. */
  15. uint8_t PortRead_PCA9655E::read()
  16. {
  17. Wire.beginTransmission(port.DEVICE_ADDR);
  18. Wire.write(port.num); //input byte command
  19. Wire.endTransmission(false); //PCA9655E needs false to send a restart
  20. Wire.requestFrom(port.DEVICE_ADDR, 1u); //request one byte from input port
  21. return Wire.read();
  22. }