Skip to content

Commit 30b9094

Browse files
authored
Merge pull request #28 from Jim-Hodapp-Coaching/add_initial_test_infrastructure
2 parents 7dddfe9 + 0f73cd7 commit 30b9094

File tree

22 files changed

+286
-139
lines changed

22 files changed

+286
-139
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Generated by Cargo
22
# will have compiled files and executables
33
/target/
4+
/cross/target/
45

56
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
67
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html

Cargo.toml

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,10 @@
1-
[package]
2-
authors = [
3-
"Jim Hodapp",
4-
"Caleb Bourg",
5-
"Glyn Matthews"
1+
[workspace]
2+
members = [
3+
"esp32-wroom-rp",
4+
"host-tests",
65
]
7-
edition = "2021"
8-
readme = "README.md"
9-
name = "esp32-wroom-rp"
10-
version = "0.1.0"
11-
resolver = "2"
12-
description = "Rust-based Espressif ESP32-WROOM WiFi driver crate for RP2040 series microcontroller boards."
13-
14-
[lib]
15-
name = "esp32_wroom_rp"
16-
17-
[dependencies]
18-
cortex-m = "0.7"
19-
cortex-m-rt = "0.7"
20-
embedded-hal = { version = "=1.0.0-alpha.7" }
21-
eh-02 = { version = "0.2", package="embedded-hal" }
22-
embedded-time = "0.12"
23-
24-
defmt = "0.3"
25-
defmt-rtt = "0.3"
26-
heapless = "0.7.16"
27-
panic-probe = { version = "0.3", features = ["print-rtt"] }
286

29-
rp2040-hal = { version = "0.5", features=["rt", "eh1_0_alpha"] }
30-
rp2040-boot2 = { version = "0.2" }
31-
cortex-m-semihosting = "0.5"
32-
33-
[features]
34-
default = [
35-
"defmt-default",
36-
]
37-
defmt-default = []
38-
defmt-trace = []
39-
defmt-debug = []
40-
defmt-info = []
41-
defmt-warn = []
42-
defmt-error = []
7+
resolver = "2"
438

449
# cargo build/run
4510
[profile.dev]
@@ -92,6 +57,3 @@ debug-assertions = false
9257
incremental = false
9358
lto = 'fat'
9459
opt-level = 3
95-
96-
[[example]]
97-
name = "get_fw_version"

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ Future implementations will support the [ESP32-WROOM-DA](https://www.espressif.c
99

1010
## Usage
1111

12-
```
12+
```rust
1313
use esp32_wroom_rp::wifi;
14+
use embedded_hal::blocking::delay::DelayMs;
1415

1516
let spi_miso = pins.gpio16.into_mode::<hal::gpio::FunctionSpi>();
1617
let spi_sclk = pins.gpio18.into_mode::<hal::gpio::FunctionSpi>();
@@ -122,12 +123,36 @@ The following table lists the pin name and pin number to properly wire between a
122123
- flip-link - this allows you to detect stack-overflows on the first core, which is the only supported target for now.
123124

124125
## Installation of development dependencies
125-
```
126+
```sh
126127
rustup target install thumbv6m-none-eabi
127128
cargo install flip-link
128129
cargo install probe-run
129130
```
130131

132+
## Building the crate and running the examples
133+
134+
To build the esp32-wroom-rp crate:
135+
```sh
136+
cargo build
137+
```
138+
139+
To build an example (e.g. get_fw_version):
140+
```sh
141+
cd cross
142+
cargo build --bin get_fw_version
143+
```
144+
145+
To run an example (e.g. get_fw_version):
146+
```sh
147+
cd cross
148+
cargo run --bin get_fw_version
149+
```
150+
151+
## Running the crate's unit tests
152+
```sh
153+
cargo test
154+
```
155+
131156
## Getting Involved
132157

133158
This project launched in April, 2022). See the main page section [Getting Involved](https://github.com/Jim-Hodapp-Coaching#getting-involved) for more info on how to contribute to this project and the Rust Never Sleeps community.
File renamed without changes.

cross/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[workspace]
2+
members = [
3+
"get_fw_version",
4+
"join",
5+
]
6+
7+
[profile.dev]
8+
codegen-units = 1
9+
incremental = false
10+
lto = 'fat'
11+
opt-level = 's'
12+
13+
[profile.test]
14+
codegen-units = 1
15+
incremental = false
16+
lto = 'fat'
17+
opt-level = 's'
File renamed without changes.

cross/get_fw_version/Cargo.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[package]
2+
authors = [
3+
"Jim Hodapp",
4+
"Caleb Bourg",
5+
"Glyn Matthews"
6+
]
7+
edition = "2021"
8+
name = "get_fw_version"
9+
version = "0.1.0"
10+
description = "Example target application that gets the Nina firmware version with the Rust-based Espressif ESP32-WROOM WiFi driver crate for RP2040 series microcontroller boards."
11+
12+
# makes `cargo check --all-targets` work
13+
[[bin]]
14+
name = "get_fw_version"
15+
bench = false
16+
doctest = false
17+
test = false
18+
19+
[dependencies]
20+
defmt = "0.3.0"
21+
defmt-rtt = "0.3.0"
22+
cortex-m = "0.7"
23+
cortex-m-rt = "0.7"
24+
embedded-hal = { version = "0.2", features=["unproven"] }
25+
embedded-time = "0.12"
26+
esp32-wroom-rp = { path = "../../esp32-wroom-rp" }
27+
panic-probe = { version = "0.3.0", features = ["print-rtt"] }
28+
29+
rp2040-hal = { version = "0.5", features=["rt", "eh1_0_alpha"] }
30+
rp2040-boot2 = { version = "0.2" }
31+
32+
[features]
33+
default = ['defmt-default']
34+
# these features are required by defmt
35+
defmt-default = []
36+
defmt-trace = []
37+
defmt-debug = []
38+
defmt-info = []
39+
defmt-warn = []
40+
defmt-error = []

examples/get_fw_version.rs renamed to cross/get_fw_version/src/main.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use panic_probe as _;
2121
// Alias for our HAL crate
2222
use rp2040_hal as hal;
2323

24-
use eh_02::spi::MODE_0;
24+
use embedded_hal::spi::MODE_0;
2525
use embedded_time::fixed_point::FixedPoint;
2626
use embedded_time::rate::Extensions;
2727
use hal::clocks::Clock;
@@ -37,24 +37,6 @@ pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
3737
/// if your board has a different frequency
3838
const XTAL_FREQ_HZ: u32 = 12_000_000u32;
3939

40-
// Until cortex_m implements the DelayUs trait needed for embedded-hal-1.0.0,
41-
// provide a wrapper around it
42-
pub struct DelayWrap(cortex_m::delay::Delay);
43-
44-
impl embedded_hal::delay::blocking::DelayUs for DelayWrap {
45-
type Error = core::convert::Infallible;
46-
47-
fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> {
48-
self.0.delay_us(us);
49-
Ok(())
50-
}
51-
52-
fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error> {
53-
self.0.delay_ms(ms);
54-
Ok(())
55-
}
56-
}
57-
5840
/// Entry point to our bare-metal application.
5941
///
6042
/// The `#[entry]` macro ensures the Cortex-M start-up code calls this function
@@ -81,10 +63,10 @@ fn main() -> ! {
8163
.ok()
8264
.unwrap();
8365

84-
let mut delay = DelayWrap(cortex_m::delay::Delay::new(
66+
let mut delay = cortex_m::delay::Delay::new(
8567
core.SYST,
8668
clocks.system_clock.freq().integer(),
87-
));
69+
);
8870

8971
// The single-cycle I/O block controls our GPIO pins
9072
let sio = hal::Sio::new(pac.SIO);
File renamed without changes.

cross/join/Cargo.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[package]
2+
authors = [
3+
"Jim Hodapp",
4+
"Caleb Bourg",
5+
"Glyn Matthews"
6+
]
7+
edition = "2021"
8+
name = "join"
9+
version = "0.1.0"
10+
description = "Example target application that joins/leaves an SSID with the Rust-based Espressif ESP32-WROOM WiFi driver crate for RP2040 series microcontroller boards."
11+
12+
# makes `cargo check --all-targets` work
13+
[[bin]]
14+
name = "join"
15+
bench = false
16+
doctest = false
17+
test = false
18+
19+
[dependencies]
20+
defmt = "0.3.0"
21+
defmt-rtt = "0.3.0"
22+
cortex-m = "0.7"
23+
cortex-m-rt = "0.7"
24+
embedded-hal = { version = "0.2", features=["unproven"] }
25+
embedded-time = "0.12"
26+
esp32-wroom-rp = { path = "../../esp32-wroom-rp" }
27+
panic-probe = { version = "0.3.0", features = ["print-rtt"] }
28+
29+
rp2040-hal = { version = "0.5", features=["rt", "eh1_0_alpha"] }
30+
rp2040-boot2 = { version = "0.2" }
31+
32+
[features]
33+
default = ['defmt-default']
34+
# these features are required by defmt
35+
defmt-default = []
36+
defmt-trace = []
37+
defmt-debug = []
38+
defmt-info = []
39+
defmt-warn = []
40+
defmt-error = []

0 commit comments

Comments
 (0)