diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-04-14 16:37:10 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-04-14 17:04:40 +0200 |
| commit | c15411d1bdbc54caa0e9879ea1de8c43025f2090 (patch) | |
| tree | 14409a127ac5cfe41acdeb506fd3107a05ad7e5e /embassy-nrf-examples/src | |
| parent | 8b1ffb2cb7bd2e0c0f50eefb2391c15ae3050e73 (diff) | |
Remove Pin from SPI
Diffstat (limited to 'embassy-nrf-examples/src')
| -rw-r--r-- | embassy-nrf-examples/src/bin/spim.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/embassy-nrf-examples/src/bin/spim.rs b/embassy-nrf-examples/src/bin/spim.rs index 6d0fa93d0..27486374f 100644 --- a/embassy-nrf-examples/src/bin/spim.rs +++ b/embassy-nrf-examples/src/bin/spim.rs | |||
| @@ -17,7 +17,6 @@ use embassy_nrf::{interrupt, spim}; | |||
| 17 | use embassy_traits::spi::FullDuplex; | 17 | use embassy_traits::spi::FullDuplex; |
| 18 | use embedded_hal::digital::v2::*; | 18 | use embedded_hal::digital::v2::*; |
| 19 | use example_common::*; | 19 | use example_common::*; |
| 20 | use futures::pin_mut; | ||
| 21 | 20 | ||
| 22 | #[embassy::main] | 21 | #[embassy::main] |
| 23 | async fn main(spawner: Spawner) { | 22 | async fn main(spawner: Spawner) { |
| @@ -32,8 +31,7 @@ async fn main(spawner: Spawner) { | |||
| 32 | }; | 31 | }; |
| 33 | 32 | ||
| 34 | let irq = interrupt::take!(SPIM3); | 33 | let irq = interrupt::take!(SPIM3); |
| 35 | let spim = spim::Spim::new(p.SPIM3, irq, p.P0_29, p.P0_28, p.P0_30, config); | 34 | let mut spim = spim::Spim::new(p.SPIM3, irq, p.P0_29, p.P0_28, p.P0_30, config); |
| 36 | pin_mut!(spim); | ||
| 37 | 35 | ||
| 38 | let mut ncs = Output::new(p.P0_31, Level::High, OutputDrive::Standard); | 36 | let mut ncs = Output::new(p.P0_31, Level::High, OutputDrive::Standard); |
| 39 | 37 | ||
| @@ -44,7 +42,7 @@ async fn main(spawner: Spawner) { | |||
| 44 | ncs.set_low().unwrap(); | 42 | ncs.set_low().unwrap(); |
| 45 | cortex_m::asm::delay(5); | 43 | cortex_m::asm::delay(5); |
| 46 | let tx = [0xFF]; | 44 | let tx = [0xFF]; |
| 47 | unwrap!(spim.as_mut().read_write(&mut [], &tx).await); | 45 | unwrap!(spim.read_write(&mut [], &tx).await); |
| 48 | cortex_m::asm::delay(10); | 46 | cortex_m::asm::delay(10); |
| 49 | ncs.set_high().unwrap(); | 47 | ncs.set_high().unwrap(); |
| 50 | 48 | ||
| @@ -57,7 +55,7 @@ async fn main(spawner: Spawner) { | |||
| 57 | ncs.set_low().unwrap(); | 55 | ncs.set_low().unwrap(); |
| 58 | cortex_m::asm::delay(5000); | 56 | cortex_m::asm::delay(5000); |
| 59 | let tx = [0b000_11101, 0]; | 57 | let tx = [0b000_11101, 0]; |
| 60 | unwrap!(spim.as_mut().read_write(&mut rx, &tx).await); | 58 | unwrap!(spim.read_write(&mut rx, &tx).await); |
| 61 | cortex_m::asm::delay(5000); | 59 | cortex_m::asm::delay(5000); |
| 62 | ncs.set_high().unwrap(); | 60 | ncs.set_high().unwrap(); |
| 63 | info!("estat: {=[?]}", rx); | 61 | info!("estat: {=[?]}", rx); |
| @@ -67,7 +65,7 @@ async fn main(spawner: Spawner) { | |||
| 67 | ncs.set_low().unwrap(); | 65 | ncs.set_low().unwrap(); |
| 68 | cortex_m::asm::delay(5); | 66 | cortex_m::asm::delay(5); |
| 69 | let tx = [0b100_11111, 0b11]; | 67 | let tx = [0b100_11111, 0b11]; |
| 70 | unwrap!(spim.as_mut().read_write(&mut rx, &tx).await); | 68 | unwrap!(spim.read_write(&mut rx, &tx).await); |
| 71 | cortex_m::asm::delay(10); | 69 | cortex_m::asm::delay(10); |
| 72 | ncs.set_high().unwrap(); | 70 | ncs.set_high().unwrap(); |
| 73 | 71 | ||
| @@ -76,7 +74,7 @@ async fn main(spawner: Spawner) { | |||
| 76 | ncs.set_low().unwrap(); | 74 | ncs.set_low().unwrap(); |
| 77 | cortex_m::asm::delay(5); | 75 | cortex_m::asm::delay(5); |
| 78 | let tx = [0b000_10010, 0]; | 76 | let tx = [0b000_10010, 0]; |
| 79 | unwrap!(spim.as_mut().read_write(&mut rx, &tx).await); | 77 | unwrap!(spim.read_write(&mut rx, &tx).await); |
| 80 | cortex_m::asm::delay(10); | 78 | cortex_m::asm::delay(10); |
| 81 | ncs.set_high().unwrap(); | 79 | ncs.set_high().unwrap(); |
| 82 | 80 | ||
