aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf/src
diff options
context:
space:
mode:
authorhuntc <[email protected]>2021-10-17 07:51:53 +1100
committerhuntc <[email protected]>2021-10-18 10:26:11 +1100
commit785030df963c9071a51fbc6e57e545faccc483c1 (patch)
tree8d24e0b85bebe470789a7d7a0ebbe2445b5d9acd /examples/nrf/src
parent0c317a64f6f0f845dd2ca3323c9579fda09be410 (diff)
Use types to strengthen the buffer dimensioning
Diffstat (limited to 'examples/nrf/src')
-rw-r--r--examples/nrf/src/bin/saadc_continuous.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/examples/nrf/src/bin/saadc_continuous.rs b/examples/nrf/src/bin/saadc_continuous.rs
index d936a7d21..149b9c60c 100644
--- a/examples/nrf/src/bin/saadc_continuous.rs
+++ b/examples/nrf/src/bin/saadc_continuous.rs
@@ -39,19 +39,17 @@ async fn main(_spawner: Spawner, mut p: Peripherals) {
39 39
40 timer.start(); 40 timer.start();
41 41
42 let mut bufs = [[0; 3 * 50]; 2]; // Each buffer of the double buffer has to be large enough for all channels. 42 let mut bufs = [[[0; 3]; 50]; 2];
43 43
44 let mut c = 0; 44 let mut c = 0;
45 let mut a: i32 = 0; 45 let mut a: i32 = 0;
46 46
47 saadc 47 saadc
48 .run_task_sampler(&mut bufs, move |buf| { 48 .run_task_sampler(&mut bufs, move |buf| {
49 for (i, b) in buf.iter().enumerate() { 49 for b in buf {
50 if i % 3 == 0 { 50 a += b[0] as i32;
51 a += *b as i32;
52 c += 1;
53 }
54 } 51 }
52 c += buf.len();
55 if c > 10000 { 53 if c > 10000 {
56 a = a / c as i32; 54 a = a / c as i32;
57 info!("channel 1: {=i32}", a); 55 info!("channel 1: {=i32}", a);