Skip to content

Commit 6678078

Browse files
authored
[Bug] Fix pmw33xx sensor corruption on get-cpi call (qmk#23116)
1 parent 6efb71d commit 6678078

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/sensors/pmw3360.c

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ uint16_t pmw33xx_get_cpi(uint8_t sensor) {
1515
}
1616

1717
uint8_t cpival = pmw33xx_read(sensor, REG_Config1);
18+
// In some cases (100, 900, 1700, 2500), reading the CPI corrupts the firmware and the sensor stops responding.
19+
// To avoid this, we write the value back to the sensor, which seems to prevent the corruption.
20+
pmw33xx_write(sensor, REG_Config1, cpival);
1821
return (uint16_t)((cpival + 1) & 0xFF) * PMW33XX_CPI_STEP;
1922
}
2023

0 commit comments

Comments
 (0)