summaryrefslogtreecommitdiff
path: root/drivers/sensors/pmw3360.c
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2024-02-28 21:47:37 +1100
committerNick Brassel <nick@tzarc.org>2024-02-28 21:47:37 +1100
commit4e369d405af6bba1adce6337b2e1b1ea1788566c (patch)
treeb0f020feff1809e37c9e7795d344929ff0bb290a /drivers/sensors/pmw3360.c
parent4e04da397ef643f8fcf4afbe1d19f63aee1fc561 (diff)
parentdd1706e468bb18dd7f7ae143de735a5d3be1bfb8 (diff)
Merge branch 'develop'
Diffstat (limited to 'drivers/sensors/pmw3360.c')
-rw-r--r--drivers/sensors/pmw3360.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/sensors/pmw3360.c b/drivers/sensors/pmw3360.c
index a7dc687f50..8408daa945 100644
--- a/drivers/sensors/pmw3360.c
+++ b/drivers/sensors/pmw3360.c
@@ -15,6 +15,9 @@ uint16_t pmw33xx_get_cpi(uint8_t sensor) {
}
uint8_t cpival = pmw33xx_read(sensor, REG_Config1);
+ // In some cases (100, 900, 1700, 2500), reading the CPI corrupts the firmware and the sensor stops responding.
+ // To avoid this, we write the value back to the sensor, which seems to prevent the corruption.
+ pmw33xx_write(sensor, REG_Config1, cpival);
return (uint16_t)((cpival + 1) & 0xFF) * PMW33XX_CPI_STEP;
}