aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-11-22 11:20:14 +0000
committerGitHub <[email protected]>2022-11-22 11:20:14 +0000
commit97cb95bbf4c6a813864252d0f8822a9ea2357ebe (patch)
treeace4389903f49e4ea794a19c8f303155648edd50 /examples
parent99c561a749fee5dbf946a8ffa12f01d031dbee49 (diff)
parentda9f82f5079ace916b8b5d26fe261cb98fb483fc (diff)
Merge #1042
1042: embassy-nrf: Add SPIS module r=Dirbaio a=kalkyl Verified to be working on nrf9160 Co-authored-by: Henrik Alsér <[email protected]> Co-authored-by: Henrik Alsér <[email protected]> Co-authored-by: kalkyl <[email protected]>
Diffstat (limited to 'examples')
-rw-r--r--examples/nrf/src/bin/spis.rs27
1 files changed, 27 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..fe3b0c53d
--- /dev/null
+++ b/examples/nrf/src/bin/spis.rs
@@ -0,0 +1,27 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt::info;
6use embassy_executor::Spawner;
7use embassy_nrf::interrupt;
8use embassy_nrf::spis::{Config, Spis};
9use {defmt_rtt as _, panic_probe as _};
10
11#[embassy_executor::main]
12async 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::new(p.SPI2, irq, p.P0_31, p.P0_29, p.P0_28, p.P0_30, Config::default());
18
19 loop {
20 let mut rx_buf = [0_u8; 64];
21 let tx_buf = [1_u8, 2, 3, 4, 5, 6, 7, 8];
22 if let Ok((n_rx, n_tx)) = spis.transfer(&mut rx_buf, &tx_buf).await {
23 info!("RX: {:?}", rx_buf[..n_rx]);
24 info!("TX: {:?}", tx_buf[..n_tx]);
25 }
26 }
27}