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.

37 lines
1.3 KiB

  1. // Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license
  2. #include "cirque_pinnacle.h"
  3. #include "i2c_master.h"
  4. #include "stdio.h"
  5. // Masks for Cirque Register Access Protocol (RAP)
  6. #define WRITE_MASK 0x80
  7. #define READ_MASK 0xA0
  8. extern bool touchpad_init;
  9. /* RAP Functions */
  10. // Reads <count> Pinnacle registers starting at <address>
  11. void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
  12. uint8_t cmdByte = READ_MASK | address; // Form the READ command byte
  13. if (touchpad_init) {
  14. i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT);
  15. if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
  16. pd_dprintf("error cirque_pinnacle i2c_readReg\n");
  17. touchpad_init = false;
  18. }
  19. i2c_stop();
  20. }
  21. }
  22. // Writes single-byte <data> to <address>
  23. void RAP_Write(uint8_t address, uint8_t data) {
  24. uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte
  25. if (touchpad_init) {
  26. if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
  27. pd_dprintf("error cirque_pinnacle i2c_writeReg\n");
  28. touchpad_init = false;
  29. }
  30. i2c_stop();
  31. }
  32. }