Skip to content

Commit c7ec577

Browse files
committed
drv8899: Validate SDO status byte fixed bits after SPI read
1 parent e8b1fb7 commit c7ec577

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/drivers/drv8899.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ drv8899_read_reg(drv8899_t *d, uint8_t reg)
4141
error_t err = d->spi->rw(d->spi, d->tx, d->rx, 2, d->cs, d->spi_config);
4242
if(err)
4343
return err;
44+
// SDO status byte: [1][1][UVLO][CPUV][OCP][0][TF][OL]
45+
// Validate fixed bits: top two must be 1, bit 2 (RSVD) must be 0
46+
if((d->rx[0] & 0xc4) != 0xc0)
47+
return ERR_MALFORMED;
4448
return d->rx[1];
4549
}
4650

0 commit comments

Comments
 (0)