aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-05-14 21:08:37 +0000
committerGitHub <[email protected]>2023-05-14 21:08:37 +0000
commita3d6aa5d7d5dfeaeed4162cbdac35494bbdc1486 (patch)
treefe3fabb100ece7ad22a4a8db9803e7d14077539f
parent7cfce05bd2622b843a7ece65bfde6ffa32130718 (diff)
parentdb907a914c7e84176a15da70385af871c9b97cf6 (diff)
Merge pull request #79 from embassy-rs/update-embassy
Update Embassy, to new PIO API.
-rw-r--r--Cargo.toml12
-rwxr-xr-xci.sh5
-rw-r--r--cyw43-pio/Cargo.toml6
-rw-r--r--cyw43-pio/src/lib.rs204
-rw-r--r--examples/rpi-pico-w/Cargo.toml22
-rw-r--r--examples/rpi-pico-w/src/bin/tcp_server.rs16
-rw-r--r--examples/rpi-pico-w/src/bin/tcp_server_ap.rs16
-rw-r--r--examples/rpi-pico-w/src/bin/wifi_scan.rs16
8 files changed, 160 insertions, 137 deletions
diff --git a/Cargo.toml b/Cargo.toml
index c4872f423..2bb2b8d93 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@ firmware-logs = []
12 12
13[dependencies] 13[dependencies]
14embassy-time = { version = "0.1.0" } 14embassy-time = { version = "0.1.0" }
15embassy-sync = { version = "0.1.0" } 15embassy-sync = { version = "0.2.0" }
16embassy-futures = { version = "0.1.0" } 16embassy-futures = { version = "0.1.0" }
17embassy-net-driver-channel = { version = "0.1.0" } 17embassy-net-driver-channel = { version = "0.1.0" }
18atomic-polyfill = "0.1.5" 18atomic-polyfill = "0.1.5"
@@ -28,11 +28,11 @@ embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.10" }
28num_enum = { version = "0.5.7", default-features = false } 28num_enum = { version = "0.5.7", default-features = false }
29 29
30[patch.crates-io] 30[patch.crates-io]
31embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 31embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
32embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 32embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
33embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 33embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
34embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 34embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
35embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 35embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
36 36
37[workspace] 37[workspace]
38members = ["cyw43-pio"] 38members = ["cyw43-pio"]
diff --git a/ci.sh b/ci.sh
index d41b3aa81..916838200 100755
--- a/ci.sh
+++ b/ci.sh
@@ -1,7 +1,9 @@
1#!/bin/bash 1#!/bin/bash
2 2
3set -euxo pipefail 3set -euxo pipefail
4cd $(dirname $0)
4 5
6export CARGO_TARGET_DIR=$(pwd)/target
5export DEFMT_LOG=trace 7export DEFMT_LOG=trace
6 8
7# build examples 9# build examples
@@ -18,3 +20,6 @@ cargo build --target thumbv6m-none-eabi --features 'log'
18cargo build --target thumbv6m-none-eabi --features 'defmt' 20cargo build --target thumbv6m-none-eabi --features 'defmt'
19cargo build --target thumbv6m-none-eabi --features 'log,firmware-logs' 21cargo build --target thumbv6m-none-eabi --features 'log,firmware-logs'
20cargo build --target thumbv6m-none-eabi --features 'defmt,firmware-logs' 22cargo build --target thumbv6m-none-eabi --features 'defmt,firmware-logs'
23
24(cd cyw43-pio; cargo build --target thumbv6m-none-eabi --features '')
25(cd cyw43-pio; cargo build --target thumbv6m-none-eabi --features 'overclock')
diff --git a/cyw43-pio/Cargo.toml b/cyw43-pio/Cargo.toml
index 8272903c3..2238f7617 100644
--- a/cyw43-pio/Cargo.toml
+++ b/cyw43-pio/Cargo.toml
@@ -3,9 +3,15 @@ name = "cyw43-pio"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2021" 4edition = "2021"
5 5
6[features]
7# If disabled, SPI runs at 31.25MHz
8# If enabled, SPI runs at 62.5MHz, which is 25% higher than 50Mhz which is the maximum according to the CYW43439 datasheet.
9overclock = []
10
6[dependencies] 11[dependencies]
7cyw43 = { path = "../" } 12cyw43 = { path = "../" }
8embassy-rp = { version = "0.1.0", features = ["unstable-traits", "nightly", "unstable-pac", "time-driver"] } 13embassy-rp = { version = "0.1.0", features = ["unstable-traits", "nightly", "unstable-pac", "time-driver"] }
9pio-proc = "0.2" 14pio-proc = "0.2"
10pio = "0.2.1" 15pio = "0.2.1"
16fixed = "1.23.1"
11defmt = { version = "0.3", optional = true } \ No newline at end of file 17defmt = { version = "0.3", optional = true } \ No newline at end of file
diff --git a/cyw43-pio/src/lib.rs b/cyw43-pio/src/lib.rs
index c468435f1..dca30c74d 100644
--- a/cyw43-pio/src/lib.rs
+++ b/cyw43-pio/src/lib.rs
@@ -6,49 +6,80 @@ use core::slice;
6 6
7use cyw43::SpiBusCyw43; 7use cyw43::SpiBusCyw43;
8use embassy_rp::dma::Channel; 8use embassy_rp::dma::Channel;
9use embassy_rp::gpio::{Drive, Output, Pin, Pull, SlewRate}; 9use embassy_rp::gpio::{Drive, Level, Output, Pin, Pull, SlewRate};
10use embassy_rp::pio::{PioStateMachine, ShiftDirection}; 10use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine};
11use embassy_rp::relocate::RelocatedProgram; 11use embassy_rp::relocate::RelocatedProgram;
12use embassy_rp::{pio_instr_util, Peripheral}; 12use embassy_rp::{pio_instr_util, Peripheral, PeripheralRef};
13use pio::Wrap; 13use fixed::FixedU32;
14use pio_proc::pio_asm; 14use pio_proc::pio_asm;
15 15
16pub struct PioSpi<CS: Pin, SM, DMA> { 16pub struct PioSpi<'d, CS: Pin, PIO: Instance, const SM: usize, DMA> {
17 cs: Output<'static, CS>, 17 cs: Output<'d, CS>,
18 sm: SM, 18 sm: StateMachine<'d, PIO, SM>,
19 dma: DMA, 19 irq: Irq<'d, PIO, 0>,
20 dma: PeripheralRef<'d, DMA>,
20 wrap_target: u8, 21 wrap_target: u8,
21} 22}
22 23
23impl<CS, SM, DMA> PioSpi<CS, SM, DMA> 24impl<'d, CS, PIO, const SM: usize, DMA> PioSpi<'d, CS, PIO, SM, DMA>
24where 25where
25 SM: PioStateMachine,
26 DMA: Channel, 26 DMA: Channel,
27 CS: Pin, 27 CS: Pin,
28 PIO: Instance,
28{ 29{
29 pub fn new<DIO, CLK>(mut sm: SM, cs: Output<'static, CS>, dio: DIO, clk: CLK, dma: DMA) -> Self 30 pub fn new<DIO, CLK>(
31 common: &mut Common<'d, PIO>,
32 mut sm: StateMachine<'d, PIO, SM>,
33 irq: Irq<'d, PIO, 0>,
34 cs: Output<'d, CS>,
35 dio: DIO,
36 clk: CLK,
37 dma: impl Peripheral<P = DMA> + 'd,
38 ) -> Self
30 where 39 where
31 DIO: Pin, 40 DIO: PioPin,
32 CLK: Pin, 41 CLK: PioPin,
33 { 42 {
43 #[cfg(feature = "overclock")]
34 let program = pio_asm!( 44 let program = pio_asm!(
35 ".side_set 1" 45 ".side_set 1"
36 46
37 ".wrap_target" 47 ".wrap_target"
38 // write out x-1 bits 48 // write out x-1 bits
39 "lp:", 49 "lp:"
40 "out pins, 1 side 0" 50 "out pins, 1 side 0"
41 "jmp x-- lp side 1" 51 "jmp x-- lp side 1"
42 // switch directions 52 // switch directions
43 "set pindirs, 0 side 0" 53 "set pindirs, 0 side 0"
44 // these nops seem to be necessary for fast clkdiv 54 "nop side 1" // necessary for clkdiv=1.
45 "nop side 1"
46 "nop side 0" 55 "nop side 0"
47 "nop side 1"
48 // read in y-1 bits 56 // read in y-1 bits
49 "lp2:" 57 "lp2:"
50 "in pins, 1 side 0" 58 "in pins, 1 side 1"
51 "jmp y-- lp2 side 1" 59 "jmp y-- lp2 side 0"
60
61 // wait for event and irq host
62 "wait 1 pin 0 side 0"
63 "irq 0 side 0"
64
65 ".wrap"
66 );
67 #[cfg(not(feature = "overclock"))]
68 let program = pio_asm!(
69 ".side_set 1"
70
71 ".wrap_target"
72 // write out x-1 bits
73 "lp:"
74 "out pins, 1 side 0"
75 "jmp x-- lp side 1"
76 // switch directions
77 "set pindirs, 0 side 0"
78 "nop side 0"
79 // read in y-1 bits
80 "lp2:"
81 "in pins, 1 side 1"
82 "jmp y-- lp2 side 0"
52 83
53 // wait for event and irq host 84 // wait for event and irq host
54 "wait 1 pin 0 side 0" 85 "wait 1 pin 0 side 0"
@@ -59,68 +90,59 @@ where
59 90
60 let relocated = RelocatedProgram::new(&program.program); 91 let relocated = RelocatedProgram::new(&program.program);
61 92
62 let mut pin_io = sm.make_pio_pin(dio); 93 let mut pin_io: embassy_rp::pio::Pin<PIO> = common.make_pio_pin(dio);
63 pin_io.set_pull(Pull::Down); 94 pin_io.set_pull(Pull::None);
64 pin_io.set_schmitt(true); 95 pin_io.set_schmitt(true);
65 pin_io.set_input_sync_bypass(true); 96 pin_io.set_input_sync_bypass(true);
97 pin_io.set_drive_strength(Drive::_12mA);
98 pin_io.set_slew_rate(SlewRate::Fast);
66 99
67 let mut pin_clk = sm.make_pio_pin(clk); 100 let mut pin_clk = common.make_pio_pin(clk);
68 pin_clk.set_drive_strength(Drive::_12mA); 101 pin_clk.set_drive_strength(Drive::_12mA);
69 pin_clk.set_slew_rate(SlewRate::Fast); 102 pin_clk.set_slew_rate(SlewRate::Fast);
70 103
71 sm.write_instr(relocated.origin() as usize, relocated.code()); 104 let mut cfg = Config::default();
72 105 cfg.use_program(&common.load_program(&relocated), &[&pin_clk]);
73 // theoretical maximum according to data sheet, 100Mhz Pio => 50Mhz SPI Freq 106 cfg.set_out_pins(&[&pin_io]);
74 sm.set_clkdiv(0x0140); 107 cfg.set_in_pins(&[&pin_io]);
75 108 cfg.set_set_pins(&[&pin_io]);
76 // same speed as pico-sdk, 62.5Mhz 109 cfg.shift_out.direction = ShiftDirection::Left;
77 // sm.set_clkdiv(0x0200); 110 cfg.shift_out.auto_fill = true;
78 111 //cfg.shift_out.threshold = 32;
79 // 32 Mhz 112 cfg.shift_in.direction = ShiftDirection::Left;
80 // sm.set_clkdiv(0x03E8); 113 cfg.shift_in.auto_fill = true;
81 114 //cfg.shift_in.threshold = 32;
82 // 16 Mhz 115
83 // sm.set_clkdiv(0x07d0); 116 #[cfg(feature = "overclock")]
84 117 {
85 // 8Mhz 118 // 125mhz Pio => 62.5Mhz SPI Freq. 25% higher than theoretical maximum according to
86 // sm.set_clkdiv(0x0a_00); 119 // data sheet, but seems to work fine.
87 120 cfg.clock_divider = FixedU32::from_bits(0x0100);
88 // 1Mhz 121 }
89 // sm.set_clkdiv(0x7d_00);
90
91 // slowest possible
92 // sm.set_clkdiv(0xffff_00);
93
94 sm.set_autopull(true);
95 // sm.set_pull_threshold(32);
96 sm.set_autopush(true);
97 // sm.set_push_threshold(32);
98
99 sm.set_out_pins(&[&pin_io]);
100 sm.set_in_base_pin(&pin_io);
101
102 sm.set_set_pins(&[&pin_clk]);
103 pio_instr_util::set_pindir(&mut sm, 0b1);
104 sm.set_set_pins(&[&pin_io]);
105 pio_instr_util::set_pindir(&mut sm, 0b1);
106
107 sm.set_sideset_base_pin(&pin_clk);
108 sm.set_sideset_count(1);
109 122
110 sm.set_out_shift_dir(ShiftDirection::Left); 123 #[cfg(not(feature = "overclock"))]
111 sm.set_in_shift_dir(ShiftDirection::Left); 124 {
125 // same speed as pico-sdk, 62.5Mhz
126 // This is actually the fastest we can go without overclocking.
127 // According to data sheet, the theoretical maximum is 100Mhz Pio => 50Mhz SPI Freq.
128 // However, the PIO uses a fractional divider, which works by introducing jitter when
129 // the divider is not an integer. It does some clocks at 125mhz and others at 62.5mhz
130 // so that it averages out to the desired frequency of 100mhz. The 125mhz clock cycles
131 // violate the maximum from the data sheet.
132 cfg.clock_divider = FixedU32::from_bits(0x0200);
133 }
112 134
113 let Wrap { source, target } = relocated.wrap(); 135 sm.set_config(&cfg);
114 sm.set_wrap(source, target);
115 136
116 // pull low for startup 137 sm.set_pin_dirs(Direction::Out, &[&pin_clk, &pin_io]);
117 pio_instr_util::set_pin(&mut sm, 0); 138 sm.set_pins(Level::Low, &[&pin_clk, &pin_io]);
118 139
119 Self { 140 Self {
120 cs, 141 cs,
121 sm, 142 sm,
122 dma, 143 irq,
123 wrap_target: target, 144 dma: dma.into_ref(),
145 wrap_target: relocated.wrap().target,
124 } 146 }
125 } 147 }
126 148
@@ -132,18 +154,22 @@ where
132 #[cfg(feature = "defmt")] 154 #[cfg(feature = "defmt")]
133 defmt::trace!("write={} read={}", write_bits, read_bits); 155 defmt::trace!("write={} read={}", write_bits, read_bits);
134 156
135 let mut dma = Peripheral::into_ref(&mut self.dma); 157 unsafe {
136 pio_instr_util::set_x(&mut self.sm, write_bits as u32); 158 pio_instr_util::set_x(&mut self.sm, write_bits as u32);
137 pio_instr_util::set_y(&mut self.sm, read_bits as u32); 159 pio_instr_util::set_y(&mut self.sm, read_bits as u32);
138 pio_instr_util::set_pindir(&mut self.sm, 0b1); 160 pio_instr_util::set_pindir(&mut self.sm, 0b1);
139 pio_instr_util::exec_jmp(&mut self.sm, self.wrap_target); 161 pio_instr_util::exec_jmp(&mut self.sm, self.wrap_target);
162 }
140 163
141 self.sm.set_enable(true); 164 self.sm.set_enable(true);
142 165
143 self.sm.dma_push(dma.reborrow(), write).await; 166 self.sm.tx().dma_push(self.dma.reborrow(), write).await;
144 167
145 let mut status = 0; 168 let mut status = 0;
146 self.sm.dma_pull(dma.reborrow(), slice::from_mut(&mut status)).await; 169 self.sm
170 .rx()
171 .dma_pull(self.dma.reborrow(), slice::from_mut(&mut status))
172 .await;
147 status 173 status
148 } 174 }
149 175
@@ -155,27 +181,32 @@ where
155 #[cfg(feature = "defmt")] 181 #[cfg(feature = "defmt")]
156 defmt::trace!("write={} read={}", write_bits, read_bits); 182 defmt::trace!("write={} read={}", write_bits, read_bits);
157 183
158 let mut dma = Peripheral::into_ref(&mut self.dma); 184 unsafe {
159 pio_instr_util::set_y(&mut self.sm, read_bits as u32); 185 pio_instr_util::set_y(&mut self.sm, read_bits as u32);
160 pio_instr_util::set_x(&mut self.sm, write_bits as u32); 186 pio_instr_util::set_x(&mut self.sm, write_bits as u32);
161 pio_instr_util::set_pindir(&mut self.sm, 0b1); 187 pio_instr_util::set_pindir(&mut self.sm, 0b1);
162 pio_instr_util::exec_jmp(&mut self.sm, self.wrap_target); 188 pio_instr_util::exec_jmp(&mut self.sm, self.wrap_target);
189 }
190
163 // self.cs.set_low(); 191 // self.cs.set_low();
164 self.sm.set_enable(true); 192 self.sm.set_enable(true);
165 193
166 self.sm.dma_push(dma.reborrow(), slice::from_ref(&cmd)).await; 194 self.sm.tx().dma_push(self.dma.reborrow(), slice::from_ref(&cmd)).await;
167 self.sm.dma_pull(dma.reborrow(), read).await; 195 self.sm.rx().dma_pull(self.dma.reborrow(), read).await;
168 196
169 let mut status = 0; 197 let mut status = 0;
170 self.sm.dma_pull(dma.reborrow(), slice::from_mut(&mut status)).await; 198 self.sm
199 .rx()
200 .dma_pull(self.dma.reborrow(), slice::from_mut(&mut status))
201 .await;
171 status 202 status
172 } 203 }
173} 204}
174 205
175impl<CS, SM, DMA> SpiBusCyw43 for PioSpi<CS, SM, DMA> 206impl<'d, CS, PIO, const SM: usize, DMA> SpiBusCyw43 for PioSpi<'d, CS, PIO, SM, DMA>
176where 207where
177 CS: Pin, 208 CS: Pin,
178 SM: PioStateMachine, 209 PIO: Instance,
179 DMA: Channel, 210 DMA: Channel,
180{ 211{
181 async fn cmd_write(&mut self, write: &[u32]) -> u32 { 212 async fn cmd_write(&mut self, write: &[u32]) -> u32 {
@@ -193,7 +224,6 @@ where
193 } 224 }
194 225
195 async fn wait_for_event(&mut self) { 226 async fn wait_for_event(&mut self) {
196 self.sm.wait_irq(0).await; 227 self.irq.wait().await;
197 self.sm.clear_irq(0);
198 } 228 }
199} 229}
diff --git a/examples/rpi-pico-w/Cargo.toml b/examples/rpi-pico-w/Cargo.toml
index 5b46726d2..525e934f4 100644
--- a/examples/rpi-pico-w/Cargo.toml
+++ b/examples/rpi-pico-w/Cargo.toml
@@ -6,8 +6,8 @@ edition = "2021"
6 6
7[dependencies] 7[dependencies]
8cyw43 = { path = "../../", features = ["defmt", "firmware-logs"] } 8cyw43 = { path = "../../", features = ["defmt", "firmware-logs"] }
9cyw43-pio = { path = "../../cyw43-pio", features = ["defmt"] } 9cyw43-pio = { path = "../../cyw43-pio", features = ["defmt", "overclock"] }
10embassy-executor = { version = "0.1.0", features = ["defmt", "integrated-timers", "executor-thread", "arch-cortex-m"] } 10embassy-executor = { version = "0.2.0", features = ["defmt", "integrated-timers", "executor-thread", "arch-cortex-m"] }
11embassy-time = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] } 11embassy-time = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] }
12embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver"] } 12embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver"] }
13embassy-net = { version = "0.1.0", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "unstable-traits", "nightly"] } 13embassy-net = { version = "0.1.0", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "unstable-traits", "nightly"] }
@@ -27,14 +27,14 @@ heapless = "0.7.15"
27 27
28 28
29[patch.crates-io] 29[patch.crates-io]
30embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 30embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
31embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 31embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
32embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 32embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
33embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 33embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
34embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 34embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
35embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 35embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
36embassy-net-driver = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 36embassy-net-driver = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
37embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" } 37embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "82f7e104d90a6628d1873017ea5ef6a7afb3b3f7" }
38 38
39[profile.dev] 39[profile.dev]
40debug = 2 40debug = 2
@@ -48,7 +48,7 @@ debug = 1
48debug-assertions = false 48debug-assertions = false
49incremental = false 49incremental = false
50lto = 'fat' 50lto = 'fat'
51opt-level = 'z' 51opt-level = 's'
52overflow-checks = false 52overflow-checks = false
53 53
54# do not optimize proc-macro crates = faster builds from scratch 54# do not optimize proc-macro crates = faster builds from scratch
diff --git a/examples/rpi-pico-w/src/bin/tcp_server.rs b/examples/rpi-pico-w/src/bin/tcp_server.rs
index 9581602a7..8accc469f 100644
--- a/examples/rpi-pico-w/src/bin/tcp_server.rs
+++ b/examples/rpi-pico-w/src/bin/tcp_server.rs
@@ -12,8 +12,8 @@ use embassy_executor::Spawner;
12use embassy_net::tcp::TcpSocket; 12use embassy_net::tcp::TcpSocket;
13use embassy_net::{Config, Stack, StackResources}; 13use embassy_net::{Config, Stack, StackResources};
14use embassy_rp::gpio::{Level, Output}; 14use embassy_rp::gpio::{Level, Output};
15use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25}; 15use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
16use embassy_rp::pio::{Pio0, PioPeripheral, PioStateMachineInstance, Sm0}; 16use embassy_rp::pio::Pio;
17use embedded_io::asynch::Write; 17use embedded_io::asynch::Write;
18use static_cell::StaticCell; 18use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _}; 19use {defmt_rtt as _, panic_probe as _};
@@ -28,11 +28,7 @@ macro_rules! singleton {
28 28
29#[embassy_executor::task] 29#[embassy_executor::task]
30async fn wifi_task( 30async fn wifi_task(
31 runner: cyw43::Runner< 31 runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>,
32 'static,
33 Output<'static, PIN_23>,
34 PioSpi<PIN_25, PioStateMachineInstance<Pio0, Sm0>, DMA_CH0>,
35 >,
36) -> ! { 32) -> ! {
37 runner.run().await 33 runner.run().await
38} 34}
@@ -60,10 +56,8 @@ async fn main(spawner: Spawner) {
60 56
61 let pwr = Output::new(p.PIN_23, Level::Low); 57 let pwr = Output::new(p.PIN_23, Level::Low);
62 let cs = Output::new(p.PIN_25, Level::High); 58 let cs = Output::new(p.PIN_25, Level::High);
63 59 let mut pio = Pio::new(p.PIO0);
64 let (_, sm, _, _, _) = p.PIO0.split(); 60 let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
65 let dma = p.DMA_CH0;
66 let spi = PioSpi::new(sm, cs, p.PIN_24, p.PIN_29, dma);
67 61
68 let state = singleton!(cyw43::State::new()); 62 let state = singleton!(cyw43::State::new());
69 let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; 63 let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
diff --git a/examples/rpi-pico-w/src/bin/tcp_server_ap.rs b/examples/rpi-pico-w/src/bin/tcp_server_ap.rs
index e43412625..ee2c32379 100644
--- a/examples/rpi-pico-w/src/bin/tcp_server_ap.rs
+++ b/examples/rpi-pico-w/src/bin/tcp_server_ap.rs
@@ -12,8 +12,8 @@ use embassy_executor::Spawner;
12use embassy_net::tcp::TcpSocket; 12use embassy_net::tcp::TcpSocket;
13use embassy_net::{Config, Stack, StackResources}; 13use embassy_net::{Config, Stack, StackResources};
14use embassy_rp::gpio::{Level, Output}; 14use embassy_rp::gpio::{Level, Output};
15use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25}; 15use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
16use embassy_rp::pio::{Pio0, PioPeripheral, PioStateMachineInstance, Sm0}; 16use embassy_rp::pio::Pio;
17use embedded_io::asynch::Write; 17use embedded_io::asynch::Write;
18use static_cell::StaticCell; 18use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _}; 19use {defmt_rtt as _, panic_probe as _};
@@ -28,11 +28,7 @@ macro_rules! singleton {
28 28
29#[embassy_executor::task] 29#[embassy_executor::task]
30async fn wifi_task( 30async fn wifi_task(
31 runner: cyw43::Runner< 31 runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>,
32 'static,
33 Output<'static, PIN_23>,
34 PioSpi<PIN_25, PioStateMachineInstance<Pio0, Sm0>, DMA_CH0>,
35 >,
36) -> ! { 32) -> ! {
37 runner.run().await 33 runner.run().await
38} 34}
@@ -60,10 +56,8 @@ async fn main(spawner: Spawner) {
60 56
61 let pwr = Output::new(p.PIN_23, Level::Low); 57 let pwr = Output::new(p.PIN_23, Level::Low);
62 let cs = Output::new(p.PIN_25, Level::High); 58 let cs = Output::new(p.PIN_25, Level::High);
63 59 let mut pio = Pio::new(p.PIO0);
64 let (_, sm, _, _, _) = p.PIO0.split(); 60 let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
65 let dma = p.DMA_CH0;
66 let spi = PioSpi::new(sm, cs, p.PIN_24, p.PIN_29, dma);
67 61
68 let state = singleton!(cyw43::State::new()); 62 let state = singleton!(cyw43::State::new());
69 let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; 63 let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
diff --git a/examples/rpi-pico-w/src/bin/wifi_scan.rs b/examples/rpi-pico-w/src/bin/wifi_scan.rs
index da8fadfd8..a2a44f99d 100644
--- a/examples/rpi-pico-w/src/bin/wifi_scan.rs
+++ b/examples/rpi-pico-w/src/bin/wifi_scan.rs
@@ -11,8 +11,8 @@ use defmt::*;
11use embassy_executor::Spawner; 11use embassy_executor::Spawner;
12use embassy_net::Stack; 12use embassy_net::Stack;
13use embassy_rp::gpio::{Level, Output}; 13use embassy_rp::gpio::{Level, Output};
14use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25}; 14use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
15use embassy_rp::pio::{Pio0, PioPeripheral, PioStateMachineInstance, Sm0}; 15use embassy_rp::pio::Pio;
16use static_cell::StaticCell; 16use static_cell::StaticCell;
17use {defmt_rtt as _, panic_probe as _}; 17use {defmt_rtt as _, panic_probe as _};
18 18
@@ -26,11 +26,7 @@ macro_rules! singleton {
26 26
27#[embassy_executor::task] 27#[embassy_executor::task]
28async fn wifi_task( 28async fn wifi_task(
29 runner: cyw43::Runner< 29 runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>,
30 'static,
31 Output<'static, PIN_23>,
32 PioSpi<PIN_25, PioStateMachineInstance<Pio0, Sm0>, DMA_CH0>,
33 >,
34) -> ! { 30) -> ! {
35 runner.run().await 31 runner.run().await
36} 32}
@@ -58,10 +54,8 @@ async fn main(spawner: Spawner) {
58 54
59 let pwr = Output::new(p.PIN_23, Level::Low); 55 let pwr = Output::new(p.PIN_23, Level::Low);
60 let cs = Output::new(p.PIN_25, Level::High); 56 let cs = Output::new(p.PIN_25, Level::High);
61 57 let mut pio = Pio::new(p.PIO0);
62 let (_, sm, _, _, _) = p.PIO0.split(); 58 let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
63 let dma = p.DMA_CH0;
64 let spi = PioSpi::new(sm, cs, p.PIN_24, p.PIN_29, dma);
65 59
66 let state = singleton!(cyw43::State::new()); 60 let state = singleton!(cyw43::State::new());
67 let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; 61 let (_net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;