From 9c340077f630ef464758687e67e415e85376dad1 Mon Sep 17 00:00:00 2001 From: Glen D'souza Date: Sun, 24 Sep 2023 03:53:15 +0530 Subject: Fix lower cpi bound on PMW33XX (#22108) --- drivers/sensors/pmw3320.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/sensors/pmw3320.c') diff --git a/drivers/sensors/pmw3320.c b/drivers/sensors/pmw3320.c index a4648ef425..69a584f4e1 100644 --- a/drivers/sensors/pmw3320.c +++ b/drivers/sensors/pmw3320.c @@ -178,7 +178,7 @@ uint16_t pmw3320_get_cpi(void) { } void pmw3320_set_cpi(uint16_t cpi) { - uint8_t cpival = constrain((cpi / PMW3320_CPI_STEP) - 1U, 0, (PMW3320_CPI_MAX / PMW3320_CPI_STEP) - 1U); + uint8_t cpival = constrain((cpi / PMW3320_CPI_STEP), (PMW3320_CPI_MIN / PMW3320_CPI_STEP), (PMW3320_CPI_MAX / PMW3320_CPI_STEP)) - 1U; // Fifth bit is probably a control bit. // PMW3320 datasheet don't have any info on this, so this is a pure guess. pmw3320_write_reg(REG_Resolution, 0x20 | cpival); -- cgit v1.2.3