aboutsummaryrefslogtreecommitdiff
path: root/cyw43-pio
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2023-12-19 16:08:06 +0100
committerUlf Lilleengen <[email protected]>2023-12-19 16:08:06 +0100
commit39c166ef9b754c5caa44ef4dd4a4e216078dbcea (patch)
treecece1955c41b80d92bd8056cc265a91cf3d0cf79 /cyw43-pio
parent5e76c8b41a05c89652a6c53061107482adc4125f (diff)
docs: document public apis for cyw43 driver
Diffstat (limited to 'cyw43-pio')
-rw-r--r--cyw43-pio/README.md17
-rw-r--r--cyw43-pio/src/lib.rs6
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
3RP2040 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
7Embassy 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
11This 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
17at 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
4use core::slice; 6use core::slice;
5 7
@@ -11,6 +13,7 @@ use embassy_rp::{Peripheral, PeripheralRef};
11use fixed::FixedU32; 13use fixed::FixedU32;
12use pio_proc::pio_asm; 14use pio_proc::pio_asm;
13 15
16/// SPI comms driven by PIO.
14pub struct PioSpi<'d, CS: Pin, PIO: Instance, const SM: usize, DMA> { 17pub 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;