aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-01-19 20:47:07 +0000
committerGitHub <[email protected]>2022-01-19 20:47:07 +0000
commit6b0cb0609b4bfa3e464e4603ce373a9de9886103 (patch)
tree70a6590ad9da8c625eb69c21faddb5721bfbcea4 /tests
parent071b034a5dbece727b28aee6362e36d66bcb763b (diff)
parent889d757ab8bcfc10caf0a7d75ffb7733a7e71ed1 (diff)
Merge #581
581: stm32: expose all functionality as inherent methods. r=Dirbaio a=Dirbaio This is the previous step to implementing both the embedded-hal 0.2 and embedded-hal 1.0 + embedded-hal-async traits. The equivalent in nrf was done in #552 - Removes need for `unwrap` in gpio. - Removes need for `use embedded_hal::whatever` in all cases. Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/stm32/src/bin/gpio.rs27
-rw-r--r--tests/stm32/src/bin/spi.rs3
-rw-r--r--tests/stm32/src/bin/usart.rs5
-rw-r--r--tests/stm32/src/bin/usart_dma.rs1
-rwxr-xr-xtests/stm32/teleprobe.sh12
5 files changed, 28 insertions, 20 deletions
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs
index 51ede6cea..305da8d12 100644
--- a/tests/stm32/src/bin/gpio.rs
+++ b/tests/stm32/src/bin/gpio.rs
@@ -8,7 +8,6 @@ use defmt::assert;
8use embassy::executor::Spawner; 8use embassy::executor::Spawner;
9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
10use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
11use embedded_hal::digital::v2::{InputPin, OutputPin};
12use example_common::*; 11use example_common::*;
13 12
14#[embassy::main(config = "config()")] 13#[embassy::main(config = "config()")]
@@ -35,12 +34,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
35 { 34 {
36 let _a = Output::new(&mut a, Level::Low, Speed::Low); 35 let _a = Output::new(&mut a, Level::Low, Speed::Low);
37 delay(); 36 delay();
38 assert!(b.is_low().unwrap()); 37 assert!(b.is_low());
39 } 38 }
40 { 39 {
41 let _a = Output::new(&mut a, Level::High, Speed::Low); 40 let _a = Output::new(&mut a, Level::High, Speed::Low);
42 delay(); 41 delay();
43 assert!(b.is_high().unwrap()); 42 assert!(b.is_high());
44 } 43 }
45 } 44 }
46 45
@@ -51,38 +50,38 @@ async fn main(_spawner: Spawner, p: Peripherals) {
51 50
52 let mut a = Output::new(&mut a, Level::Low, Speed::Low); 51 let mut a = Output::new(&mut a, Level::Low, Speed::Low);
53 delay(); 52 delay();
54 assert!(b.is_low().unwrap()); 53 assert!(b.is_low());
55 a.set_high().unwrap(); 54 a.set_high();
56 delay(); 55 delay();
57 assert!(b.is_high().unwrap()); 56 assert!(b.is_high());
58 } 57 }
59 58
60 // Test input pulldown 59 // Test input pulldown
61 { 60 {
62 let b = Input::new(&mut b, Pull::Down); 61 let b = Input::new(&mut b, Pull::Down);
63 delay(); 62 delay();
64 assert!(b.is_low().unwrap()); 63 assert!(b.is_low());
65 64
66 let mut a = Output::new(&mut a, Level::Low, Speed::Low); 65 let mut a = Output::new(&mut a, Level::Low, Speed::Low);
67 delay(); 66 delay();
68 assert!(b.is_low().unwrap()); 67 assert!(b.is_low());
69 a.set_high().unwrap(); 68 a.set_high();
70 delay(); 69 delay();
71 assert!(b.is_high().unwrap()); 70 assert!(b.is_high());
72 } 71 }
73 72
74 // Test input pullup 73 // Test input pullup
75 { 74 {
76 let b = Input::new(&mut b, Pull::Up); 75 let b = Input::new(&mut b, Pull::Up);
77 delay(); 76 delay();
78 assert!(b.is_high().unwrap()); 77 assert!(b.is_high());
79 78
80 let mut a = Output::new(&mut a, Level::Low, Speed::Low); 79 let mut a = Output::new(&mut a, Level::Low, Speed::Low);
81 delay(); 80 delay();
82 assert!(b.is_low().unwrap()); 81 assert!(b.is_low());
83 a.set_high().unwrap(); 82 a.set_high();
84 delay(); 83 delay();
85 assert!(b.is_high().unwrap()); 84 assert!(b.is_high());
86 } 85 }
87 86
88 info!("Test OK"); 87 info!("Test OK");
diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs
index 043505c7b..47d0017ac 100644
--- a/tests/stm32/src/bin/spi.rs
+++ b/tests/stm32/src/bin/spi.rs
@@ -10,7 +10,6 @@ use embassy_stm32::dma::NoDma;
10use embassy_stm32::spi::{self, Spi}; 10use embassy_stm32::spi::{self, Spi};
11use embassy_stm32::time::Hertz; 11use embassy_stm32::time::Hertz;
12use embassy_stm32::Peripherals; 12use embassy_stm32::Peripherals;
13use embedded_hal::blocking::spi::Transfer;
14use example_common::*; 13use example_common::*;
15 14
16#[embassy::main(config = "config()")] 15#[embassy::main(config = "config()")]
@@ -38,7 +37,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
38 // Arduino pins D11 and D12 (MOSI-MISO) are connected together with a 1K resistor. 37 // Arduino pins D11 and D12 (MOSI-MISO) are connected together with a 1K resistor.
39 // so we should get the data we sent back. 38 // so we should get the data we sent back.
40 let mut buf = data; 39 let mut buf = data;
41 spi.transfer(&mut buf).unwrap(); 40 spi.blocking_transfer_in_place(&mut buf).unwrap();
42 assert_eq!(buf, data); 41 assert_eq!(buf, data);
43 42
44 info!("Test OK"); 43 info!("Test OK");
diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs
index f887b084a..44ee730e4 100644
--- a/tests/stm32/src/bin/usart.rs
+++ b/tests/stm32/src/bin/usart.rs
@@ -9,7 +9,6 @@ use embassy::executor::Spawner;
9use embassy_stm32::dma::NoDma; 9use embassy_stm32::dma::NoDma;
10use embassy_stm32::usart::{Config, Uart}; 10use embassy_stm32::usart::{Config, Uart};
11use embassy_stm32::Peripherals; 11use embassy_stm32::Peripherals;
12use embedded_hal::blocking::serial::Write;
13use example_common::*; 12use example_common::*;
14 13
15#[embassy::main(config = "config()")] 14#[embassy::main(config = "config()")]
@@ -42,10 +41,10 @@ async fn main(_spawner: Spawner, p: Peripherals) {
42 // This is because we aren't sending+receiving at the same time. 41 // This is because we aren't sending+receiving at the same time.
43 42
44 let data = [0xC0, 0xDE]; 43 let data = [0xC0, 0xDE];
45 usart.bwrite_all(&data).unwrap(); 44 usart.blocking_write(&data).unwrap();
46 45
47 let mut buf = [0; 2]; 46 let mut buf = [0; 2];
48 usart.read_blocking(&mut buf).unwrap(); 47 usart.blocking_read(&mut buf).unwrap();
49 assert_eq!(buf, data); 48 assert_eq!(buf, data);
50 49
51 info!("Test OK"); 50 info!("Test OK");
diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs
index 96c6a6640..37faaf376 100644
--- a/tests/stm32/src/bin/usart_dma.rs
+++ b/tests/stm32/src/bin/usart_dma.rs
@@ -8,7 +8,6 @@ use defmt::assert_eq;
8use embassy::executor::Spawner; 8use embassy::executor::Spawner;
9use embassy_stm32::usart::{Config, Uart}; 9use embassy_stm32::usart::{Config, Uart};
10use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
11use embassy_traits::uart::{Read, Write};
12use example_common::*; 11use example_common::*;
13 12
14#[embassy::main(config = "config()")] 13#[embassy::main(config = "config()")]
diff --git a/tests/stm32/teleprobe.sh b/tests/stm32/teleprobe.sh
new file mode 100755
index 000000000..6eec6ca93
--- /dev/null
+++ b/tests/stm32/teleprobe.sh
@@ -0,0 +1,12 @@
1echo Running target=$1 elf=$2
2STATUSCODE=$(
3 curl \
4 -sS \
5 --output /dev/stderr \
6 --write-out "%{http_code}" \
7 -H "Authorization: Bearer $TELEPROBE_TOKEN" \
8 https://teleprobe.embassy.dev/targets/$1/run --data-binary @$2
9)
10echo
11echo HTTP Status code: $STATUSCODE
12test "$STATUSCODE" -eq 200