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