stm32 ringbuffered adc: add buf size assert

This commit is contained in:
Andres Vahter 2024-07-02 16:56:19 +03:00
parent b88e1a5d71
commit dd69efe708

View File

@ -408,6 +408,12 @@ impl<'d, T: Instance> RingBufferedAdc<'d, T> {
/// [`teardown_adc`]: #method.teardown_adc
/// [`start`]: #method.start
pub async fn read_exact<const N: usize>(&mut self, measurements: &mut [u16; N]) -> Result<usize, OverrunError> {
assert_eq!(
self.ring_buf.capacity() / 2,
N,
"Buffer size must be half the size of the ring buffer"
);
let r = T::regs();
// Start background receive if it was not already started