aboutsummaryrefslogtreecommitdiff
path: root/examples/rp235x/src/bin/spi_async.rs
diff options
context:
space:
mode:
authorCurly <[email protected]>2025-02-23 07:33:58 -0800
committerCurly <[email protected]>2025-02-23 07:33:58 -0800
commit3932835998802fc3abf7cce4f736e072858ebfd1 (patch)
tree5dd714b99bc74a03556c58809237c88691c293bb /examples/rp235x/src/bin/spi_async.rs
parentc3c67db93e627a4fafe5e1a1123e5cbb4abafe47 (diff)
rename `rp23` (?) folder to `rp235x`; fix `ci.sh` to use `rp235x` folder
Diffstat (limited to 'examples/rp235x/src/bin/spi_async.rs')
-rw-r--r--examples/rp235x/src/bin/spi_async.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/rp235x/src/bin/spi_async.rs b/examples/rp235x/src/bin/spi_async.rs
new file mode 100644
index 000000000..266584efc
--- /dev/null
+++ b/examples/rp235x/src/bin/spi_async.rs
@@ -0,0 +1,31 @@
1//! This example shows how to use SPI (Serial Peripheral Interface) in the RP2040 chip.
2//! No specific hardware is specified in this example. If you connect pin 11 and 12 you should get the same data back.
3
4#![no_std]
5#![no_main]
6
7use defmt::*;
8use embassy_executor::Spawner;
9use embassy_rp::spi::{Config, Spi};
10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _};
12
13#[embassy_executor::main]
14async fn main(_spawner: Spawner) {
15 let p = embassy_rp::init(Default::default());
16 info!("Hello World!");
17
18 let miso = p.PIN_12;
19 let mosi = p.PIN_11;
20 let clk = p.PIN_10;
21
22 let mut spi = Spi::new(p.SPI1, clk, mosi, miso, p.DMA_CH0, p.DMA_CH1, Config::default());
23
24 loop {
25 let tx_buf = [1_u8, 2, 3, 4, 5, 6];
26 let mut rx_buf = [0_u8; 6];
27 spi.transfer(&mut rx_buf, &tx_buf).await.unwrap();
28 info!("{:?}", rx_buf);
29 Timer::after_secs(1).await;
30 }
31}