logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

cirque_pinnacle_i2c.c (1333B)


  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_write_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT);
  15. if (i2c_read_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
  16. pd_dprintf("error cirque_pinnacle i2c_read_register\n");
  17. touchpad_init = false;
  18. }
  19. }
  20. }
  21. // Writes single-byte <data> to <address>
  22. void RAP_Write(uint8_t address, uint8_t data) {
  23. uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte
  24. if (touchpad_init) {
  25. if (i2c_write_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
  26. pd_dprintf("error cirque_pinnacle i2c_write_register\n");
  27. touchpad_init = false;
  28. }
  29. }
  30. }