Summary
In src/main/drivers/max7456.c inside max7456_dma_irq_handler(), the STM32 SPI RX buffer is drained after DMA transmission by reading the DR register in a bare expression:
// Empty RX buffer. RX DMA takes care of it if enabled.
// This should be done after transmission finish!!!
while (SPI_I2S_GetFlagStatus(busdev->busType_u.spi.instance, SPI_I2S_FLAG_RXNE) == SET) {
busdev->busType_u.spi.instance->DR; // line 310
}
The read of DR is intentional — on STM32, reading the SPI DR register is the only way to clear the RXNE flag and discard the buffered received byte. However, because the value is never stored in a variable, static-analysis tools (Codacy / cppcheck) flag it as a "Redundant code: Found unused member access." (MINOR / Code style).
Suggested fix
Make the intentional side-effect explicit to satisfy static analysers:
while (SPI_I2S_GetFlagStatus(busdev->busType_u.spi.instance, SPI_I2S_FLAG_RXNE) == SET) {
(void)busdev->busType_u.spi.instance->DR;
}
Notes
Summary
In
src/main/drivers/max7456.cinsidemax7456_dma_irq_handler(), the STM32 SPI RX buffer is drained after DMA transmission by reading theDRregister in a bare expression:The read of
DRis intentional — on STM32, reading the SPIDRregister is the only way to clear theRXNEflag and discard the buffered received byte. However, because the value is never stored in a variable, static-analysis tools (Codacy / cppcheck) flag it as a "Redundant code: Found unused member access." (MINOR / Code style).Suggested fix
Make the intentional side-effect explicit to satisfy static analysers:
Notes