Use types to strengthen the buffer dimensioning

This commit is contained in:
huntc
2021-10-17 07:51:53 +11:00
parent 0c317a64f6
commit 785030df96
2 changed files with 13 additions and 19 deletions

View File

@ -39,19 +39,17 @@ async fn main(_spawner: Spawner, mut p: Peripherals) {
timer.start();
let mut bufs = [[0; 3 * 50]; 2]; // Each buffer of the double buffer has to be large enough for all channels.
let mut bufs = [[[0; 3]; 50]; 2];
let mut c = 0;
let mut a: i32 = 0;
saadc
.run_task_sampler(&mut bufs, move |buf| {
for (i, b) in buf.iter().enumerate() {
if i % 3 == 0 {
a += *b as i32;
c += 1;
}
for b in buf {
a += b[0] as i32;
}
c += buf.len();
if c > 10000 {
a = a / c as i32;
info!("channel 1: {=i32}", a);