diff options
Diffstat (limited to 'drivers/sensors/pmw3360.h')
| -rw-r--r-- | drivers/sensors/pmw3360.h | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/drivers/sensors/pmw3360.h b/drivers/sensors/pmw3360.h index 7429a6ba0..7b2bef5b8 100644 --- a/drivers/sensors/pmw3360.h +++ b/drivers/sensors/pmw3360.h | |||
| @@ -18,6 +18,8 @@ | |||
| 18 | 18 | ||
| 19 | #pragma once | 19 | #pragma once |
| 20 | 20 | ||
| 21 | #include <stdint.h> | ||
| 22 | #include "report.h" | ||
| 21 | #include "spi_master.h" | 23 | #include "spi_master.h" |
| 22 | 24 | ||
| 23 | #ifndef PMW3360_CPI | 25 | #ifndef PMW3360_CPI |
| @@ -25,7 +27,7 @@ | |||
| 25 | #endif | 27 | #endif |
| 26 | 28 | ||
| 27 | #ifndef PMW3360_CLOCK_SPEED | 29 | #ifndef PMW3360_CLOCK_SPEED |
| 28 | # define PMW3360_CLOCK_SPEED 70000000 | 30 | # define PMW3360_CLOCK_SPEED 2000000 |
| 29 | #endif | 31 | #endif |
| 30 | 32 | ||
| 31 | #ifndef PMW3360_SPI_LSBFIRST | 33 | #ifndef PMW3360_SPI_LSBFIRST |
| @@ -52,6 +54,17 @@ | |||
| 52 | # error "No chip select pin defined -- missing PMW3360_CS_PIN" | 54 | # error "No chip select pin defined -- missing PMW3360_CS_PIN" |
| 53 | #endif | 55 | #endif |
| 54 | 56 | ||
| 57 | /* | ||
| 58 | The pmw33660 and pmw3389 use the same registers and timing and such. | ||
| 59 | The only differences between the two is the firmware used, and the | ||
| 60 | range for the DPI. So add a semi-secret hack to allow use of the | ||
| 61 | pmw3389's firmware blob. Also, can set the max cpi range too. | ||
| 62 | This should work for the 3390 and 3391 too, in theory. | ||
| 63 | */ | ||
| 64 | #ifndef PMW3360_FIRMWARE_H | ||
| 65 | # define PMW3360_FIRMWARE_H "pmw3360_firmware.h" | ||
| 66 | #endif | ||
| 67 | |||
| 55 | #ifdef CONSOLE_ENABLE | 68 | #ifdef CONSOLE_ENABLE |
| 56 | void print_byte(uint8_t byte); | 69 | void print_byte(uint8_t byte); |
| 57 | #endif | 70 | #endif |
| @@ -64,19 +77,18 @@ typedef struct { | |||
| 64 | int8_t mdx; | 77 | int8_t mdx; |
| 65 | int16_t dy; // displacement on y directions. | 78 | int16_t dy; // displacement on y directions. |
| 66 | int8_t mdy; | 79 | int8_t mdy; |
| 67 | } report_pmw_t; | 80 | } report_pmw3360_t; |
| 68 | 81 | ||
| 69 | bool spi_start_adv(void); | 82 | bool spi_start_adv(void); |
| 70 | void spi_stop_adv(void); | 83 | void spi_stop_adv(void); |
| 71 | spi_status_t spi_write_adv(uint8_t reg_addr, uint8_t data); | 84 | spi_status_t spi_write_adv(uint8_t reg_addr, uint8_t data); |
| 72 | uint8_t spi_read_adv(uint8_t reg_addr); | 85 | uint8_t spi_read_adv(uint8_t reg_addr); |
| 73 | bool pmw_spi_init(void); | 86 | bool pmw3360_init(void); |
| 74 | void pmw_set_cpi(uint16_t cpi); | 87 | void pmw3360_set_cpi(uint16_t cpi); |
| 75 | uint16_t pmw_get_cpi(void); | 88 | uint16_t pmw3360_get_cpi(void); |
| 76 | void pmw_upload_firmware(void); | 89 | void pmw3360_upload_firmware(void); |
| 77 | bool pmw_check_signature(void); | 90 | bool pmw3360_check_signature(void); |
| 78 | report_pmw_t pmw_read_burst(void); | 91 | report_pmw3360_t pmw3360_read_burst(void); |
| 79 | 92 | ||
| 80 | #define degToRad(angleInDegrees) ((angleInDegrees)*M_PI / 180.0) | 93 | #define degToRad(angleInDegrees) ((angleInDegrees)*M_PI / 180.0) |
| 81 | #define radToDeg(angleInRadians) ((angleInRadians)*180.0 / M_PI) | 94 | #define radToDeg(angleInRadians) ((angleInRadians)*180.0 / M_PI) |
| 82 | #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) | ||
