Skip to content

Commit

Permalink
[Bug] Fix pmw33xx sensor corruption on get-cpi call (#23116)
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna committed Feb 20, 2024
1 parent 6efb71d commit 6678078
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/sensors/pmw3360.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 6678078

Please sign in to comment.