diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-03-18 01:27:30 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-03-18 01:27:30 +0100 |
| commit | 3de2d5c5bde44f1aec0e1727cfb2af3052c1bda4 (patch) | |
| tree | a337a563ce519ff73123f5b219587e3570adf0c1 /embassy-nrf-examples/src | |
| parent | c403a47b7f77252c26356d69173169b5fe393d52 (diff) | |
Implement FullDuplex for nrf spim
Diffstat (limited to 'embassy-nrf-examples/src')
| -rw-r--r-- | embassy-nrf-examples/src/bin/spim.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/embassy-nrf-examples/src/bin/spim.rs b/embassy-nrf-examples/src/bin/spim.rs index d6b3a5f87..d3d942e4e 100644 --- a/embassy-nrf-examples/src/bin/spim.rs +++ b/embassy-nrf-examples/src/bin/spim.rs | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use embassy_traits::spi::FullDuplex; | ||
| 9 | use example_common::*; | 10 | use example_common::*; |
| 10 | 11 | ||
| 11 | use cortex_m_rt::entry; | 12 | use cortex_m_rt::entry; |
| @@ -49,7 +50,7 @@ async fn run() { | |||
| 49 | ncs.set_low().unwrap(); | 50 | ncs.set_low().unwrap(); |
| 50 | cortex_m::asm::delay(5); | 51 | cortex_m::asm::delay(5); |
| 51 | let tx = [0xFF]; | 52 | let tx = [0xFF]; |
| 52 | unwrap!(spim.as_mut().send_receive(&tx, &mut []).await); | 53 | unwrap!(spim.as_mut().read_write(&mut [], &tx).await); |
| 53 | cortex_m::asm::delay(10); | 54 | cortex_m::asm::delay(10); |
| 54 | ncs.set_high().unwrap(); | 55 | ncs.set_high().unwrap(); |
| 55 | 56 | ||
| @@ -62,7 +63,7 @@ async fn run() { | |||
| 62 | ncs.set_low().unwrap(); | 63 | ncs.set_low().unwrap(); |
| 63 | cortex_m::asm::delay(5000); | 64 | cortex_m::asm::delay(5000); |
| 64 | let tx = [0b000_11101, 0]; | 65 | let tx = [0b000_11101, 0]; |
| 65 | unwrap!(spim.as_mut().send_receive(&tx, &mut rx).await); | 66 | unwrap!(spim.as_mut().read_write(&mut rx, &tx).await); |
| 66 | cortex_m::asm::delay(5000); | 67 | cortex_m::asm::delay(5000); |
| 67 | ncs.set_high().unwrap(); | 68 | ncs.set_high().unwrap(); |
| 68 | info!("estat: {=[?]}", rx); | 69 | info!("estat: {=[?]}", rx); |
| @@ -72,7 +73,7 @@ async fn run() { | |||
| 72 | ncs.set_low().unwrap(); | 73 | ncs.set_low().unwrap(); |
| 73 | cortex_m::asm::delay(5); | 74 | cortex_m::asm::delay(5); |
| 74 | let tx = [0b100_11111, 0b11]; | 75 | let tx = [0b100_11111, 0b11]; |
| 75 | unwrap!(spim.as_mut().send_receive(&tx, &mut rx).await); | 76 | unwrap!(spim.as_mut().read_write(&mut rx, &tx).await); |
| 76 | cortex_m::asm::delay(10); | 77 | cortex_m::asm::delay(10); |
| 77 | ncs.set_high().unwrap(); | 78 | ncs.set_high().unwrap(); |
| 78 | 79 | ||
| @@ -81,7 +82,7 @@ async fn run() { | |||
| 81 | ncs.set_low().unwrap(); | 82 | ncs.set_low().unwrap(); |
| 82 | cortex_m::asm::delay(5); | 83 | cortex_m::asm::delay(5); |
| 83 | let tx = [0b000_10010, 0]; | 84 | let tx = [0b000_10010, 0]; |
| 84 | unwrap!(spim.as_mut().send_receive(&tx, &mut rx).await); | 85 | unwrap!(spim.as_mut().read_write(&mut rx, &tx).await); |
| 85 | cortex_m::asm::delay(10); | 86 | cortex_m::asm::delay(10); |
| 86 | ncs.set_high().unwrap(); | 87 | ncs.set_high().unwrap(); |
| 87 | 88 | ||
