aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMathias <[email protected]>2022-09-29 10:00:13 +0200
committerMathias <[email protected]>2022-09-29 10:00:13 +0200
commit7ee7109508b463f98ea9ae08e061aeaca28016e6 (patch)
tree50723244067224c6c32603e21fbe8ec36c76898e /tests
parent18dc0dea636daa6e48aa9208b5a74cdfedc8b513 (diff)
parent77ece3f903735b50f265ddd43520c50e0f28c1a1 (diff)
Rebase on master
Diffstat (limited to 'tests')
-rw-r--r--tests/rp/.cargo/config.toml2
-rw-r--r--tests/rp/Cargo.toml3
-rw-r--r--tests/rp/src/bin/uart_buffered.rs44
3 files changed, 47 insertions, 2 deletions
diff --git a/tests/rp/.cargo/config.toml b/tests/rp/.cargo/config.toml
index 0330025e4..9611db3a0 100644
--- a/tests/rp/.cargo/config.toml
+++ b/tests/rp/.cargo/config.toml
@@ -3,7 +3,7 @@ build-std = ["core"]
3build-std-features = ["panic_immediate_abort"] 3build-std-features = ["panic_immediate_abort"]
4 4
5[target.'cfg(all(target_arch = "arm", target_os = "none"))'] 5[target.'cfg(all(target_arch = "arm", target_os = "none"))']
6#runner = "teleprobe client run --target bluepill-stm32f103c8 --elf" 6#runner = "teleprobe client run --target rpi-pico --elf"
7runner = "teleprobe local run --chip RP2040 --elf" 7runner = "teleprobe local run --chip RP2040 --elf"
8 8
9rustflags = [ 9rustflags = [
diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml
index 11ecb9169..503373759 100644
--- a/tests/rp/Cargo.toml
+++ b/tests/rp/Cargo.toml
@@ -7,7 +7,7 @@ version = "0.1.0"
7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } 7embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
8embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } 8embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] }
9embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt"] } 9embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt"] }
10embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits"] } 10embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "time-driver"] }
11embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 11embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
12 12
13defmt = "0.3.0" 13defmt = "0.3.0"
@@ -20,6 +20,7 @@ embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" }
20embedded-hal-async = { version = "0.1.0-alpha.1" } 20embedded-hal-async = { version = "0.1.0-alpha.1" }
21panic-probe = { version = "0.3.0", features = ["print-defmt"] } 21panic-probe = { version = "0.3.0", features = ["print-defmt"] }
22futures = { version = "0.3.17", default-features = false, features = ["async-await"] } 22futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
23embedded-io = { version = "0.3.0", features = ["async"] }
23 24
24[profile.dev] 25[profile.dev]
25debug = 2 26debug = 2
diff --git a/tests/rp/src/bin/uart_buffered.rs b/tests/rp/src/bin/uart_buffered.rs
new file mode 100644
index 000000000..9cc20bb98
--- /dev/null
+++ b/tests/rp/src/bin/uart_buffered.rs
@@ -0,0 +1,44 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt::{assert_eq, *};
6use embassy_executor::Spawner;
7use embassy_rp::interrupt;
8use embassy_rp::uart::{BufferedUart, Config, State, Uart};
9use embedded_io::asynch::{Read, Write};
10use {defmt_rtt as _, panic_probe as _};
11
12#[embassy_executor::main]
13async fn main(_spawner: Spawner) {
14 let p = embassy_rp::init(Default::default());
15 info!("Hello World!");
16
17 let (tx, rx, uart) = (p.PIN_0, p.PIN_1, p.UART0);
18
19 let config = Config::default();
20 let uart = Uart::new_blocking(uart, tx, rx, config);
21
22 let irq = interrupt::take!(UART0_IRQ);
23 let tx_buf = &mut [0u8; 16];
24 let rx_buf = &mut [0u8; 16];
25 let mut state = State::new();
26 let mut uart = BufferedUart::new(&mut state, uart, irq, tx_buf, rx_buf);
27
28 // Make sure we send more bytes than fits in the FIFO, to test the actual
29 // bufferedUart.
30
31 let data = [
32 1_u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
33 30, 31, 32,
34 ];
35 uart.write_all(&data).await.unwrap();
36 info!("Done writing");
37
38 let mut buf = [0; 32];
39 uart.read_exact(&mut buf).await.unwrap();
40 assert_eq!(buf, data);
41
42 info!("Test OK");
43 cortex_m::asm::bkpt();
44}