stm32 adc read_async: add asserts for buf len
This commit is contained in:
parent
5e2fd8623a
commit
c120efad5b
2 changed files with 13 additions and 6 deletions
|
@ -262,10 +262,13 @@ impl<'d, T: Instance> Adc<'d, T> {
|
|||
&mut self,
|
||||
rx_dma: &mut impl RxDma<T>,
|
||||
sequence: impl ExactSizeIterator<Item = (&mut AnyAdcChannel<T>, SampleTime)>,
|
||||
data: &mut [u16],
|
||||
readings: &mut [u16],
|
||||
) {
|
||||
assert!(sequence.len() != 0, "Asynchronous read sequence cannot be empty");
|
||||
|
||||
assert!(
|
||||
sequence.len() == readings.len(),
|
||||
"Sequence length must be equal to readings length"
|
||||
);
|
||||
assert!(
|
||||
sequence.len() <= 16,
|
||||
"Asynchronous read sequence cannot be more than 16 in length"
|
||||
|
@ -357,7 +360,7 @@ impl<'d, T: Instance> Adc<'d, T> {
|
|||
rx_dma,
|
||||
request,
|
||||
T::regs().dr().as_ptr() as *mut u16,
|
||||
data,
|
||||
readings,
|
||||
Default::default(),
|
||||
)
|
||||
};
|
||||
|
@ -431,6 +434,7 @@ impl<'d, T: Instance> Adc<'d, T> {
|
|||
fn set_channel_sample_time(_ch: u8, sample_time: SampleTime) {
|
||||
cfg_if! {
|
||||
if #[cfg(any(adc_g0, adc_u0))] {
|
||||
// On G0 and U6 all channels use the same sampling time.
|
||||
T::regs().smpr().modify(|reg| reg.set_smp1(sample_time.into()));
|
||||
} else if #[cfg(adc_h5)] {
|
||||
match _ch {
|
||||
|
|
|
@ -290,10 +290,13 @@ impl<'d, T: Instance> Adc<'d, T> {
|
|||
&mut self,
|
||||
rx_dma: &mut impl RxDma<T>,
|
||||
sequence: impl ExactSizeIterator<Item = (&mut AnyAdcChannel<T>, SampleTime)>,
|
||||
data: &mut [u16],
|
||||
readings: &mut [u16],
|
||||
) {
|
||||
assert!(sequence.len() != 0, "Asynchronous read sequence cannot be empty");
|
||||
|
||||
assert!(
|
||||
sequence.len() == readings.len(),
|
||||
"Sequence length must be equal to readings length"
|
||||
);
|
||||
assert!(
|
||||
sequence.len() <= 16,
|
||||
"Asynchronous read sequence cannot be more than 16 in length"
|
||||
|
@ -352,7 +355,7 @@ impl<'d, T: Instance> Adc<'d, T> {
|
|||
rx_dma,
|
||||
request,
|
||||
T::regs().dr().as_ptr() as *mut u16,
|
||||
data,
|
||||
readings,
|
||||
Default::default(),
|
||||
)
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue