Custom Bus Trait to support PIO

This commit is contained in:
kbleeke
2023-02-19 16:31:33 +01:00
parent e33b99e9ec
commit d57fe0de86
4 changed files with 104 additions and 49 deletions

View File

@ -14,23 +14,23 @@ use std::io::Write;
use std::path::PathBuf;
fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
// // Put `memory.x` in our output directory and ensure it's
// // on the linker search path.
// let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
// File::create(out.join("memory.x"))
// .unwrap()
// .write_all(include_bytes!("memory.x"))
// .unwrap();
// println!("cargo:rustc-link-search={}", out.display());
// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");
// // By default, Cargo will re-run a build script whenever
// // any file in the project changes. By specifying `memory.x`
// // here, we ensure the build script is only re-run when
// // `memory.x` is changed.
// println!("cargo:rerun-if-changed=memory.x");
println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
// println!("cargo:rustc-link-arg-bins=--nmagic");
// println!("cargo:rustc-link-arg-bins=-Tlink.x");
// println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
// println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
}

View File

@ -161,6 +161,17 @@ impl ErrorType for MySpi {
type Error = Infallible;
}
impl cyw43::SpiBusCyw43<u32> for MySpi {
async fn cmd_write<'a>(&'a mut self, write: &'a [u32]) -> Result<(), Self::Error> {
self.write(write).await
}
async fn cmd_read<'a>(&'a mut self, write: &'a [u32], read: &'a mut [u32]) -> Result<(), Self::Error> {
self.write(write).await?;
self.read(read).await
}
}
impl SpiBusFlush for MySpi {
async fn flush(&mut self) -> Result<(), Self::Error> {
Ok(())