diff options
| author | kbleeke <[email protected]> | 2023-02-19 16:31:33 +0100 |
|---|---|---|
| committer | kbleeke <[email protected]> | 2023-03-19 16:57:54 +0100 |
| commit | d57fe0de867cfc6510f0192fab488355d9ae8586 (patch) | |
| tree | 08a59192f1dbba10000759cb2d473178beefda00 /examples | |
| parent | e33b99e9ec9902d6f93582530fd9cfe38953ce69 (diff) | |
Custom Bus Trait to support PIO
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rpi-pico-w/build.rs | 34 | ||||
| -rw-r--r-- | examples/rpi-pico-w/src/main.rs | 11 |
2 files changed, 28 insertions, 17 deletions
diff --git a/examples/rpi-pico-w/build.rs b/examples/rpi-pico-w/build.rs index 3f915f931..d4c3ec89d 100644 --- a/examples/rpi-pico-w/build.rs +++ b/examples/rpi-pico-w/build.rs | |||
| @@ -14,23 +14,23 @@ use std::io::Write; | |||
| 14 | use std::path::PathBuf; | 14 | use std::path::PathBuf; |
| 15 | 15 | ||
| 16 | fn main() { | 16 | fn main() { |
| 17 | // Put `memory.x` in our output directory and ensure it's | 17 | // // Put `memory.x` in our output directory and ensure it's |
| 18 | // on the linker search path. | 18 | // // on the linker search path. |
| 19 | let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | 19 | // let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); |
| 20 | File::create(out.join("memory.x")) | 20 | // File::create(out.join("memory.x")) |
| 21 | .unwrap() | 21 | // .unwrap() |
| 22 | .write_all(include_bytes!("memory.x")) | 22 | // .write_all(include_bytes!("memory.x")) |
| 23 | .unwrap(); | 23 | // .unwrap(); |
| 24 | println!("cargo:rustc-link-search={}", out.display()); | 24 | // println!("cargo:rustc-link-search={}", out.display()); |
| 25 | 25 | ||
| 26 | // By default, Cargo will re-run a build script whenever | 26 | // // By default, Cargo will re-run a build script whenever |
| 27 | // any file in the project changes. By specifying `memory.x` | 27 | // // any file in the project changes. By specifying `memory.x` |
| 28 | // here, we ensure the build script is only re-run when | 28 | // // here, we ensure the build script is only re-run when |
| 29 | // `memory.x` is changed. | 29 | // // `memory.x` is changed. |
| 30 | println!("cargo:rerun-if-changed=memory.x"); | 30 | // println!("cargo:rerun-if-changed=memory.x"); |
| 31 | 31 | ||
| 32 | println!("cargo:rustc-link-arg-bins=--nmagic"); | 32 | // println!("cargo:rustc-link-arg-bins=--nmagic"); |
| 33 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | 33 | // println!("cargo:rustc-link-arg-bins=-Tlink.x"); |
| 34 | println!("cargo:rustc-link-arg-bins=-Tlink-rp.x"); | 34 | // println!("cargo:rustc-link-arg-bins=-Tlink-rp.x"); |
| 35 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | 35 | // println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); |
| 36 | } | 36 | } |
diff --git a/examples/rpi-pico-w/src/main.rs b/examples/rpi-pico-w/src/main.rs index c706e121d..f768af193 100644 --- a/examples/rpi-pico-w/src/main.rs +++ b/examples/rpi-pico-w/src/main.rs | |||
| @@ -161,6 +161,17 @@ impl ErrorType for MySpi { | |||
| 161 | type Error = Infallible; | 161 | type Error = Infallible; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | impl cyw43::SpiBusCyw43<u32> for MySpi { | ||
| 165 | async fn cmd_write<'a>(&'a mut self, write: &'a [u32]) -> Result<(), Self::Error> { | ||
| 166 | self.write(write).await | ||
| 167 | } | ||
| 168 | |||
| 169 | async fn cmd_read<'a>(&'a mut self, write: &'a [u32], read: &'a mut [u32]) -> Result<(), Self::Error> { | ||
| 170 | self.write(write).await?; | ||
| 171 | self.read(read).await | ||
| 172 | } | ||
| 173 | } | ||
| 174 | |||
| 164 | impl SpiBusFlush for MySpi { | 175 | impl SpiBusFlush for MySpi { |
| 165 | async fn flush(&mut self) -> Result<(), Self::Error> { | 176 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 166 | Ok(()) | 177 | Ok(()) |
