aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-rp/src/pio.rs271
-rw-r--r--embassy-rp/src/pio_instr_util.rs20
-rw-r--r--examples/rp/src/bin/pio_async.rs2
-rw-r--r--examples/rp/src/bin/pio_dma.rs2
-rw-r--r--examples/rp/src/bin/pio_hd44780.rs2
-rw-r--r--examples/rp/src/bin/ws2812-pio.rs4
6 files changed, 138 insertions, 163 deletions
diff --git a/embassy-rp/src/pio.rs b/embassy-rp/src/pio.rs
index a2e3d3a91..52ef89a16 100644
--- a/embassy-rp/src/pio.rs
+++ b/embassy-rp/src/pio.rs
@@ -14,7 +14,6 @@ use crate::dma::{Channel, Transfer, Word};
14use crate::gpio::sealed::Pin as SealedPin; 14use crate::gpio::sealed::Pin as SealedPin;
15use crate::gpio::{self, AnyPin, Drive, Pull, SlewRate}; 15use crate::gpio::{self, AnyPin, Drive, Pull, SlewRate};
16use crate::pac::dma::vals::TreqSel; 16use crate::pac::dma::vals::TreqSel;
17use crate::pio::sealed::PioInstance as _;
18use crate::{interrupt, pac, peripherals, RegExt}; 17use crate::{interrupt, pac, peripherals, RegExt};
19 18
20struct Wakers([AtomicWaker; 12]); 19struct Wakers([AtomicWaker; 12]);
@@ -97,23 +96,18 @@ pub(crate) unsafe fn init() {
97 96
98/// Future that waits for TX-FIFO to become writable 97/// Future that waits for TX-FIFO to become writable
99#[must_use = "futures do nothing unless you `.await` or poll them"] 98#[must_use = "futures do nothing unless you `.await` or poll them"]
100pub struct FifoOutFuture<'a, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> { 99pub struct FifoOutFuture<'a, 'd, PIO: PioInstance, const SM: usize> {
101 sm: &'a mut SM, 100 sm: &'a mut PioStateMachine<'d, PIO, SM>,
102 pio: PhantomData<PIO>,
103 value: u32, 101 value: u32,
104} 102}
105 103
106impl<'a, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> FifoOutFuture<'a, PIO, SM> { 104impl<'a, 'd, PIO: PioInstance, const SM: usize> FifoOutFuture<'a, 'd, PIO, SM> {
107 pub fn new(sm: &'a mut SM, value: u32) -> Self { 105 pub fn new(sm: &'a mut PioStateMachine<'d, PIO, SM>, value: u32) -> Self {
108 FifoOutFuture { 106 FifoOutFuture { sm, value }
109 sm,
110 pio: PhantomData::default(),
111 value,
112 }
113 } 107 }
114} 108}
115 109
116impl<'d, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> Future for FifoOutFuture<'d, PIO, SM> { 110impl<'a, 'd, PIO: PioInstance, const SM: usize> Future for FifoOutFuture<'a, 'd, PIO, SM> {
117 type Output = (); 111 type Output = ();
118 fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { 112 fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
119 //debug!("Poll {},{}", PIO::PIO_NO, SM); 113 //debug!("Poll {},{}", PIO::PIO_NO, SM);
@@ -121,10 +115,10 @@ impl<'d, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> Future for FifoO
121 if self.get_mut().sm.try_push_tx(value) { 115 if self.get_mut().sm.try_push_tx(value) {
122 Poll::Ready(()) 116 Poll::Ready(())
123 } else { 117 } else {
124 WAKERS[PIO::PIO_NO as usize].fifo_out()[SM::SM as usize].register(cx.waker()); 118 WAKERS[PIO::PIO_NO as usize].fifo_out()[SM].register(cx.waker());
125 unsafe { 119 unsafe {
126 PIO::PIO.irqs(0).inte().write_set(|m| { 120 PIO::PIO.irqs(0).inte().write_set(|m| {
127 m.0 = TXNFULL_MASK << SM::SM; 121 m.0 = TXNFULL_MASK << SM;
128 }); 122 });
129 } 123 }
130 // debug!("Pending"); 124 // debug!("Pending");
@@ -133,11 +127,11 @@ impl<'d, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> Future for FifoO
133 } 127 }
134} 128}
135 129
136impl<'d, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> Drop for FifoOutFuture<'d, PIO, SM> { 130impl<'a, 'd, PIO: PioInstance, const SM: usize> Drop for FifoOutFuture<'a, 'd, PIO, SM> {
137 fn drop(&mut self) { 131 fn drop(&mut self) {
138 unsafe { 132 unsafe {
139 PIO::PIO.irqs(0).inte().write_clear(|m| { 133 PIO::PIO.irqs(0).inte().write_clear(|m| {
140 m.0 = TXNFULL_MASK << SM::SM; 134 m.0 = TXNFULL_MASK << SM;
141 }); 135 });
142 } 136 }
143 } 137 }
@@ -145,31 +139,27 @@ impl<'d, PIO: PioInstance, SM: PioStateMachineInstance + Unpin> Drop for FifoOut
145 139
146/// Future that waits for RX-FIFO to become readable 140/// Future that waits for RX-FIFO to become readable
147#[must_use = "futures do nothing unless you `.await` or poll them"] 141#[must_use = "futures do nothing unless you `.await` or poll them"]
148pub struct FifoInFuture<'a, PIO: PioInstance, SM: PioStateMachineInstance> { 142pub struct FifoInFuture<'a, 'd, PIO: PioInstance, const SM: usize> {
149 sm: &'a mut SM, 143 sm: &'a mut PioStateMachine<'d, PIO, SM>,
150 pio: PhantomData<PIO>,
151} 144}
152 145
153impl<'a, PIO: PioInstance, SM: PioStateMachineInstance> FifoInFuture<'a, PIO, SM> { 146impl<'a, 'd, PIO: PioInstance, const SM: usize> FifoInFuture<'a, 'd, PIO, SM> {
154 pub fn new(sm: &'a mut SM) -> Self { 147 pub fn new(sm: &'a mut PioStateMachine<'d, PIO, SM>) -> Self {
155 FifoInFuture { 148 FifoInFuture { sm }
156 sm,
157 pio: PhantomData::default(),
158 }
159 } 149 }
160} 150}
161 151
162impl<'d, PIO: PioInstance, SM: PioStateMachineInstance> Future for FifoInFuture<'d, PIO, SM> { 152impl<'a, 'd, PIO: PioInstance, const SM: usize> Future for FifoInFuture<'a, 'd, PIO, SM> {
163 type Output = u32; 153 type Output = u32;
164 fn poll(mut self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { 154 fn poll(mut self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
165 //debug!("Poll {},{}", PIO::PIO_NO, SM); 155 //debug!("Poll {},{}", PIO::PIO_NO, SM);
166 if let Some(v) = self.sm.try_pull_rx() { 156 if let Some(v) = self.sm.try_pull_rx() {
167 Poll::Ready(v) 157 Poll::Ready(v)
168 } else { 158 } else {
169 WAKERS[PIO::PIO_NO as usize].fifo_in()[SM::SM].register(cx.waker()); 159 WAKERS[PIO::PIO_NO as usize].fifo_in()[SM].register(cx.waker());
170 unsafe { 160 unsafe {
171 PIO::PIO.irqs(0).inte().write_set(|m| { 161 PIO::PIO.irqs(0).inte().write_set(|m| {
172 m.0 = RXNEMPTY_MASK << SM::SM; 162 m.0 = RXNEMPTY_MASK << SM;
173 }); 163 });
174 } 164 }
175 //debug!("Pending"); 165 //debug!("Pending");
@@ -178,11 +168,11 @@ impl<'d, PIO: PioInstance, SM: PioStateMachineInstance> Future for FifoInFuture<
178 } 168 }
179} 169}
180 170
181impl<'d, PIO: PioInstance, SM: PioStateMachineInstance> Drop for FifoInFuture<'d, PIO, SM> { 171impl<'a, 'd, PIO: PioInstance, const SM: usize> Drop for FifoInFuture<'a, 'd, PIO, SM> {
182 fn drop(&mut self) { 172 fn drop(&mut self) {
183 unsafe { 173 unsafe {
184 PIO::PIO.irqs(0).inte().write_clear(|m| { 174 PIO::PIO.irqs(0).inte().write_clear(|m| {
185 m.0 = RXNEMPTY_MASK << SM::SM; 175 m.0 = RXNEMPTY_MASK << SM;
186 }); 176 });
187 } 177 }
188 } 178 }
@@ -325,69 +315,68 @@ impl<'d, PIO: PioInstance, const SM: usize> Drop for PioStateMachine<'d, PIO, SM
325 } 315 }
326} 316}
327 317
328impl<'d, PIO: PioInstance, const SM: usize> sealed::PioStateMachineInstance for PioStateMachine<'d, PIO, SM> { 318impl<'d, PIO: PioInstance + 'd, const SM: usize> PioStateMachine<'d, PIO, SM> {
329 type Pio = PIO; 319 #[inline(always)]
330 const SM: usize = SM; 320 fn this_sm() -> crate::pac::pio::StateMachine {
331} 321 PIO::PIO.sm(SM)
332impl<'d, PIO: PioInstance, const SM: usize> PioStateMachineInstance for PioStateMachine<'d, PIO, SM> {} 322 }
333 323
334pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unpin { 324 pub fn restart(&mut self) {
335 fn restart(&mut self) { 325 let mask = 1u8 << SM;
336 let mask = 1u8 << Self::SM;
337 unsafe { 326 unsafe {
338 Self::Pio::PIO.ctrl().write_set(|w| w.set_sm_restart(mask)); 327 PIO::PIO.ctrl().write_set(|w| w.set_sm_restart(mask));
339 } 328 }
340 } 329 }
341 fn set_enable(&mut self, enable: bool) { 330 pub fn set_enable(&mut self, enable: bool) {
342 let mask = 1u8 << Self::SM; 331 let mask = 1u8 << SM;
343 unsafe { 332 unsafe {
344 if enable { 333 if enable {
345 Self::Pio::PIO.ctrl().write_set(|w| w.set_sm_enable(mask)); 334 PIO::PIO.ctrl().write_set(|w| w.set_sm_enable(mask));
346 } else { 335 } else {
347 Self::Pio::PIO.ctrl().write_clear(|w| w.set_sm_enable(mask)); 336 PIO::PIO.ctrl().write_clear(|w| w.set_sm_enable(mask));
348 } 337 }
349 } 338 }
350 } 339 }
351 340
352 fn is_enabled(&self) -> bool { 341 pub fn is_enabled(&self) -> bool {
353 unsafe { Self::Pio::PIO.ctrl().read().sm_enable() & (1u8 << Self::SM) != 0 } 342 unsafe { PIO::PIO.ctrl().read().sm_enable() & (1u8 << SM) != 0 }
354 } 343 }
355 344
356 fn is_tx_empty(&self) -> bool { 345 pub fn is_tx_empty(&self) -> bool {
357 unsafe { Self::Pio::PIO.fstat().read().txempty() & (1u8 << Self::SM) != 0 } 346 unsafe { PIO::PIO.fstat().read().txempty() & (1u8 << SM) != 0 }
358 } 347 }
359 fn is_tx_full(&self) -> bool { 348 pub fn is_tx_full(&self) -> bool {
360 unsafe { Self::Pio::PIO.fstat().read().txfull() & (1u8 << Self::SM) != 0 } 349 unsafe { PIO::PIO.fstat().read().txfull() & (1u8 << SM) != 0 }
361 } 350 }
362 351
363 fn is_rx_empty(&self) -> bool { 352 pub fn is_rx_empty(&self) -> bool {
364 unsafe { Self::Pio::PIO.fstat().read().rxempty() & (1u8 << Self::SM) != 0 } 353 unsafe { PIO::PIO.fstat().read().rxempty() & (1u8 << SM) != 0 }
365 } 354 }
366 fn is_rx_full(&self) -> bool { 355 pub fn is_rx_full(&self) -> bool {
367 unsafe { Self::Pio::PIO.fstat().read().rxfull() & (1u8 << Self::SM) != 0 } 356 unsafe { PIO::PIO.fstat().read().rxfull() & (1u8 << SM) != 0 }
368 } 357 }
369 358
370 fn tx_level(&self) -> u8 { 359 pub fn tx_level(&self) -> u8 {
371 unsafe { 360 unsafe {
372 let flevel = Self::Pio::PIO.flevel().read().0; 361 let flevel = PIO::PIO.flevel().read().0;
373 (flevel >> (Self::SM * 8)) as u8 & 0x0f 362 (flevel >> (SM * 8)) as u8 & 0x0f
374 } 363 }
375 } 364 }
376 365
377 fn rx_level(&self) -> u8 { 366 pub fn rx_level(&self) -> u8 {
378 unsafe { 367 unsafe {
379 let flevel = Self::Pio::PIO.flevel().read().0; 368 let flevel = PIO::PIO.flevel().read().0;
380 (flevel >> (Self::SM * 8 + 4)) as u8 & 0x0f 369 (flevel >> (SM * 8 + 4)) as u8 & 0x0f
381 } 370 }
382 } 371 }
383 372
384 fn push_tx(&mut self, v: u32) { 373 pub fn push_tx(&mut self, v: u32) {
385 unsafe { 374 unsafe {
386 Self::Pio::PIO.txf(Self::SM).write_value(v); 375 PIO::PIO.txf(SM).write_value(v);
387 } 376 }
388 } 377 }
389 378
390 fn try_push_tx(&mut self, v: u32) -> bool { 379 pub fn try_push_tx(&mut self, v: u32) -> bool {
391 if self.is_tx_full() { 380 if self.is_tx_full() {
392 return false; 381 return false;
393 } 382 }
@@ -395,65 +384,65 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
395 true 384 true
396 } 385 }
397 386
398 fn pull_rx(&mut self) -> u32 { 387 pub fn pull_rx(&mut self) -> u32 {
399 unsafe { Self::Pio::PIO.rxf(Self::SM).read() } 388 unsafe { PIO::PIO.rxf(SM).read() }
400 } 389 }
401 390
402 fn try_pull_rx(&mut self) -> Option<u32> { 391 pub fn try_pull_rx(&mut self) -> Option<u32> {
403 if self.is_rx_empty() { 392 if self.is_rx_empty() {
404 return None; 393 return None;
405 } 394 }
406 Some(self.pull_rx()) 395 Some(self.pull_rx())
407 } 396 }
408 397
409 fn set_clkdiv(&mut self, div_x_256: u32) { 398 pub fn set_clkdiv(&mut self, div_x_256: u32) {
410 unsafe { 399 unsafe {
411 Self::this_sm().clkdiv().write(|w| w.0 = div_x_256 << 8); 400 Self::this_sm().clkdiv().write(|w| w.0 = div_x_256 << 8);
412 } 401 }
413 } 402 }
414 403
415 fn get_clkdiv(&self) -> u32 { 404 pub fn get_clkdiv(&self) -> u32 {
416 unsafe { Self::this_sm().clkdiv().read().0 >> 8 } 405 unsafe { Self::this_sm().clkdiv().read().0 >> 8 }
417 } 406 }
418 407
419 fn clkdiv_restart(&mut self) { 408 pub fn clkdiv_restart(&mut self) {
420 let mask = 1u8 << Self::SM; 409 let mask = 1u8 << SM;
421 unsafe { 410 unsafe {
422 Self::Pio::PIO.ctrl().write_set(|w| w.set_clkdiv_restart(mask)); 411 PIO::PIO.ctrl().write_set(|w| w.set_clkdiv_restart(mask));
423 } 412 }
424 } 413 }
425 414
426 fn set_side_enable(&self, enable: bool) { 415 pub fn set_side_enable(&self, enable: bool) {
427 unsafe { 416 unsafe {
428 Self::this_sm().execctrl().modify(|w| w.set_side_en(enable)); 417 Self::this_sm().execctrl().modify(|w| w.set_side_en(enable));
429 } 418 }
430 } 419 }
431 420
432 fn is_side_enabled(&self) -> bool { 421 pub fn is_side_enabled(&self) -> bool {
433 unsafe { Self::this_sm().execctrl().read().side_en() } 422 unsafe { Self::this_sm().execctrl().read().side_en() }
434 } 423 }
435 424
436 fn set_side_pindir(&mut self, pindir: bool) { 425 pub fn set_side_pindir(&mut self, pindir: bool) {
437 unsafe { 426 unsafe {
438 Self::this_sm().execctrl().modify(|w| w.set_side_pindir(pindir)); 427 Self::this_sm().execctrl().modify(|w| w.set_side_pindir(pindir));
439 } 428 }
440 } 429 }
441 430
442 fn is_side_pindir(&self) -> bool { 431 pub fn is_side_pindir(&self) -> bool {
443 unsafe { Self::this_sm().execctrl().read().side_pindir() } 432 unsafe { Self::this_sm().execctrl().read().side_pindir() }
444 } 433 }
445 434
446 fn set_jmp_pin(&mut self, pin: u8) { 435 pub fn set_jmp_pin(&mut self, pin: u8) {
447 unsafe { 436 unsafe {
448 Self::this_sm().execctrl().modify(|w| w.set_jmp_pin(pin)); 437 Self::this_sm().execctrl().modify(|w| w.set_jmp_pin(pin));
449 } 438 }
450 } 439 }
451 440
452 fn get_jmp_pin(&mut self) -> u8 { 441 pub fn get_jmp_pin(&mut self) -> u8 {
453 unsafe { Self::this_sm().execctrl().read().jmp_pin() } 442 unsafe { Self::this_sm().execctrl().read().jmp_pin() }
454 } 443 }
455 444
456 fn set_wrap(&self, source: u8, target: u8) { 445 pub fn set_wrap(&self, source: u8, target: u8) {
457 unsafe { 446 unsafe {
458 Self::this_sm().execctrl().modify(|w| { 447 Self::this_sm().execctrl().modify(|w| {
459 w.set_wrap_top(source); 448 w.set_wrap_top(source);
@@ -463,14 +452,14 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
463 } 452 }
464 453
465 /// Get wrapping addresses. Returns (source, target). 454 /// Get wrapping addresses. Returns (source, target).
466 fn get_wrap(&self) -> (u8, u8) { 455 pub fn get_wrap(&self) -> (u8, u8) {
467 unsafe { 456 unsafe {
468 let r = Self::this_sm().execctrl().read(); 457 let r = Self::this_sm().execctrl().read();
469 (r.wrap_top(), r.wrap_bottom()) 458 (r.wrap_top(), r.wrap_bottom())
470 } 459 }
471 } 460 }
472 461
473 fn set_fifo_join(&mut self, join: FifoJoin) { 462 pub fn set_fifo_join(&mut self, join: FifoJoin) {
474 let (rx, tx) = match join { 463 let (rx, tx) = match join {
475 FifoJoin::Duplex => (false, false), 464 FifoJoin::Duplex => (false, false),
476 FifoJoin::RxOnly => (true, false), 465 FifoJoin::RxOnly => (true, false),
@@ -483,7 +472,7 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
483 }); 472 });
484 } 473 }
485 } 474 }
486 fn get_fifo_join(&self) -> FifoJoin { 475 pub fn get_fifo_join(&self) -> FifoJoin {
487 unsafe { 476 unsafe {
488 let r = Self::this_sm().shiftctrl().read(); 477 let r = Self::this_sm().shiftctrl().read();
489 // Ignores the invalid state when both bits are set 478 // Ignores the invalid state when both bits are set
@@ -497,7 +486,7 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
497 } 486 }
498 } 487 }
499 488
500 fn clear_fifos(&mut self) { 489 pub fn clear_fifos(&mut self) {
501 // Toggle FJOIN_RX to flush FIFOs 490 // Toggle FJOIN_RX to flush FIFOs
502 unsafe { 491 unsafe {
503 let shiftctrl = Self::this_sm().shiftctrl(); 492 let shiftctrl = Self::this_sm().shiftctrl();
@@ -510,33 +499,33 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
510 } 499 }
511 } 500 }
512 501
513 fn set_pull_threshold(&mut self, threshold: u8) { 502 pub fn set_pull_threshold(&mut self, threshold: u8) {
514 unsafe { 503 unsafe {
515 Self::this_sm().shiftctrl().modify(|w| w.set_pull_thresh(threshold)); 504 Self::this_sm().shiftctrl().modify(|w| w.set_pull_thresh(threshold));
516 } 505 }
517 } 506 }
518 507
519 fn get_pull_threshold(&self) -> u8 { 508 pub fn get_pull_threshold(&self) -> u8 {
520 unsafe { Self::this_sm().shiftctrl().read().pull_thresh() } 509 unsafe { Self::this_sm().shiftctrl().read().pull_thresh() }
521 } 510 }
522 fn set_push_threshold(&mut self, threshold: u8) { 511 pub fn set_push_threshold(&mut self, threshold: u8) {
523 unsafe { 512 unsafe {
524 Self::this_sm().shiftctrl().modify(|w| w.set_push_thresh(threshold)); 513 Self::this_sm().shiftctrl().modify(|w| w.set_push_thresh(threshold));
525 } 514 }
526 } 515 }
527 516
528 fn get_push_threshold(&self) -> u8 { 517 pub fn get_push_threshold(&self) -> u8 {
529 unsafe { Self::this_sm().shiftctrl().read().push_thresh() } 518 unsafe { Self::this_sm().shiftctrl().read().push_thresh() }
530 } 519 }
531 520
532 fn set_out_shift_dir(&mut self, dir: ShiftDirection) { 521 pub fn set_out_shift_dir(&mut self, dir: ShiftDirection) {
533 unsafe { 522 unsafe {
534 Self::this_sm() 523 Self::this_sm()
535 .shiftctrl() 524 .shiftctrl()
536 .modify(|w| w.set_out_shiftdir(dir == ShiftDirection::Right)); 525 .modify(|w| w.set_out_shiftdir(dir == ShiftDirection::Right));
537 } 526 }
538 } 527 }
539 fn get_out_shiftdir(&self) -> ShiftDirection { 528 pub fn get_out_shiftdir(&self) -> ShiftDirection {
540 unsafe { 529 unsafe {
541 if Self::this_sm().shiftctrl().read().out_shiftdir() { 530 if Self::this_sm().shiftctrl().read().out_shiftdir() {
542 ShiftDirection::Right 531 ShiftDirection::Right
@@ -546,14 +535,14 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
546 } 535 }
547 } 536 }
548 537
549 fn set_in_shift_dir(&mut self, dir: ShiftDirection) { 538 pub fn set_in_shift_dir(&mut self, dir: ShiftDirection) {
550 unsafe { 539 unsafe {
551 Self::this_sm() 540 Self::this_sm()
552 .shiftctrl() 541 .shiftctrl()
553 .modify(|w| w.set_in_shiftdir(dir == ShiftDirection::Right)); 542 .modify(|w| w.set_in_shiftdir(dir == ShiftDirection::Right));
554 } 543 }
555 } 544 }
556 fn get_in_shiftdir(&self) -> ShiftDirection { 545 pub fn get_in_shiftdir(&self) -> ShiftDirection {
557 unsafe { 546 unsafe {
558 if Self::this_sm().shiftctrl().read().in_shiftdir() { 547 if Self::this_sm().shiftctrl().read().in_shiftdir() {
559 ShiftDirection::Right 548 ShiftDirection::Right
@@ -563,46 +552,46 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
563 } 552 }
564 } 553 }
565 554
566 fn set_autopull(&mut self, auto: bool) { 555 pub fn set_autopull(&mut self, auto: bool) {
567 unsafe { 556 unsafe {
568 Self::this_sm().shiftctrl().modify(|w| w.set_autopull(auto)); 557 Self::this_sm().shiftctrl().modify(|w| w.set_autopull(auto));
569 } 558 }
570 } 559 }
571 560
572 fn is_autopull(&self) -> bool { 561 pub fn is_autopull(&self) -> bool {
573 unsafe { Self::this_sm().shiftctrl().read().autopull() } 562 unsafe { Self::this_sm().shiftctrl().read().autopull() }
574 } 563 }
575 564
576 fn set_autopush(&mut self, auto: bool) { 565 pub fn set_autopush(&mut self, auto: bool) {
577 unsafe { 566 unsafe {
578 Self::this_sm().shiftctrl().modify(|w| w.set_autopush(auto)); 567 Self::this_sm().shiftctrl().modify(|w| w.set_autopush(auto));
579 } 568 }
580 } 569 }
581 570
582 fn is_autopush(&self) -> bool { 571 pub fn is_autopush(&self) -> bool {
583 unsafe { Self::this_sm().shiftctrl().read().autopush() } 572 unsafe { Self::this_sm().shiftctrl().read().autopush() }
584 } 573 }
585 574
586 fn get_addr(&self) -> u8 { 575 pub fn get_addr(&self) -> u8 {
587 unsafe { Self::this_sm().addr().read().addr() } 576 unsafe { Self::this_sm().addr().read().addr() }
588 } 577 }
589 fn set_sideset_count(&mut self, count: u8) { 578 pub fn set_sideset_count(&mut self, count: u8) {
590 unsafe { 579 unsafe {
591 Self::this_sm().pinctrl().modify(|w| w.set_sideset_count(count)); 580 Self::this_sm().pinctrl().modify(|w| w.set_sideset_count(count));
592 } 581 }
593 } 582 }
594 583
595 fn get_sideset_count(&self) -> u8 { 584 pub fn get_sideset_count(&self) -> u8 {
596 unsafe { Self::this_sm().pinctrl().read().sideset_count() } 585 unsafe { Self::this_sm().pinctrl().read().sideset_count() }
597 } 586 }
598 587
599 fn set_sideset_base_pin(&mut self, base_pin: &Pin<Self::Pio>) { 588 pub fn set_sideset_base_pin(&mut self, base_pin: &Pin<PIO>) {
600 unsafe { 589 unsafe {
601 Self::this_sm().pinctrl().modify(|w| w.set_sideset_base(base_pin.pin())); 590 Self::this_sm().pinctrl().modify(|w| w.set_sideset_base(base_pin.pin()));
602 } 591 }
603 } 592 }
604 593
605 fn get_sideset_base(&self) -> u8 { 594 pub fn get_sideset_base(&self) -> u8 {
606 unsafe { 595 unsafe {
607 let r = Self::this_sm().pinctrl().read(); 596 let r = Self::this_sm().pinctrl().read();
608 r.sideset_base() 597 r.sideset_base()
@@ -610,7 +599,7 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
610 } 599 }
611 600
612 /// Set the range of out pins affected by a set instruction. 601 /// Set the range of out pins affected by a set instruction.
613 fn set_set_range(&mut self, base: u8, count: u8) { 602 pub fn set_set_range(&mut self, base: u8, count: u8) {
614 assert!(base + count < 32); 603 assert!(base + count < 32);
615 unsafe { 604 unsafe {
616 Self::this_sm().pinctrl().modify(|w| { 605 Self::this_sm().pinctrl().modify(|w| {
@@ -621,27 +610,27 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
621 } 610 }
622 611
623 /// Get the range of out pins affected by a set instruction. Returns (base, count). 612 /// Get the range of out pins affected by a set instruction. Returns (base, count).
624 fn get_set_range(&self) -> (u8, u8) { 613 pub fn get_set_range(&self) -> (u8, u8) {
625 unsafe { 614 unsafe {
626 let r = Self::this_sm().pinctrl().read(); 615 let r = Self::this_sm().pinctrl().read();
627 (r.set_base(), r.set_count()) 616 (r.set_base(), r.set_count())
628 } 617 }
629 } 618 }
630 619
631 fn set_in_base_pin(&mut self, base: &Pin<Self::Pio>) { 620 pub fn set_in_base_pin(&mut self, base: &Pin<PIO>) {
632 unsafe { 621 unsafe {
633 Self::this_sm().pinctrl().modify(|w| w.set_in_base(base.pin())); 622 Self::this_sm().pinctrl().modify(|w| w.set_in_base(base.pin()));
634 } 623 }
635 } 624 }
636 625
637 fn get_in_base(&self) -> u8 { 626 pub fn get_in_base(&self) -> u8 {
638 unsafe { 627 unsafe {
639 let r = Self::this_sm().pinctrl().read(); 628 let r = Self::this_sm().pinctrl().read();
640 r.in_base() 629 r.in_base()
641 } 630 }
642 } 631 }
643 632
644 fn set_out_range(&mut self, base: u8, count: u8) { 633 pub fn set_out_range(&mut self, base: u8, count: u8) {
645 assert!(base + count < 32); 634 assert!(base + count < 32);
646 unsafe { 635 unsafe {
647 Self::this_sm().pinctrl().modify(|w| { 636 Self::this_sm().pinctrl().modify(|w| {
@@ -652,14 +641,14 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
652 } 641 }
653 642
654 /// Get the range of out pins affected by a set instruction. Returns (base, count). 643 /// Get the range of out pins affected by a set instruction. Returns (base, count).
655 fn get_out_range(&self) -> (u8, u8) { 644 pub fn get_out_range(&self) -> (u8, u8) {
656 unsafe { 645 unsafe {
657 let r = Self::this_sm().pinctrl().read(); 646 let r = Self::this_sm().pinctrl().read();
658 (r.out_base(), r.out_count()) 647 (r.out_base(), r.out_count())
659 } 648 }
660 } 649 }
661 650
662 fn set_out_pins<'a, 'b: 'a>(&'a mut self, pins: &'b [&Pin<Self::Pio>]) { 651 pub fn set_out_pins<'a, 'b: 'a>(&'a mut self, pins: &'b [&Pin<PIO>]) {
663 let count = pins.len(); 652 let count = pins.len();
664 assert!(count >= 1); 653 assert!(count >= 1);
665 let start = pins[0].pin() as usize; 654 let start = pins[0].pin() as usize;
@@ -670,7 +659,7 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
670 self.set_out_range(start as u8, count as u8); 659 self.set_out_range(start as u8, count as u8);
671 } 660 }
672 661
673 fn set_set_pins<'a, 'b: 'a>(&'a mut self, pins: &'b [&Pin<Self::Pio>]) { 662 pub fn set_set_pins<'a, 'b: 'a>(&'a mut self, pins: &'b [&Pin<PIO>]) {
674 let count = pins.len(); 663 let count = pins.len();
675 assert!(count >= 1); 664 assert!(count >= 1);
676 let start = pins[0].pin() as usize; 665 let start = pins[0].pin() as usize;
@@ -681,76 +670,75 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
681 self.set_set_range(start as u8, count as u8); 670 self.set_set_range(start as u8, count as u8);
682 } 671 }
683 672
684 fn get_current_instr() -> u32 { 673 pub fn get_current_instr() -> u32 {
685 unsafe { Self::this_sm().instr().read().0 } 674 unsafe { Self::this_sm().instr().read().0 }
686 } 675 }
687 676
688 fn exec_instr(&mut self, instr: u16) { 677 pub fn exec_instr(&mut self, instr: u16) {
689 unsafe { 678 unsafe {
690 Self::this_sm().instr().write(|w| w.set_instr(instr)); 679 Self::this_sm().instr().write(|w| w.set_instr(instr));
691 } 680 }
692 } 681 }
693 682
694 fn wait_push<'a>(&'a mut self, value: u32) -> FifoOutFuture<'a, Self::Pio, Self> { 683 pub fn wait_push<'a>(&'a mut self, value: u32) -> FifoOutFuture<'a, 'd, PIO, SM> {
695 FifoOutFuture::new(self, value) 684 FifoOutFuture::new(self, value)
696 } 685 }
697 686
698 fn wait_pull<'a>(&'a mut self) -> FifoInFuture<'a, Self::Pio, Self> { 687 pub fn wait_pull<'a>(&'a mut self) -> FifoInFuture<'a, 'd, PIO, SM> {
699 FifoInFuture::new(self) 688 FifoInFuture::new(self)
700 } 689 }
701 690
702 fn wait_irq(&self, irq_no: u8) -> IrqFuture<Self::Pio> { 691 pub fn wait_irq(&self, irq_no: u8) -> IrqFuture<PIO> {
703 IrqFuture::new(irq_no) 692 IrqFuture::new(irq_no)
704 } 693 }
705 694
706 fn has_tx_stalled(&self) -> bool { 695 pub fn has_tx_stalled(&self) -> bool {
707 unsafe { 696 unsafe {
708 let fdebug = Self::Pio::PIO.fdebug(); 697 let fdebug = PIO::PIO.fdebug();
709 let ret = fdebug.read().txstall() & (1 << Self::SM) != 0; 698 let ret = fdebug.read().txstall() & (1 << SM) != 0;
710 fdebug.write(|w| w.set_txstall(1 << Self::SM)); 699 fdebug.write(|w| w.set_txstall(1 << SM));
711 ret 700 ret
712 } 701 }
713 } 702 }
714 703
715 fn has_tx_overflowed(&self) -> bool { 704 pub fn has_tx_overflowed(&self) -> bool {
716 unsafe { 705 unsafe {
717 let fdebug = Self::Pio::PIO.fdebug(); 706 let fdebug = PIO::PIO.fdebug();
718 let ret = fdebug.read().txover() & (1 << Self::SM) != 0; 707 let ret = fdebug.read().txover() & (1 << SM) != 0;
719 fdebug.write(|w| w.set_txover(1 << Self::SM)); 708 fdebug.write(|w| w.set_txover(1 << SM));
720 ret 709 ret
721 } 710 }
722 } 711 }
723 712
724 fn has_rx_stalled(&self) -> bool { 713 pub fn has_rx_stalled(&self) -> bool {
725 unsafe { 714 unsafe {
726 let fdebug = Self::Pio::PIO.fdebug(); 715 let fdebug = PIO::PIO.fdebug();
727 let ret = fdebug.read().rxstall() & (1 << Self::SM) != 0; 716 let ret = fdebug.read().rxstall() & (1 << SM) != 0;
728 fdebug.write(|w| w.set_rxstall(1 << Self::SM)); 717 fdebug.write(|w| w.set_rxstall(1 << SM));
729 ret 718 ret
730 } 719 }
731 } 720 }
732 721
733 fn has_rx_underflowed(&self) -> bool { 722 pub fn has_rx_underflowed(&self) -> bool {
734 unsafe { 723 unsafe {
735 let fdebug = Self::Pio::PIO.fdebug(); 724 let fdebug = PIO::PIO.fdebug();
736 let ret = fdebug.read().rxunder() & (1 << Self::SM) != 0; 725 let ret = fdebug.read().rxunder() & (1 << SM) != 0;
737 fdebug.write(|w| w.set_rxunder(1 << Self::SM)); 726 fdebug.write(|w| w.set_rxunder(1 << SM));
738 ret 727 ret
739 } 728 }
740 } 729 }
741 730
742 fn dma_push<'a, C: Channel, W: Word>(&'a self, ch: PeripheralRef<'a, C>, data: &'a [W]) -> Transfer<'a, C> { 731 pub fn dma_push<'a, C: Channel, W: Word>(&'a self, ch: PeripheralRef<'a, C>, data: &'a [W]) -> Transfer<'a, C> {
743 unsafe { 732 unsafe {
744 let pio_no = Self::Pio::PIO_NO; 733 let pio_no = PIO::PIO_NO;
745 let sm_no = Self::SM;
746 let p = ch.regs(); 734 let p = ch.regs();
747 p.read_addr().write_value(data.as_ptr() as u32); 735 p.read_addr().write_value(data.as_ptr() as u32);
748 p.write_addr().write_value(Self::Pio::PIO.txf(sm_no).ptr() as u32); 736 p.write_addr().write_value(PIO::PIO.txf(SM).ptr() as u32);
749 p.trans_count().write_value(data.len() as u32); 737 p.trans_count().write_value(data.len() as u32);
750 compiler_fence(Ordering::SeqCst); 738 compiler_fence(Ordering::SeqCst);
751 p.ctrl_trig().write(|w| { 739 p.ctrl_trig().write(|w| {
752 // Set TX DREQ for this statemachine 740 // Set TX DREQ for this statemachine
753 w.set_treq_sel(TreqSel(pio_no * 8 + sm_no as u8)); 741 w.set_treq_sel(TreqSel(pio_no * 8 + SM as u8));
754 w.set_data_size(W::size()); 742 w.set_data_size(W::size());
755 w.set_chain_to(ch.number()); 743 w.set_chain_to(ch.number());
756 w.set_incr_read(true); 744 w.set_incr_read(true);
@@ -762,18 +750,17 @@ pub trait PioStateMachineInstance: sealed::PioStateMachineInstance + Sized + Unp
762 Transfer::new(ch) 750 Transfer::new(ch)
763 } 751 }
764 752
765 fn dma_pull<'a, C: Channel, W: Word>(&'a self, ch: PeripheralRef<'a, C>, data: &'a mut [W]) -> Transfer<'a, C> { 753 pub fn dma_pull<'a, C: Channel, W: Word>(&'a self, ch: PeripheralRef<'a, C>, data: &'a mut [W]) -> Transfer<'a, C> {
766 unsafe { 754 unsafe {
767 let pio_no = Self::Pio::PIO_NO; 755 let pio_no = PIO::PIO_NO;
768 let sm_no = Self::SM;
769 let p = ch.regs(); 756 let p = ch.regs();
770 p.write_addr().write_value(data.as_ptr() as u32); 757 p.write_addr().write_value(data.as_ptr() as u32);
771 p.read_addr().write_value(Self::Pio::PIO.rxf(sm_no).ptr() as u32); 758 p.read_addr().write_value(PIO::PIO.rxf(SM).ptr() as u32);
772 p.trans_count().write_value(data.len() as u32); 759 p.trans_count().write_value(data.len() as u32);
773 compiler_fence(Ordering::SeqCst); 760 compiler_fence(Ordering::SeqCst);
774 p.ctrl_trig().write(|w| { 761 p.ctrl_trig().write(|w| {
775 // Set RX DREQ for this statemachine 762 // Set RX DREQ for this statemachine
776 w.set_treq_sel(TreqSel(pio_no * 8 + sm_no as u8 + 4)); 763 w.set_treq_sel(TreqSel(pio_no * 8 + SM as u8 + 4));
777 w.set_data_size(W::size()); 764 w.set_data_size(W::size());
778 w.set_chain_to(ch.number()); 765 w.set_chain_to(ch.number());
779 w.set_incr_read(false); 766 w.set_incr_read(false);
@@ -944,16 +931,6 @@ fn on_pio_drop<PIO: PioInstance>() {
944mod sealed { 931mod sealed {
945 use super::*; 932 use super::*;
946 933
947 pub trait PioStateMachineInstance {
948 type Pio: super::PioInstance;
949 const SM: usize;
950
951 #[inline(always)]
952 fn this_sm() -> crate::pac::pio::StateMachine {
953 Self::Pio::PIO.sm(Self::SM as usize)
954 }
955 }
956
957 pub trait PioPin {} 934 pub trait PioPin {}
958 935
959 pub trait PioInstance { 936 pub trait PioInstance {
diff --git a/embassy-rp/src/pio_instr_util.rs b/embassy-rp/src/pio_instr_util.rs
index f5e7d7abd..ffe160246 100644
--- a/embassy-rp/src/pio_instr_util.rs
+++ b/embassy-rp/src/pio_instr_util.rs
@@ -1,8 +1,8 @@
1use pio::{InSource, InstructionOperands, JmpCondition, OutDestination, SetDestination}; 1use pio::{InSource, InstructionOperands, JmpCondition, OutDestination, SetDestination};
2 2
3use crate::pio::PioStateMachineInstance; 3use crate::pio::{PioInstance, PioStateMachine};
4 4
5pub fn set_x<SM: PioStateMachineInstance>(sm: &mut SM, value: u32) { 5pub fn set_x<PIO: PioInstance, const SM: usize>(sm: &mut PioStateMachine<PIO, SM>, value: u32) {
6 const OUT: u16 = InstructionOperands::OUT { 6 const OUT: u16 = InstructionOperands::OUT {
7 destination: OutDestination::X, 7 destination: OutDestination::X,
8 bit_count: 32, 8 bit_count: 32,
@@ -12,7 +12,7 @@ pub fn set_x<SM: PioStateMachineInstance>(sm: &mut SM, value: u32) {
12 sm.exec_instr(OUT); 12 sm.exec_instr(OUT);
13} 13}
14 14
15pub fn get_x<SM: PioStateMachineInstance>(sm: &mut SM) -> u32 { 15pub fn get_x<PIO: PioInstance, const SM: usize>(sm: &mut PioStateMachine<PIO, SM>) -> u32 {
16 const IN: u16 = InstructionOperands::IN { 16 const IN: u16 = InstructionOperands::IN {
17 source: InSource::X, 17 source: InSource::X,
18 bit_count: 32, 18 bit_count: 32,
@@ -22,7 +22,7 @@ pub fn get_x<SM: PioStateMachineInstance>(sm: &mut SM) -> u32 {
22 sm.pull_rx() 22 sm.pull_rx()
23} 23}
24 24
25pub fn set_y<SM: PioStateMachineInstance>(sm: &mut SM, value: u32) { 25pub fn set_y<PIO: PioInstance, const SM: usize>(sm: &mut PioStateMachine<PIO, SM>, value: u32) {
26 const OUT: u16 = InstructionOperands::OUT { 26 const OUT: u16 = InstructionOperands::OUT {
27 destination: OutDestination::Y, 27 destination: OutDestination::Y,
28 bit_count: 32, 28 bit_count: 32,
@@ -32,7 +32,7 @@ pub fn set_y<SM: PioStateMachineInstance>(sm: &mut SM, value: u32) {
32 sm.exec_instr(OUT); 32 sm.exec_instr(OUT);
33} 33}
34 34
35pub fn get_y<SM: PioStateMachineInstance>(sm: &mut SM) -> u32 { 35pub fn get_y<PIO: PioInstance, const SM: usize>(sm: &mut PioStateMachine<PIO, SM>) -> u32 {
36 const IN: u16 = InstructionOperands::IN { 36 const IN: u16 = InstructionOperands::IN {
37 source: InSource::Y, 37 source: InSource::Y,
38 bit_count: 32, 38 bit_count: 32,
@@ -43,7 +43,7 @@ pub fn get_y<SM: PioStateMachineInstance>(sm: &mut SM) -> u32 {
43 sm.pull_rx() 43 sm.pull_rx()
44} 44}
45 45
46pub fn set_pindir<SM: PioStateMachineInstance>(sm: &mut SM, data: u8) { 46pub fn set_pindir<PIO: PioInstance, const SM: usize>(sm: &mut PioStateMachine<PIO, SM>, data: u8) {
47 let set: u16 = InstructionOperands::SET { 47 let set: u16 = InstructionOperands::SET {
48 destination: SetDestination::PINDIRS, 48 destination: SetDestination::PINDIRS,
49 data, 49 data,
@@ -52,7 +52,7 @@ pub fn set_pindir<SM: PioStateMachineInstance>(sm: &mut SM, data: u8) {
52 sm.exec_instr(set); 52 sm.exec_instr(set);
53} 53}
54 54
55pub fn set_pin<SM: PioStateMachineInstance>(sm: &mut SM, data: u8) { 55pub fn set_pin<PIO: PioInstance, const SM: usize>(sm: &mut PioStateMachine<PIO, SM>, data: u8) {
56 let set: u16 = InstructionOperands::SET { 56 let set: u16 = InstructionOperands::SET {
57 destination: SetDestination::PINS, 57 destination: SetDestination::PINS,
58 data, 58 data,
@@ -61,7 +61,7 @@ pub fn set_pin<SM: PioStateMachineInstance>(sm: &mut SM, data: u8) {
61 sm.exec_instr(set); 61 sm.exec_instr(set);
62} 62}
63 63
64pub fn set_out_pin<SM: PioStateMachineInstance>(sm: &mut SM, data: u32) { 64pub fn set_out_pin<PIO: PioInstance, const SM: usize>(sm: &mut PioStateMachine<PIO, SM>, data: u32) {
65 const OUT: u16 = InstructionOperands::OUT { 65 const OUT: u16 = InstructionOperands::OUT {
66 destination: OutDestination::PINS, 66 destination: OutDestination::PINS,
67 bit_count: 32, 67 bit_count: 32,
@@ -70,7 +70,7 @@ pub fn set_out_pin<SM: PioStateMachineInstance>(sm: &mut SM, data: u32) {
70 sm.push_tx(data); 70 sm.push_tx(data);
71 sm.exec_instr(OUT); 71 sm.exec_instr(OUT);
72} 72}
73pub fn set_out_pindir<SM: PioStateMachineInstance>(sm: &mut SM, data: u32) { 73pub fn set_out_pindir<PIO: PioInstance, const SM: usize>(sm: &mut PioStateMachine<PIO, SM>, data: u32) {
74 const OUT: u16 = InstructionOperands::OUT { 74 const OUT: u16 = InstructionOperands::OUT {
75 destination: OutDestination::PINDIRS, 75 destination: OutDestination::PINDIRS,
76 bit_count: 32, 76 bit_count: 32,
@@ -80,7 +80,7 @@ pub fn set_out_pindir<SM: PioStateMachineInstance>(sm: &mut SM, data: u32) {
80 sm.exec_instr(OUT); 80 sm.exec_instr(OUT);
81} 81}
82 82
83pub fn exec_jmp<SM: PioStateMachineInstance>(sm: &mut SM, to_addr: u8) { 83pub fn exec_jmp<PIO: PioInstance, const SM: usize>(sm: &mut PioStateMachine<PIO, SM>, to_addr: u8) {
84 let jmp: u16 = InstructionOperands::JMP { 84 let jmp: u16 = InstructionOperands::JMP {
85 address: to_addr, 85 address: to_addr,
86 condition: JmpCondition::Always, 86 condition: JmpCondition::Always,
diff --git a/examples/rp/src/bin/pio_async.rs b/examples/rp/src/bin/pio_async.rs
index 8c02f9f16..11b290869 100644
--- a/examples/rp/src/bin/pio_async.rs
+++ b/examples/rp/src/bin/pio_async.rs
@@ -4,7 +4,7 @@
4use defmt::info; 4use defmt::info;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_rp::peripherals::PIO0; 6use embassy_rp::peripherals::PIO0;
7use embassy_rp::pio::{Pio, PioCommon, PioPin, PioStateMachine, PioStateMachineInstance, ShiftDirection}; 7use embassy_rp::pio::{Pio, PioCommon, PioPin, PioStateMachine, ShiftDirection};
8use embassy_rp::pio_instr_util; 8use embassy_rp::pio_instr_util;
9use embassy_rp::relocate::RelocatedProgram; 9use embassy_rp::relocate::RelocatedProgram;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
diff --git a/examples/rp/src/bin/pio_dma.rs b/examples/rp/src/bin/pio_dma.rs
index a351e2c7c..a2a2ee39a 100644
--- a/examples/rp/src/bin/pio_dma.rs
+++ b/examples/rp/src/bin/pio_dma.rs
@@ -4,7 +4,7 @@
4use defmt::info; 4use defmt::info;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_futures::join::join; 6use embassy_futures::join::join;
7use embassy_rp::pio::{Pio, PioStateMachineInstance, ShiftDirection}; 7use embassy_rp::pio::{Pio, ShiftDirection};
8use embassy_rp::relocate::RelocatedProgram; 8use embassy_rp::relocate::RelocatedProgram;
9use embassy_rp::{pio_instr_util, Peripheral}; 9use embassy_rp::{pio_instr_util, Peripheral};
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
diff --git a/examples/rp/src/bin/pio_hd44780.rs b/examples/rp/src/bin/pio_hd44780.rs
index 249711a32..bc51d43c4 100644
--- a/examples/rp/src/bin/pio_hd44780.rs
+++ b/examples/rp/src/bin/pio_hd44780.rs
@@ -7,7 +7,7 @@ use core::fmt::Write;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_rp::dma::{AnyChannel, Channel}; 8use embassy_rp::dma::{AnyChannel, Channel};
9use embassy_rp::peripherals::PIO0; 9use embassy_rp::peripherals::PIO0;
10use embassy_rp::pio::{FifoJoin, Pio, PioPin, PioStateMachine, PioStateMachineInstance, ShiftDirection}; 10use embassy_rp::pio::{FifoJoin, Pio, PioPin, PioStateMachine, ShiftDirection};
11use embassy_rp::pwm::{Config, Pwm}; 11use embassy_rp::pwm::{Config, Pwm};
12use embassy_rp::relocate::RelocatedProgram; 12use embassy_rp::relocate::RelocatedProgram;
13use embassy_rp::{into_ref, Peripheral, PeripheralRef}; 13use embassy_rp::{into_ref, Peripheral, PeripheralRef};
diff --git a/examples/rp/src/bin/ws2812-pio.rs b/examples/rp/src/bin/ws2812-pio.rs
index c141560e5..713e01b44 100644
--- a/examples/rp/src/bin/ws2812-pio.rs
+++ b/examples/rp/src/bin/ws2812-pio.rs
@@ -4,9 +4,7 @@
4 4
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_rp::pio::{ 7use embassy_rp::pio::{FifoJoin, Pio, PioCommon, PioInstance, PioPin, PioStateMachine, ShiftDirection};
8 FifoJoin, Pio, PioCommon, PioInstance, PioPin, PioStateMachine, PioStateMachineInstance, ShiftDirection,
9};
10use embassy_rp::pio_instr_util; 8use embassy_rp::pio_instr_util;
11use embassy_rp::relocate::RelocatedProgram; 9use embassy_rp::relocate::RelocatedProgram;
12use embassy_time::{Duration, Timer}; 10use embassy_time::{Duration, Timer};