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.

74 lines
2.4 KiB

  1. // Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license
  2. #pragma once
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. // Convenient way to store and access measurements
  6. typedef struct {
  7. uint16_t xValue;
  8. uint16_t yValue;
  9. uint16_t zValue;
  10. uint8_t buttonFlags;
  11. bool touchDown;
  12. } pinnacle_data_t;
  13. void cirque_pinnacle_init(void);
  14. pinnacle_data_t cirque_pinnacle_read_data(void);
  15. void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution);
  16. uint16_t cirque_pinnacle_get_scale(void);
  17. void cirque_pinnacle_set_scale(uint16_t scale);
  18. #ifndef CIRQUE_PINNACLE_TIMEOUT
  19. # define CIRQUE_PINNACLE_TIMEOUT 20
  20. #endif
  21. // Coordinate scaling values
  22. #ifndef CIRQUE_PINNACLE_X_LOWER
  23. # define CIRQUE_PINNACLE_X_LOWER 127 // min "reachable" X value
  24. #endif
  25. #ifndef CIRQUE_PINNACLE_X_UPPER
  26. # define CIRQUE_PINNACLE_X_UPPER 1919 // max "reachable" X value
  27. #endif
  28. #ifndef CIRQUE_PINNACLE_Y_LOWER
  29. # define CIRQUE_PINNACLE_Y_LOWER 63 // min "reachable" Y value
  30. #endif
  31. #ifndef CIRQUE_PINNACLE_Y_UPPER
  32. # define CIRQUE_PINNACLE_Y_UPPER 1471 // max "reachable" Y value
  33. #endif
  34. #ifndef CIRQUE_PINNACLE_X_RANGE
  35. # define CIRQUE_PINNACLE_X_RANGE (CIRQUE_PINNACLE_X_UPPER - CIRQUE_PINNACLE_X_LOWER)
  36. #endif
  37. #ifndef CIRQUE_PINNACLE_Y_RANGE
  38. # define CIRQUE_PINNACLE_Y_RANGE (CIRQUE_PINNACLE_Y_UPPER - CIRQUE_PINNACLE_Y_LOWER)
  39. #endif
  40. #if defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c)
  41. # include "i2c_master.h"
  42. // Cirque's 7-bit I2C Slave Address
  43. # ifndef CIRQUE_PINNACLE_ADDR
  44. # define CIRQUE_PINNACLE_ADDR 0x2A
  45. # endif
  46. #elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
  47. # include "spi_master.h"
  48. # ifndef CIRQUE_PINNACLE_CLOCK_SPEED
  49. # define CIRQUE_PINNACLE_CLOCK_SPEED 10000000
  50. # endif
  51. # ifndef CIRQUE_PINNACLE_SPI_LSBFIRST
  52. # define CIRQUE_PINNACLE_SPI_LSBFIRST false
  53. # endif
  54. # ifndef CIRQUE_PINNACLE_SPI_MODE
  55. # define CIRQUE_PINNACLE_SPI_MODE 1
  56. # endif
  57. # ifndef CIRQUE_PINNACLE_SPI_DIVISOR
  58. # ifdef __AVR__
  59. # define CIRQUE_PINNACLE_SPI_DIVISOR (F_CPU / CIRQUE_PINNACLE_CLOCK_SPEED)
  60. # else
  61. # define CIRQUE_PINNACLE_SPI_DIVISOR 64
  62. # endif
  63. # ifndef CIRQUE_PINNACLE_SPI_CS_PIN
  64. # error "No Chip Select pin has been defined -- missing CIRQUE_PINNACLE_SPI_CS_PIN define"
  65. # endif
  66. # endif
  67. #endif