As suggested, use the const param to declare the internal sample for one channel only
This commit is contained in:
parent
cb56f52b99
commit
0c317a64f6
1 changed files with 24 additions and 30 deletions
|
@ -237,36 +237,6 @@ impl<'d, const N: usize> Saadc<'d, N> {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Continuous sampling with double buffers. The sample buffers generally
|
|
||||||
/// should be a multiple of the number of channels configured.
|
|
||||||
///
|
|
||||||
/// The internal clock is to be used with a sample rate expressed as a divisor of
|
|
||||||
/// 16MHz, ranging from 80..2047. For example, 1600 represnts a sample rate of 10KHz
|
|
||||||
/// given 16_000_000 / 10_000_000 = 1600.
|
|
||||||
///
|
|
||||||
/// A sampler closure is provided that receives the buffer of samples, noting
|
|
||||||
/// that the size of this buffer can be less than the original buffer's size.
|
|
||||||
/// A command is return from the closure that indicates whether the sampling
|
|
||||||
/// should continue or stop.
|
|
||||||
pub async fn run_timer_sampler<S, const N0: usize>(
|
|
||||||
&mut self,
|
|
||||||
bufs: &mut [[i16; N0]; 2],
|
|
||||||
sample_rate: u16,
|
|
||||||
sampler: S,
|
|
||||||
) where
|
|
||||||
S: FnMut(&[i16]) -> SamplerState,
|
|
||||||
{
|
|
||||||
assert!(
|
|
||||||
N == 1,
|
|
||||||
"The internal timer can only be used with one channel"
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
N0 % N == 0,
|
|
||||||
"The buffer size must be a multiple of the number of channels"
|
|
||||||
);
|
|
||||||
self.run_sampler(bufs, Some(sample_rate), sampler).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Continuous sampling with double buffers. The sample buffers generally
|
/// Continuous sampling with double buffers. The sample buffers generally
|
||||||
/// should be a multiple of the number of channels configured.
|
/// should be a multiple of the number of channels configured.
|
||||||
///
|
///
|
||||||
|
@ -387,6 +357,30 @@ impl<'d, const N: usize> Saadc<'d, N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'d> Saadc<'d, 1> {
|
||||||
|
/// Continuous sampling on a single channel with double buffers. The sample
|
||||||
|
/// buffers generally should be a multiple of the number of channels configured.
|
||||||
|
///
|
||||||
|
/// The internal clock is to be used with a sample rate expressed as a divisor of
|
||||||
|
/// 16MHz, ranging from 80..2047. For example, 1600 represnts a sample rate of 10KHz
|
||||||
|
/// given 16_000_000 / 10_000_000 = 1600.
|
||||||
|
///
|
||||||
|
/// A sampler closure is provided that receives the buffer of samples, noting
|
||||||
|
/// that the size of this buffer can be less than the original buffer's size.
|
||||||
|
/// A command is return from the closure that indicates whether the sampling
|
||||||
|
/// should continue or stop.
|
||||||
|
pub async fn run_timer_sampler<S, const N0: usize>(
|
||||||
|
&mut self,
|
||||||
|
bufs: &mut [[i16; N0]; 2],
|
||||||
|
sample_rate: u16,
|
||||||
|
sampler: S,
|
||||||
|
) where
|
||||||
|
S: FnMut(&[i16]) -> SamplerState,
|
||||||
|
{
|
||||||
|
self.run_sampler(bufs, Some(sample_rate), sampler).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'d, const N: usize> Drop for Saadc<'d, N> {
|
impl<'d, const N: usize> Drop for Saadc<'d, N> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let r = Self::regs();
|
let r = Self::regs();
|
||||||
|
|
Loading…
Reference in a new issue