diff options
author | Drashna Jaelre <drashna@live.com> | 2021-12-15 13:41:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-15 13:41:07 -0800 |
commit | aed64aaef4724c01a30b1815c0c910ca8b1a5e43 (patch) | |
tree | 785af8d14b310374997d8a4d959e4b00e658f246 /drivers | |
parent | 3fa592a4024a24a636fa0c562e6761667a94f565 (diff) | |
download | qmk_firmware-aed64aaef4724c01a30b1815c0c910ca8b1a5e43.tar.gz qmk_firmware-aed64aaef4724c01a30b1815c0c910ca8b1a5e43.zip |
[Core] Fix Sensor driver code (#15484)
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/sensors/cirque_pinnacle_spi.c | 5 | ||||
-rw-r--r-- | drivers/sensors/pmw3360.c | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/drivers/sensors/cirque_pinnacle_spi.c b/drivers/sensors/cirque_pinnacle_spi.c index f3eee8875..ed40abd9f 100644 --- a/drivers/sensors/cirque_pinnacle_spi.c +++ b/drivers/sensors/cirque_pinnacle_spi.c | |||
@@ -15,7 +15,7 @@ extern bool touchpad_init; | |||
15 | void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { | 15 | void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { |
16 | uint8_t cmdByte = READ_MASK | address; // Form the READ command byte | 16 | uint8_t cmdByte = READ_MASK | address; // Form the READ command byte |
17 | if (touchpad_init) { | 17 | if (touchpad_init) { |
18 | if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_TRACKPAD_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { | 18 | if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { |
19 | spi_write(cmdByte); | 19 | spi_write(cmdByte); |
20 | spi_read(); // filler | 20 | spi_read(); // filler |
21 | spi_read(); // filler | 21 | spi_read(); // filler |
@@ -27,7 +27,6 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { | |||
27 | dprintf("error right touchpad\n"); | 27 | dprintf("error right touchpad\n"); |
28 | #endif | 28 | #endif |
29 | touchpad_init = false; | 29 | touchpad_init = false; |
30 | j | ||
31 | } | 30 | } |
32 | spi_stop(); | 31 | spi_stop(); |
33 | } | 32 | } |
@@ -38,7 +37,7 @@ void RAP_Write(uint8_t address, uint8_t data) { | |||
38 | uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte | 37 | uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte |
39 | 38 | ||
40 | if (touchpad_init) { | 39 | if (touchpad_init) { |
41 | if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_TRACKPAD_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { | 40 | if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { |
42 | spi_write(cmdByte); | 41 | spi_write(cmdByte); |
43 | spi_write(data); | 42 | spi_write(data); |
44 | } else { | 43 | } else { |
diff --git a/drivers/sensors/pmw3360.c b/drivers/sensors/pmw3360.c index 7e830cdde..50d1c3580 100644 --- a/drivers/sensors/pmw3360.c +++ b/drivers/sensors/pmw3360.c | |||
@@ -143,7 +143,7 @@ void pmw3360_set_cpi(uint16_t cpi) { | |||
143 | 143 | ||
144 | uint16_t pmw3360_get_cpi(void) { | 144 | uint16_t pmw3360_get_cpi(void) { |
145 | uint8_t cpival = spi_read_adv(REG_Config1); | 145 | uint8_t cpival = spi_read_adv(REG_Config1); |
146 | return (uint16_t)(cpival & 0xFF) * 100; | 146 | return (uint16_t)((cpival + 1) & 0xFF) * 100; |
147 | } | 147 | } |
148 | 148 | ||
149 | bool pmw3360_init(void) { | 149 | bool pmw3360_init(void) { |