Closed rtzoeller closed 4 months ago
I've put this up against the develop
branch, but I'm happy to retarget or duplicate it against main
if desired.
The conditions for this to cause an issue seem to be fairly application and device specific; I've reliably hit it with an STM32H7 in one application, but never hit it with an STM32L0 in another. It's UB regardless, so it'd be nice to see it fixed.
thank you for contributing.
never have seen this issue, but totally agree to fix it.
Zero-initialize the buffer used for ADC reads, as the buffer is always written over the wire as part of the SPI transaction. In unlucky circumstances the uninitialized buffer would encode a valid command, resetting the device or triggering other undesired behavior.
Note that
uint8_t buffer[s] = {0};
won't work due to the variable-length of the array.