Merge pull request #54 from kbleeke/pio-irq

Move pio driver to separate crate
This commit is contained in:
Dario Nieuwenhuis 2023-03-27 17:08:54 +00:00 committed by GitHub
commit e9e2be137f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;