diff options
| author | Henrik Alsér <[email protected]> | 2022-11-05 00:15:43 +0100 |
|---|---|---|
| committer | Henrik Alsér <[email protected]> | 2022-11-05 00:15:43 +0100 |
| commit | 1920e90dcdbebc1e2f86001f1491a9f28eb0f0f3 (patch) | |
| tree | 5cb6408c92df3b3bf09d4271e800caef85620579 /examples | |
| parent | b99533607ceed225dd12ae73aaa9a0d969a7365e (diff) | |
embassy-nrf: Add SPIS module
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf/src/bin/spis.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/nrf/src/bin/spis.rs b/examples/nrf/src/bin/spis.rs new file mode 100644 index 000000000..181e08404 --- /dev/null +++ b/examples/nrf/src/bin/spis.rs | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::info; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_nrf::interrupt; | ||
| 8 | use embassy_nrf::spis::{self, Config}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 10 | |||
| 11 | #[embassy_executor::main] | ||
| 12 | async fn main(_spawner: Spawner) { | ||
| 13 | let p = embassy_nrf::init(Default::default()); | ||
| 14 | info!("Running!"); | ||
| 15 | |||
| 16 | let irq = interrupt::take!(SPIM2_SPIS2_SPI2); | ||
| 17 | let mut spis = spis::Spis::new(p.SPI2, irq, p.P0_31, p.P0_29, p.P0_28, p.P0_30, Config::default()); | ||
| 18 | |||
| 19 | loop { | ||
| 20 | let mut buf = [0_u8; 64]; | ||
| 21 | if let Ok(n) = spis.read(&mut buf).await { | ||
| 22 | info!("RX: {:?}", buf[..n]); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | ||
