Move pio driver to separate crate

This commit is contained in:
kbleeke 2023-03-27 18:04:48 +02:00
parent d918919cb2
commit 20ea35fc96
6 changed files with 31 additions and 9 deletions

View file

@ -9,6 +9,7 @@
"rust-analyzer.check.noDefaultFeatures": true, "rust-analyzer.check.noDefaultFeatures": true,
"rust-analyzer.linkedProjects": [ "rust-analyzer.linkedProjects": [
"examples/rpi-pico-w/Cargo.toml", "examples/rpi-pico-w/Cargo.toml",
"cyw43-pio/Cargo.toml",
], ],
"rust-analyzer.server.extraEnv": { "rust-analyzer.server.extraEnv": {
"WIFI_NETWORK": "foo", "WIFI_NETWORK": "foo",

View file

@ -32,3 +32,9 @@ embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3
embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" } embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" }
embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" } embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" }
embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" } embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" }
embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "e3f8020c3bdf726dfa451b5b190f27191507a18f" }
[workspace]
members = ["cyw43-pio"]
default-members = ["cyw43-pio", "."]
exclude = ["examples"]

13
cyw43-pio/Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "cyw43-pio"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
cyw43 = { path = "../" }
embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "pio"] }
pio-proc = "0.2"
pio = "0.2.1"
defmt = "0.3"

View file

@ -1,3 +1,7 @@
#![no_std]
#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]
use core::slice; use core::slice;
use cyw43::SpiBusCyw43; use cyw43::SpiBusCyw43;
@ -125,7 +129,8 @@ where
self.sm.dma_push(dma.reborrow(), write).await; self.sm.dma_push(dma.reborrow(), write).await;
let status = self.sm.wait_pull().await; let mut status = 0;
self.sm.dma_pull(dma.reborrow(), slice::from_mut(&mut status)).await;
status status
} }
@ -145,9 +150,10 @@ where
self.sm.set_enable(true); self.sm.set_enable(true);
self.sm.dma_push(dma.reborrow(), slice::from_ref(&cmd)).await; self.sm.dma_push(dma.reborrow(), slice::from_ref(&cmd)).await;
self.sm.dma_pull(dma, read).await; self.sm.dma_pull(dma.reborrow(), read).await;
let status = self.sm.wait_pull().await; let mut status = 0;
self.sm.dma_pull(dma.reborrow(), slice::from_mut(&mut status)).await;
status status
} }
} }

View file

@ -6,6 +6,7 @@ edition = "2021"
[dependencies] [dependencies]
cyw43 = { path = "../../", features = ["defmt", "firmware-logs"] } cyw43 = { path = "../../", features = ["defmt", "firmware-logs"] }
cyw43-pio = { path = "../../cyw43-pio" }
embassy-executor = { version = "0.1.0", features = ["defmt", "integrated-timers"] } embassy-executor = { version = "0.1.0", features = ["defmt", "integrated-timers"] }
embassy-time = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] } embassy-time = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "pio"] } 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"] }
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0" cortex-m-rt = "0.7.0"
futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }
pio-proc = "0.2"
pio = "0.2.1"
embedded-io = { version = "0.4.0", features = ["async", "defmt"] } embedded-io = { version = "0.4.0", features = ["async", "defmt"] }
heapless = "0.7.15" heapless = "0.7.15"

View file

@ -4,11 +4,10 @@
#![feature(async_fn_in_trait)] #![feature(async_fn_in_trait)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
mod pio;
use core::slice; use core::slice;
use core::str::from_utf8; use core::str::from_utf8;
use cyw43_pio::PioSpi;
use defmt::*; use defmt::*;
use embassy_executor::Spawner; use embassy_executor::Spawner;
use embassy_net::tcp::TcpSocket; use embassy_net::tcp::TcpSocket;
@ -20,8 +19,6 @@ use embedded_io::asynch::Write;
use static_cell::StaticCell; use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _}; use {defmt_rtt as _, panic_probe as _};
use crate::pio::PioSpi;
macro_rules! singleton { macro_rules! singleton {
($val:expr) => {{ ($val:expr) => {{
type T = impl Sized; type T = impl Sized;