diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-03-26 16:01:37 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-03-27 15:18:06 +0100 |
| commit | d41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch) | |
| tree | 678b6fc732216e529dc38e6f65b72a309917ac32 /cyw43-pio | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'cyw43-pio')
| -rw-r--r-- | cyw43-pio/src/lib.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/cyw43-pio/src/lib.rs b/cyw43-pio/src/lib.rs index c1b301547..b0be19358 100644 --- a/cyw43-pio/src/lib.rs +++ b/cyw43-pio/src/lib.rs | |||
| @@ -10,16 +10,16 @@ use embassy_rp::dma::Channel; | |||
| 10 | use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate}; | 10 | use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate}; |
| 11 | use embassy_rp::pio::program::pio_asm; | 11 | use embassy_rp::pio::program::pio_asm; |
| 12 | use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; | 12 | use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; |
| 13 | use embassy_rp::{Peripheral, PeripheralRef}; | 13 | use embassy_rp::Peri; |
| 14 | use fixed::types::extra::U8; | 14 | use fixed::types::extra::U8; |
| 15 | use fixed::FixedU32; | 15 | use fixed::FixedU32; |
| 16 | 16 | ||
| 17 | /// SPI comms driven by PIO. | 17 | /// SPI comms driven by PIO. |
| 18 | pub struct PioSpi<'d, PIO: Instance, const SM: usize, DMA> { | 18 | pub struct PioSpi<'d, PIO: Instance, const SM: usize, DMA: Channel> { |
| 19 | cs: Output<'d>, | 19 | cs: Output<'d>, |
| 20 | sm: StateMachine<'d, PIO, SM>, | 20 | sm: StateMachine<'d, PIO, SM>, |
| 21 | irq: Irq<'d, PIO, 0>, | 21 | irq: Irq<'d, PIO, 0>, |
| 22 | dma: PeripheralRef<'d, DMA>, | 22 | dma: Peri<'d, DMA>, |
| 23 | wrap_target: u8, | 23 | wrap_target: u8, |
| 24 | } | 24 | } |
| 25 | 25 | ||
| @@ -48,20 +48,16 @@ where | |||
| 48 | PIO: Instance, | 48 | PIO: Instance, |
| 49 | { | 49 | { |
| 50 | /// Create a new instance of PioSpi. | 50 | /// Create a new instance of PioSpi. |
| 51 | pub fn new<DIO, CLK>( | 51 | pub fn new( |
| 52 | common: &mut Common<'d, PIO>, | 52 | common: &mut Common<'d, PIO>, |
| 53 | mut sm: StateMachine<'d, PIO, SM>, | 53 | mut sm: StateMachine<'d, PIO, SM>, |
| 54 | clock_divider: FixedU32<U8>, | 54 | clock_divider: FixedU32<U8>, |
| 55 | irq: Irq<'d, PIO, 0>, | 55 | irq: Irq<'d, PIO, 0>, |
| 56 | cs: Output<'d>, | 56 | cs: Output<'d>, |
| 57 | dio: DIO, | 57 | dio: Peri<'d, impl PioPin>, |
| 58 | clk: CLK, | 58 | clk: Peri<'d, impl PioPin>, |
| 59 | dma: impl Peripheral<P = DMA> + 'd, | 59 | dma: Peri<'d, DMA>, |
| 60 | ) -> Self | 60 | ) -> Self { |
| 61 | where | ||
| 62 | DIO: PioPin, | ||
| 63 | CLK: PioPin, | ||
| 64 | { | ||
| 65 | let loaded_program = if clock_divider < DEFAULT_CLOCK_DIVIDER { | 61 | let loaded_program = if clock_divider < DEFAULT_CLOCK_DIVIDER { |
| 66 | let overclock_program = pio_asm!( | 62 | let overclock_program = pio_asm!( |
| 67 | ".side_set 1" | 63 | ".side_set 1" |
| @@ -146,7 +142,7 @@ where | |||
| 146 | cs, | 142 | cs, |
| 147 | sm, | 143 | sm, |
| 148 | irq, | 144 | irq, |
| 149 | dma: dma.into_ref(), | 145 | dma: dma, |
| 150 | wrap_target: loaded_program.wrap.target, | 146 | wrap_target: loaded_program.wrap.target, |
| 151 | } | 147 | } |
| 152 | } | 148 | } |
