From 380fccff2a34919e5c5ac6cd902c3ddadab10b3a Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Sun, 11 Jan 2026 14:36:14 -0600 Subject: [PATCH] Fix SPI register masking in busWriteBuf Correct the SPI register address masking in busWriteBuf() to clear the MSB instead of setting it. For SPI protocol, the MSB indicates read (1) or write (0) operations. Write operations should use (reg & 0x7F) to clear the MSB, not (reg | 0x80) which sets it. This matches the correct implementation in busWrite() at line 318 which uses (reg & 0x7F) for write operations. Note: This bug affects theoretical future SPI devices using buffer writes. Current devices using busWriteBuf() are all I2C-based (VL53L0X, VL53L1X, MLX90393, TERARANGER_EVO, US42 rangefinders) and are unaffected. Fixes #10674 --- src/main/drivers/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/drivers/bus.c b/src/main/drivers/bus.c index 0da3f76d307..71410fb2748 100644 --- a/src/main/drivers/bus.c +++ b/src/main/drivers/bus.c @@ -283,7 +283,7 @@ bool busWriteBuf(const busDevice_t * dev, uint8_t reg, const uint8_t * data, uin return spiBusWriteBuffer(dev, reg, data, length); } else { - return spiBusWriteBuffer(dev, reg | 0x80, data, length); + return spiBusWriteBuffer(dev, reg & 0x7F, data, length); } #else return false;