diff options
| author | Ulf Lilleengen <[email protected]> | 2023-12-19 16:08:06 +0100 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2023-12-19 16:08:06 +0100 |
| commit | 39c166ef9b754c5caa44ef4dd4a4e216078dbcea (patch) | |
| tree | cece1955c41b80d92bd8056cc265a91cf3d0cf79 /cyw43-pio | |
| parent | 5e76c8b41a05c89652a6c53061107482adc4125f (diff) | |
docs: document public apis for cyw43 driver
Diffstat (limited to 'cyw43-pio')
| -rw-r--r-- | cyw43-pio/README.md | 17 | ||||
| -rw-r--r-- | cyw43-pio/src/lib.rs | 6 |
2 files changed, 23 insertions, 0 deletions
diff --git a/cyw43-pio/README.md b/cyw43-pio/README.md new file mode 100644 index 000000000..2b22db360 --- /dev/null +++ b/cyw43-pio/README.md | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | # cyw43-pio | ||
| 2 | |||
| 3 | RP2040 PIO driver for the nonstandard half-duplex SPI used in the Pico W. The PIO driver offloads SPI communication with the WiFi chip and improves throughput. | ||
| 4 | |||
| 5 | ## Minimum supported Rust version (MSRV) | ||
| 6 | |||
| 7 | Embassy is guaranteed to compile on the latest stable Rust version at the time of release. It might compile with older versions but that may change in any new patch release. | ||
| 8 | |||
| 9 | ## License | ||
| 10 | |||
| 11 | This work is licensed under either of | ||
| 12 | |||
| 13 | - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or | ||
| 14 | <http://www.apache.org/licenses/LICENSE-2.0>) | ||
| 15 | - MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>) | ||
| 16 | |||
| 17 | at your option. | ||
diff --git a/cyw43-pio/src/lib.rs b/cyw43-pio/src/lib.rs index 8304740b3..5efab10e4 100644 --- a/cyw43-pio/src/lib.rs +++ b/cyw43-pio/src/lib.rs | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![doc = include_str!("../README.md")] | ||
| 4 | #![warn(missing_docs)] | ||
| 3 | 5 | ||
| 4 | use core::slice; | 6 | use core::slice; |
| 5 | 7 | ||
| @@ -11,6 +13,7 @@ use embassy_rp::{Peripheral, PeripheralRef}; | |||
| 11 | use fixed::FixedU32; | 13 | use fixed::FixedU32; |
| 12 | use pio_proc::pio_asm; | 14 | use pio_proc::pio_asm; |
| 13 | 15 | ||
| 16 | /// SPI comms driven by PIO. | ||
| 14 | pub struct PioSpi<'d, CS: Pin, PIO: Instance, const SM: usize, DMA> { | 17 | pub struct PioSpi<'d, CS: Pin, PIO: Instance, const SM: usize, DMA> { |
| 15 | cs: Output<'d, CS>, | 18 | cs: Output<'d, CS>, |
| 16 | sm: StateMachine<'d, PIO, SM>, | 19 | sm: StateMachine<'d, PIO, SM>, |
| @@ -25,6 +28,7 @@ where | |||
| 25 | CS: Pin, | 28 | CS: Pin, |
| 26 | PIO: Instance, | 29 | PIO: Instance, |
| 27 | { | 30 | { |
| 31 | /// Create a new instance of PioSpi. | ||
| 28 | pub fn new<DIO, CLK>( | 32 | pub fn new<DIO, CLK>( |
| 29 | common: &mut Common<'d, PIO>, | 33 | common: &mut Common<'d, PIO>, |
| 30 | mut sm: StateMachine<'d, PIO, SM>, | 34 | mut sm: StateMachine<'d, PIO, SM>, |
| @@ -143,6 +147,7 @@ where | |||
| 143 | } | 147 | } |
| 144 | } | 148 | } |
| 145 | 149 | ||
| 150 | /// Write data to peripheral and return status. | ||
| 146 | pub async fn write(&mut self, write: &[u32]) -> u32 { | 151 | pub async fn write(&mut self, write: &[u32]) -> u32 { |
| 147 | self.sm.set_enable(false); | 152 | self.sm.set_enable(false); |
| 148 | let write_bits = write.len() * 32 - 1; | 153 | let write_bits = write.len() * 32 - 1; |
| @@ -170,6 +175,7 @@ where | |||
| 170 | status | 175 | status |
| 171 | } | 176 | } |
| 172 | 177 | ||
| 178 | /// Send command and read response into buffer. | ||
| 173 | pub async fn cmd_read(&mut self, cmd: u32, read: &mut [u32]) -> u32 { | 179 | pub async fn cmd_read(&mut self, cmd: u32, read: &mut [u32]) -> u32 { |
| 174 | self.sm.set_enable(false); | 180 | self.sm.set_enable(false); |
| 175 | let write_bits = 31; | 181 | let write_bits = 31; |
