diff options
| author | kbleeke <[email protected]> | 2023-03-27 18:04:48 +0200 |
|---|---|---|
| committer | kbleeke <[email protected]> | 2023-03-27 19:00:20 +0200 |
| commit | 20ea35fc9639487eaa21f1dcee6c32d8a66a0fbb (patch) | |
| tree | 20b44e30e4bce17d3c5c6cc342c0888bf60c3bbe | |
| parent | d918919cb20a3b8139013638193c22b3744b0f1d (diff) | |
Move pio driver to separate crate
| -rw-r--r-- | .vscode/settings.json | 1 | ||||
| -rw-r--r-- | Cargo.toml | 6 | ||||
| -rw-r--r-- | cyw43-pio/Cargo.toml | 13 | ||||
| -rw-r--r-- | cyw43-pio/src/lib.rs (renamed from examples/rpi-pico-w/src/pio.rs) | 12 | ||||
| -rw-r--r-- | examples/rpi-pico-w/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/rpi-pico-w/src/main.rs | 5 |
6 files changed, 31 insertions, 9 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index dd479929e..344307695 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | "rust-analyzer.check.noDefaultFeatures": true, | 9 | "rust-analyzer.check.noDefaultFeatures": true, |
| 10 | "rust-analyzer.linkedProjects": [ | 10 | "rust-analyzer.linkedProjects": [ |
| 11 | "examples/rpi-pico-w/Cargo.toml", | 11 | "examples/rpi-pico-w/Cargo.toml", |
| 12 | "cyw43-pio/Cargo.toml", | ||
| 12 | ], | 13 | ], |
| 13 | "rust-analyzer.server.extraEnv": { | 14 | "rust-analyzer.server.extraEnv": { |
| 14 | "WIFI_NETWORK": "foo", | 15 | "WIFI_NETWORK": "foo", |
diff --git a/Cargo.toml b/Cargo.toml index a307a6cc3..04a47a3a5 100644 --- a/Cargo.toml +++ b/Cargo.toml | |||
| @@ -32,3 +32,9 @@ embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3 | |||
| 32 | embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" } | 32 | embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" } |
| 33 | embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" } | 33 | embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" } |
| 34 | embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" } | 34 | embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" } |
| 35 | embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" } | ||
| 36 | |||
| 37 | [workspace] | ||
| 38 | members = ["cyw43-pio"] | ||
| 39 | default-members = ["cyw43-pio", "."] | ||
| 40 | exclude = ["examples"] \ No newline at end of file | ||
diff --git a/cyw43-pio/Cargo.toml b/cyw43-pio/Cargo.toml new file mode 100644 index 000000000..2fc6b7591 --- /dev/null +++ b/cyw43-pio/Cargo.toml | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | [package] | ||
| 2 | name = "cyw43-pio" | ||
| 3 | version = "0.1.0" | ||
| 4 | edition = "2021" | ||
| 5 | |||
| 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
| 7 | |||
| 8 | [dependencies] | ||
| 9 | cyw43 = { path = "../" } | ||
| 10 | embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "pio"] } | ||
| 11 | pio-proc = "0.2" | ||
| 12 | pio = "0.2.1" | ||
| 13 | defmt = "0.3" \ No newline at end of file | ||
diff --git a/examples/rpi-pico-w/src/pio.rs b/cyw43-pio/src/lib.rs index 846113060..2159796cd 100644 --- a/examples/rpi-pico-w/src/pio.rs +++ b/cyw43-pio/src/lib.rs | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![allow(incomplete_features)] | ||
| 3 | #![feature(async_fn_in_trait)] | ||
| 4 | |||
| 1 | use core::slice; | 5 | use core::slice; |
| 2 | 6 | ||
| 3 | use cyw43::SpiBusCyw43; | 7 | use cyw43::SpiBusCyw43; |
| @@ -125,7 +129,8 @@ where | |||
| 125 | 129 | ||
| 126 | self.sm.dma_push(dma.reborrow(), write).await; | 130 | self.sm.dma_push(dma.reborrow(), write).await; |
| 127 | 131 | ||
| 128 | let status = self.sm.wait_pull().await; | 132 | let mut status = 0; |
| 133 | self.sm.dma_pull(dma.reborrow(), slice::from_mut(&mut status)).await; | ||
| 129 | status | 134 | status |
| 130 | } | 135 | } |
| 131 | 136 | ||
| @@ -145,9 +150,10 @@ where | |||
| 145 | self.sm.set_enable(true); | 150 | self.sm.set_enable(true); |
| 146 | 151 | ||
| 147 | self.sm.dma_push(dma.reborrow(), slice::from_ref(&cmd)).await; | 152 | self.sm.dma_push(dma.reborrow(), slice::from_ref(&cmd)).await; |
| 148 | self.sm.dma_pull(dma, read).await; | 153 | self.sm.dma_pull(dma.reborrow(), read).await; |
| 149 | 154 | ||
| 150 | let status = self.sm.wait_pull().await; | 155 | let mut status = 0; |
| 156 | self.sm.dma_pull(dma.reborrow(), slice::from_mut(&mut status)).await; | ||
| 151 | status | 157 | status |
| 152 | } | 158 | } |
| 153 | } | 159 | } |
diff --git a/examples/rpi-pico-w/Cargo.toml b/examples/rpi-pico-w/Cargo.toml index 4a531c88c..41ee8a3c4 100644 --- a/examples/rpi-pico-w/Cargo.toml +++ b/examples/rpi-pico-w/Cargo.toml | |||
| @@ -6,6 +6,7 @@ edition = "2021" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | cyw43 = { path = "../../", features = ["defmt", "firmware-logs"] } | 8 | cyw43 = { path = "../../", features = ["defmt", "firmware-logs"] } |
| 9 | cyw43-pio = { path = "../../cyw43-pio" } | ||
| 9 | embassy-executor = { version = "0.1.0", features = ["defmt", "integrated-timers"] } | 10 | embassy-executor = { version = "0.1.0", features = ["defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] } | 11 | embassy-time = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] } |
| 11 | embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "pio"] } | 12 | embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "pio"] } |
| @@ -20,8 +21,6 @@ panic-probe = { version = "0.3", features = ["print-defmt"] } | |||
| 20 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | 21 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 21 | cortex-m-rt = "0.7.0" | 22 | cortex-m-rt = "0.7.0" |
| 22 | futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } | 23 | futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } |
| 23 | pio-proc = "0.2" | ||
| 24 | pio = "0.2.1" | ||
| 25 | 24 | ||
| 26 | embedded-io = { version = "0.4.0", features = ["async", "defmt"] } | 25 | embedded-io = { version = "0.4.0", features = ["async", "defmt"] } |
| 27 | heapless = "0.7.15" | 26 | heapless = "0.7.15" |
diff --git a/examples/rpi-pico-w/src/main.rs b/examples/rpi-pico-w/src/main.rs index e3c59223b..4b1623be7 100644 --- a/examples/rpi-pico-w/src/main.rs +++ b/examples/rpi-pico-w/src/main.rs | |||
| @@ -4,11 +4,10 @@ | |||
| 4 | #![feature(async_fn_in_trait)] | 4 | #![feature(async_fn_in_trait)] |
| 5 | #![allow(incomplete_features)] | 5 | #![allow(incomplete_features)] |
| 6 | 6 | ||
| 7 | mod pio; | ||
| 8 | |||
| 9 | use core::slice; | 7 | use core::slice; |
| 10 | use core::str::from_utf8; | 8 | use core::str::from_utf8; |
| 11 | 9 | ||
| 10 | use cyw43_pio::PioSpi; | ||
| 12 | use defmt::*; | 11 | use defmt::*; |
| 13 | use embassy_executor::Spawner; | 12 | use embassy_executor::Spawner; |
| 14 | use embassy_net::tcp::TcpSocket; | 13 | use embassy_net::tcp::TcpSocket; |
| @@ -20,8 +19,6 @@ use embedded_io::asynch::Write; | |||
| 20 | use static_cell::StaticCell; | 19 | use static_cell::StaticCell; |
| 21 | use {defmt_rtt as _, panic_probe as _}; | 20 | use {defmt_rtt as _, panic_probe as _}; |
| 22 | 21 | ||
| 23 | use crate::pio::PioSpi; | ||
| 24 | |||
| 25 | macro_rules! singleton { | 22 | macro_rules! singleton { |
| 26 | ($val:expr) => {{ | 23 | ($val:expr) => {{ |
| 27 | type T = impl Sized; | 24 | type T = impl Sized; |
