diff options
Diffstat (limited to 'cyw43-pio/src')
| -rw-r--r-- | cyw43-pio/src/lib.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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; |
