aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/nrf/src/bin/blinky.rs6
-rw-r--r--examples/nrf/src/bin/mpsc.rs5
-rw-r--r--examples/nrf/src/bin/spim.rs17
3 files changed, 12 insertions, 16 deletions
diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs
index a12fe58ff..0fc004ed8 100644
--- a/examples/nrf/src/bin/blinky.rs
+++ b/examples/nrf/src/bin/blinky.rs
@@ -5,21 +5,19 @@
5#[path = "../example_common.rs"] 5#[path = "../example_common.rs"]
6mod example_common; 6mod example_common;
7 7
8use defmt::unwrap;
9use embassy::executor::Spawner; 8use embassy::executor::Spawner;
10use embassy::time::{Duration, Timer}; 9use embassy::time::{Duration, Timer};
11use embassy_nrf::gpio::{Level, Output, OutputDrive}; 10use embassy_nrf::gpio::{Level, Output, OutputDrive};
12use embassy_nrf::Peripherals; 11use embassy_nrf::Peripherals;
13use embedded_hal::digital::v2::OutputPin;
14 12
15#[embassy::main] 13#[embassy::main]
16async fn main(_spawner: Spawner, p: Peripherals) { 14async fn main(_spawner: Spawner, p: Peripherals) {
17 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); 15 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
18 16
19 loop { 17 loop {
20 unwrap!(led.set_high()); 18 led.set_high();
21 Timer::after(Duration::from_millis(300)).await; 19 Timer::after(Duration::from_millis(300)).await;
22 unwrap!(led.set_low()); 20 led.set_low();
23 Timer::after(Duration::from_millis(300)).await; 21 Timer::after(Duration::from_millis(300)).await;
24 } 22 }
25} 23}
diff --git a/examples/nrf/src/bin/mpsc.rs b/examples/nrf/src/bin/mpsc.rs
index c85b7c282..454fb9541 100644
--- a/examples/nrf/src/bin/mpsc.rs
+++ b/examples/nrf/src/bin/mpsc.rs
@@ -13,7 +13,6 @@ use embassy::time::{Duration, Timer};
13use embassy::util::Forever; 13use embassy::util::Forever;
14use embassy_nrf::gpio::{Level, Output, OutputDrive}; 14use embassy_nrf::gpio::{Level, Output, OutputDrive};
15use embassy_nrf::Peripherals; 15use embassy_nrf::Peripherals;
16use embedded_hal::digital::v2::OutputPin;
17 16
18enum LedState { 17enum LedState {
19 On, 18 On,
@@ -53,8 +52,8 @@ async fn main(spawner: Spawner, p: Peripherals) {
53 Err(TryRecvError::Closed) => break, 52 Err(TryRecvError::Closed) => break,
54 }; 53 };
55 match maybe_message { 54 match maybe_message {
56 Some(LedState::On) => unwrap!(led.set_high()), 55 Some(LedState::On) => led.set_high(),
57 Some(LedState::Off) => unwrap!(led.set_low()), 56 Some(LedState::Off) => led.set_low(),
58 _ => (), 57 _ => (),
59 } 58 }
60 } 59 }
diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs
index d34ca0b85..fc31d140a 100644
--- a/examples/nrf/src/bin/spim.rs
+++ b/examples/nrf/src/bin/spim.rs
@@ -10,7 +10,6 @@ use embassy_nrf::gpio::{Level, Output, OutputDrive};
10use embassy_nrf::Peripherals; 10use embassy_nrf::Peripherals;
11use embassy_nrf::{interrupt, spim}; 11use embassy_nrf::{interrupt, spim};
12use embassy_traits::spi::FullDuplex; 12use embassy_traits::spi::FullDuplex;
13use embedded_hal::digital::v2::*;
14use example_common::*; 13use example_common::*;
15 14
16#[embassy::main] 15#[embassy::main]
@@ -29,12 +28,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
29 28
30 // softreset 29 // softreset
31 cortex_m::asm::delay(10); 30 cortex_m::asm::delay(10);
32 unwrap!(ncs.set_low()); 31 ncs.set_low();
33 cortex_m::asm::delay(5); 32 cortex_m::asm::delay(5);
34 let tx = [0xFF]; 33 let tx = [0xFF];
35 unwrap!(spim.read_write(&mut [], &tx).await); 34 unwrap!(spim.read_write(&mut [], &tx).await);
36 cortex_m::asm::delay(10); 35 cortex_m::asm::delay(10);
37 unwrap!(ncs.set_high()); 36 ncs.set_high();
38 37
39 cortex_m::asm::delay(100000); 38 cortex_m::asm::delay(100000);
40 39
@@ -42,31 +41,31 @@ async fn main(_spawner: Spawner, p: Peripherals) {
42 41
43 // read ESTAT 42 // read ESTAT
44 cortex_m::asm::delay(5000); 43 cortex_m::asm::delay(5000);
45 unwrap!(ncs.set_low()); 44 ncs.set_low();
46 cortex_m::asm::delay(5000); 45 cortex_m::asm::delay(5000);
47 let tx = [0b000_11101, 0]; 46 let tx = [0b000_11101, 0];
48 unwrap!(spim.read_write(&mut rx, &tx).await); 47 unwrap!(spim.read_write(&mut rx, &tx).await);
49 cortex_m::asm::delay(5000); 48 cortex_m::asm::delay(5000);
50 unwrap!(ncs.set_high()); 49 ncs.set_high();
51 info!("estat: {=[?]}", rx); 50 info!("estat: {=[?]}", rx);
52 51
53 // Switch to bank 3 52 // Switch to bank 3
54 cortex_m::asm::delay(10); 53 cortex_m::asm::delay(10);
55 unwrap!(ncs.set_low()); 54 ncs.set_low();
56 cortex_m::asm::delay(5); 55 cortex_m::asm::delay(5);
57 let tx = [0b100_11111, 0b11]; 56 let tx = [0b100_11111, 0b11];
58 unwrap!(spim.read_write(&mut rx, &tx).await); 57 unwrap!(spim.read_write(&mut rx, &tx).await);
59 cortex_m::asm::delay(10); 58 cortex_m::asm::delay(10);
60 unwrap!(ncs.set_high()); 59 ncs.set_high();
61 60
62 // read EREVID 61 // read EREVID
63 cortex_m::asm::delay(10); 62 cortex_m::asm::delay(10);
64 unwrap!(ncs.set_low()); 63 ncs.set_low();
65 cortex_m::asm::delay(5); 64 cortex_m::asm::delay(5);
66 let tx = [0b000_10010, 0]; 65 let tx = [0b000_10010, 0];
67 unwrap!(spim.read_write(&mut rx, &tx).await); 66 unwrap!(spim.read_write(&mut rx, &tx).await);
68 cortex_m::asm::delay(10); 67 cortex_m::asm::delay(10);
69 unwrap!(ncs.set_high()); 68 ncs.set_high();
70 69
71 info!("erevid: {=[?]}", rx); 70 info!("erevid: {=[?]}", rx);
72} 71}