aboutsummaryrefslogtreecommitdiff
path: root/cyw43-pio/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cyw43-pio/src/lib.rs')
-rw-r--r--cyw43-pio/src/lib.rs22
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;
10use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate}; 10use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate};
11use embassy_rp::pio::program::pio_asm; 11use embassy_rp::pio::program::pio_asm;
12use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; 12use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine};
13use embassy_rp::{Peripheral, PeripheralRef}; 13use embassy_rp::Peri;
14use fixed::types::extra::U8; 14use fixed::types::extra::U8;
15use fixed::FixedU32; 15use fixed::FixedU32;
16 16
17/// SPI comms driven by PIO. 17/// SPI comms driven by PIO.
18pub struct PioSpi<'d, PIO: Instance, const SM: usize, DMA> { 18pub 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 }