aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-10-06 22:56:31 +0200
committerDario Nieuwenhuis <[email protected]>2025-10-06 23:19:53 +0200
commit8730a013c395cf0bf4c2fa8eeb7f138288103039 (patch)
tree39eca5fbc4570bd0129c9a291f134de5dab98820 /embassy-rp/src
parentabc8e450f936567ad42cb34b5d2a7941b206aa5d (diff)
Rustfmt for edition 2024.
Diffstat (limited to 'embassy-rp/src')
-rw-r--r--embassy-rp/src/adc.rs8
-rw-r--r--embassy-rp/src/bootsel.rs2
-rw-r--r--embassy-rp/src/clocks.rs4
-rw-r--r--embassy-rp/src/dma.rs4
-rw-r--r--embassy-rp/src/flash.rs4
-rw-r--r--embassy-rp/src/float/cmp.rs12
-rw-r--r--embassy-rp/src/float/functions.rs12
-rw-r--r--embassy-rp/src/gpio.rs6
-rw-r--r--embassy-rp/src/i2c_slave.rs4
-rw-r--r--embassy-rp/src/multicore.rs4
-rw-r--r--embassy-rp/src/pio/mod.rs14
-rw-r--r--embassy-rp/src/pio_programs/hd44780.rs2
-rw-r--r--embassy-rp/src/pio_programs/i2s.rs2
-rw-r--r--embassy-rp/src/pio_programs/onewire.rs8
-rw-r--r--embassy-rp/src/pio_programs/pwm.rs2
-rw-r--r--embassy-rp/src/pio_programs/rotary_encoder.rs2
-rw-r--r--embassy-rp/src/pio_programs/stepper.rs2
-rw-r--r--embassy-rp/src/pio_programs/uart.rs2
-rw-r--r--embassy-rp/src/pio_programs/ws2812.rs2
-rw-r--r--embassy-rp/src/psram.rs2
-rw-r--r--embassy-rp/src/pwm.rs4
-rw-r--r--embassy-rp/src/rtc/mod.rs2
-rw-r--r--embassy-rp/src/time_driver.rs2
-rw-r--r--embassy-rp/src/uart/mod.rs16
-rw-r--r--embassy-rp/src/usb.rs16
-rw-r--r--embassy-rp/src/watchdog.rs2
26 files changed, 50 insertions, 90 deletions
diff --git a/embassy-rp/src/adc.rs b/embassy-rp/src/adc.rs
index 2db8e63d7..d16779e01 100644
--- a/embassy-rp/src/adc.rs
+++ b/embassy-rp/src/adc.rs
@@ -1,18 +1,18 @@
1//! ADC driver. 1//! ADC driver.
2use core::future::{poll_fn, Future}; 2use core::future::{Future, poll_fn};
3use core::marker::PhantomData; 3use core::marker::PhantomData;
4use core::mem; 4use core::mem;
5use core::sync::atomic::{compiler_fence, Ordering}; 5use core::sync::atomic::{Ordering, compiler_fence};
6use core::task::Poll; 6use core::task::Poll;
7 7
8use embassy_sync::waitqueue::AtomicWaker; 8use embassy_sync::waitqueue::AtomicWaker;
9 9
10use crate::gpio::{self, AnyPin, Pull, SealedPin as GpioPin}; 10use crate::gpio::{self, AnyPin, Pull, SealedPin as GpioPin};
11use crate::interrupt::typelevel::Binding;
12use crate::interrupt::InterruptExt; 11use crate::interrupt::InterruptExt;
12use crate::interrupt::typelevel::Binding;
13use crate::pac::dma::vals::TreqSel; 13use crate::pac::dma::vals::TreqSel;
14use crate::peripherals::{ADC, ADC_TEMP_SENSOR}; 14use crate::peripherals::{ADC, ADC_TEMP_SENSOR};
15use crate::{dma, interrupt, pac, peripherals, Peri, RegExt}; 15use crate::{Peri, RegExt, dma, interrupt, pac, peripherals};
16 16
17static WAKER: AtomicWaker = AtomicWaker::new(); 17static WAKER: AtomicWaker = AtomicWaker::new();
18 18
diff --git a/embassy-rp/src/bootsel.rs b/embassy-rp/src/bootsel.rs
index 5f0bac248..b24b98cd5 100644
--- a/embassy-rp/src/bootsel.rs
+++ b/embassy-rp/src/bootsel.rs
@@ -7,8 +7,8 @@
7//! 7//!
8//! This module provides functionality to poll BOOTSEL from an embassy application. 8//! This module provides functionality to poll BOOTSEL from an embassy application.
9 9
10use crate::flash::in_ram;
11use crate::Peri; 10use crate::Peri;
11use crate::flash::in_ram;
12 12
13/// Reads the BOOTSEL button. Returns true if the button is pressed. 13/// Reads the BOOTSEL button. Returns true if the button is pressed.
14/// 14///
diff --git a/embassy-rp/src/clocks.rs b/embassy-rp/src/clocks.rs
index 2eddc0bcc..56892d7a2 100644
--- a/embassy-rp/src/clocks.rs
+++ b/embassy-rp/src/clocks.rs
@@ -72,8 +72,8 @@ use core::sync::atomic::{AtomicU32, Ordering};
72use pac::clocks::vals::*; 72use pac::clocks::vals::*;
73 73
74use crate::gpio::{AnyPin, SealedPin}; 74use crate::gpio::{AnyPin, SealedPin};
75use crate::pac::common::{Reg, RW}; 75use crate::pac::common::{RW, Reg};
76use crate::{pac, reset, Peri}; 76use crate::{Peri, pac, reset};
77 77
78// NOTE: all gpin handling is commented out for future reference. 78// NOTE: all gpin handling is commented out for future reference.
79// gpin is not usually safe to use during the boot init() call, so it won't 79// gpin is not usually safe to use during the boot init() call, so it won't
diff --git a/embassy-rp/src/dma.rs b/embassy-rp/src/dma.rs
index d31d1e159..18aec60a5 100644
--- a/embassy-rp/src/dma.rs
+++ b/embassy-rp/src/dma.rs
@@ -1,10 +1,10 @@
1//! Direct Memory Access (DMA) 1//! Direct Memory Access (DMA)
2use core::future::Future; 2use core::future::Future;
3use core::pin::Pin; 3use core::pin::Pin;
4use core::sync::atomic::{compiler_fence, Ordering}; 4use core::sync::atomic::{Ordering, compiler_fence};
5use core::task::{Context, Poll}; 5use core::task::{Context, Poll};
6 6
7use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; 7use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral};
8use embassy_sync::waitqueue::AtomicWaker; 8use embassy_sync::waitqueue::AtomicWaker;
9use pac::dma::vals::DataSize; 9use pac::dma::vals::DataSize;
10 10
diff --git a/embassy-rp/src/flash.rs b/embassy-rp/src/flash.rs
index 6b5eda0a3..7cc8f0c1d 100644
--- a/embassy-rp/src/flash.rs
+++ b/embassy-rp/src/flash.rs
@@ -6,8 +6,8 @@ use core::task::{Context, Poll};
6 6
7use embassy_hal_internal::{Peri, PeripheralType}; 7use embassy_hal_internal::{Peri, PeripheralType};
8use embedded_storage::nor_flash::{ 8use embedded_storage::nor_flash::{
9 check_erase, check_read, check_write, ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, 9 ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash, check_erase, check_read,
10 ReadNorFlash, 10 check_write,
11}; 11};
12 12
13use crate::dma::{AnyChannel, Channel, Transfer}; 13use crate::dma::{AnyChannel, Channel, Transfer};
diff --git a/embassy-rp/src/float/cmp.rs b/embassy-rp/src/float/cmp.rs
index e540e3918..f917eb9b3 100644
--- a/embassy-rp/src/float/cmp.rs
+++ b/embassy-rp/src/float/cmp.rs
@@ -21,19 +21,11 @@ impl ROMCmp for f64 {
21} 21}
22 22
23fn le_abi<F: Float + ROMCmp>(a: F, b: F) -> i32 { 23fn le_abi<F: Float + ROMCmp>(a: F, b: F) -> i32 {
24 if a.is_nan() || b.is_nan() { 24 if a.is_nan() || b.is_nan() { 1 } else { a.rom_cmp(b) }
25 1
26 } else {
27 a.rom_cmp(b)
28 }
29} 25}
30 26
31fn ge_abi<F: Float + ROMCmp>(a: F, b: F) -> i32 { 27fn ge_abi<F: Float + ROMCmp>(a: F, b: F) -> i32 {
32 if a.is_nan() || b.is_nan() { 28 if a.is_nan() || b.is_nan() { -1 } else { a.rom_cmp(b) }
33 -1
34 } else {
35 a.rom_cmp(b)
36 }
37} 29}
38 30
39intrinsics! { 31intrinsics! {
diff --git a/embassy-rp/src/float/functions.rs b/embassy-rp/src/float/functions.rs
index de29ce336..170168237 100644
--- a/embassy-rp/src/float/functions.rs
+++ b/embassy-rp/src/float/functions.rs
@@ -114,19 +114,11 @@ fn sqrt<F: Float + ROMFunctions>(f: F) -> F {
114} 114}
115 115
116fn ln<F: Float + ROMFunctions>(f: F) -> F { 116fn ln<F: Float + ROMFunctions>(f: F) -> F {
117 if is_negative_nonzero_or_nan(f) { 117 if is_negative_nonzero_or_nan(f) { F::NAN } else { f.ln() }
118 F::NAN
119 } else {
120 f.ln()
121 }
122} 118}
123 119
124fn exp<F: Float + ROMFunctions>(f: F) -> F { 120fn exp<F: Float + ROMFunctions>(f: F) -> F {
125 if f.is_nan() { 121 if f.is_nan() { F::NAN } else { f.exp() }
126 F::NAN
127 } else {
128 f.exp()
129 }
130} 122}
131 123
132fn sin<F: Float + ROMFunctions>(f: F) -> F { 124fn sin<F: Float + ROMFunctions>(f: F) -> F {
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs
index f79bf8948..c15e0e41b 100644
--- a/embassy-rp/src/gpio.rs
+++ b/embassy-rp/src/gpio.rs
@@ -5,13 +5,13 @@ use core::future::Future;
5use core::pin::Pin as FuturePin; 5use core::pin::Pin as FuturePin;
6use core::task::{Context, Poll}; 6use core::task::{Context, Poll};
7 7
8use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; 8use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral};
9use embassy_sync::waitqueue::AtomicWaker; 9use embassy_sync::waitqueue::AtomicWaker;
10 10
11use crate::interrupt::InterruptExt; 11use crate::interrupt::InterruptExt;
12use crate::pac::common::{Reg, RW};
13use crate::pac::SIO; 12use crate::pac::SIO;
14use crate::{interrupt, pac, peripherals, RegExt}; 13use crate::pac::common::{RW, Reg};
14use crate::{RegExt, interrupt, pac, peripherals};
15 15
16#[cfg(any(feature = "rp2040", feature = "rp235xa"))] 16#[cfg(any(feature = "rp2040", feature = "rp235xa"))]
17pub(crate) const BANK0_PIN_COUNT: usize = 30; 17pub(crate) const BANK0_PIN_COUNT: usize = 30;
diff --git a/embassy-rp/src/i2c_slave.rs b/embassy-rp/src/i2c_slave.rs
index c263047ad..770087bc8 100644
--- a/embassy-rp/src/i2c_slave.rs
+++ b/embassy-rp/src/i2c_slave.rs
@@ -5,9 +5,9 @@ use core::task::Poll;
5 5
6use pac::i2c; 6use pac::i2c;
7 7
8use crate::i2c::{set_up_i2c_pin, AbortReason, Instance, InterruptHandler, SclPin, SdaPin, FIFO_SIZE}; 8use crate::i2c::{AbortReason, FIFO_SIZE, Instance, InterruptHandler, SclPin, SdaPin, set_up_i2c_pin};
9use crate::interrupt::typelevel::{Binding, Interrupt}; 9use crate::interrupt::typelevel::{Binding, Interrupt};
10use crate::{pac, Peri}; 10use crate::{Peri, pac};
11 11
12/// I2C error 12/// I2C error
13#[derive(Debug, PartialEq, Eq, Clone, Copy)] 13#[derive(Debug, PartialEq, Eq, Clone, Copy)]
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs
index c305513ca..3b120e349 100644
--- a/embassy-rp/src/multicore.rs
+++ b/embassy-rp/src/multicore.rs
@@ -48,11 +48,11 @@
48//! ``` 48//! ```
49 49
50use core::mem::ManuallyDrop; 50use core::mem::ManuallyDrop;
51use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; 51use core::sync::atomic::{AtomicBool, Ordering, compiler_fence};
52 52
53use crate::interrupt::InterruptExt; 53use crate::interrupt::InterruptExt;
54use crate::peripherals::CORE1; 54use crate::peripherals::CORE1;
55use crate::{gpio, install_stack_guard, interrupt, pac, Peri}; 55use crate::{Peri, gpio, install_stack_guard, interrupt, pac};
56 56
57const PAUSE_TOKEN: u32 = 0xDEADBEEF; 57const PAUSE_TOKEN: u32 = 0xDEADBEEF;
58const RESUME_TOKEN: u32 = !0xDEADBEEF; 58const RESUME_TOKEN: u32 = !0xDEADBEEF;
diff --git a/embassy-rp/src/pio/mod.rs b/embassy-rp/src/pio/mod.rs
index 5f554dfe3..38ee1f97c 100644
--- a/embassy-rp/src/pio/mod.rs
+++ b/embassy-rp/src/pio/mod.rs
@@ -2,21 +2,21 @@
2use core::future::Future; 2use core::future::Future;
3use core::marker::PhantomData; 3use core::marker::PhantomData;
4use core::pin::Pin as FuturePin; 4use core::pin::Pin as FuturePin;
5use core::sync::atomic::{compiler_fence, Ordering}; 5use core::sync::atomic::{Ordering, compiler_fence};
6use core::task::{Context, Poll}; 6use core::task::{Context, Poll};
7 7
8use atomic_polyfill::{AtomicU64, AtomicU8}; 8use atomic_polyfill::{AtomicU8, AtomicU64};
9use embassy_hal_internal::{Peri, PeripheralType}; 9use embassy_hal_internal::{Peri, PeripheralType};
10use embassy_sync::waitqueue::AtomicWaker; 10use embassy_sync::waitqueue::AtomicWaker;
11use fixed::types::extra::U8;
12use fixed::FixedU32; 11use fixed::FixedU32;
12use fixed::types::extra::U8;
13use pio::{Program, SideSet, Wrap}; 13use pio::{Program, SideSet, Wrap};
14 14
15use crate::dma::{self, Channel, Transfer, Word}; 15use crate::dma::{self, Channel, Transfer, Word};
16use crate::gpio::{self, AnyPin, Drive, Level, Pull, SealedPin, SlewRate}; 16use crate::gpio::{self, AnyPin, Drive, Level, Pull, SealedPin, SlewRate};
17use crate::interrupt::typelevel::{Binding, Handler, Interrupt}; 17use crate::interrupt::typelevel::{Binding, Handler, Interrupt};
18use crate::relocate::RelocatedProgram; 18use crate::relocate::RelocatedProgram;
19use crate::{pac, peripherals, RegExt}; 19use crate::{RegExt, pac, peripherals};
20 20
21mod instr; 21mod instr;
22 22
@@ -984,11 +984,7 @@ impl<'d, PIO: Instance + 'd, const SM: usize> StateMachine<'d, PIO, SM> {
984 984
985 #[cfg(feature = "_rp235x")] 985 #[cfg(feature = "_rp235x")]
986 fn pin_base() -> u8 { 986 fn pin_base() -> u8 {
987 if PIO::PIO.gpiobase().read().gpiobase() { 987 if PIO::PIO.gpiobase().read().gpiobase() { 16 } else { 0 }
988 16
989 } else {
990 0
991 }
992 } 988 }
993 989
994 /// Sets pin directions. This pauses the current state machine to run `SET` commands 990 /// Sets pin directions. This pauses the current state machine to run `SET` commands
diff --git a/embassy-rp/src/pio_programs/hd44780.rs b/embassy-rp/src/pio_programs/hd44780.rs
index 546c85a89..78281ddd4 100644
--- a/embassy-rp/src/pio_programs/hd44780.rs
+++ b/embassy-rp/src/pio_programs/hd44780.rs
@@ -1,12 +1,12 @@
1//! [HD44780 display driver](https://www.sparkfun.com/datasheets/LCD/HD44780.pdf) 1//! [HD44780 display driver](https://www.sparkfun.com/datasheets/LCD/HD44780.pdf)
2 2
3use crate::Peri;
3use crate::dma::{AnyChannel, Channel}; 4use crate::dma::{AnyChannel, Channel};
4use crate::pio::{ 5use crate::pio::{
5 Common, Config, Direction, FifoJoin, Instance, Irq, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, 6 Common, Config, Direction, FifoJoin, Instance, Irq, LoadedProgram, PioPin, ShiftConfig, ShiftDirection,
6 StateMachine, 7 StateMachine,
7}; 8};
8use crate::pio_programs::clock_divider::calculate_pio_clock_divider; 9use crate::pio_programs::clock_divider::calculate_pio_clock_divider;
9use crate::Peri;
10 10
11/// This struct represents a HD44780 program that takes command words (<wait:24> <command:4> <0:4>) 11/// This struct represents a HD44780 program that takes command words (<wait:24> <command:4> <0:4>)
12pub struct PioHD44780CommandWordProgram<'a, PIO: Instance> { 12pub struct PioHD44780CommandWordProgram<'a, PIO: Instance> {
diff --git a/embassy-rp/src/pio_programs/i2s.rs b/embassy-rp/src/pio_programs/i2s.rs
index 2382a3f9f..7e5f68ad6 100644
--- a/embassy-rp/src/pio_programs/i2s.rs
+++ b/embassy-rp/src/pio_programs/i2s.rs
@@ -2,12 +2,12 @@
2 2
3use fixed::traits::ToFixed; 3use fixed::traits::ToFixed;
4 4
5use crate::Peri;
5use crate::dma::{AnyChannel, Channel, Transfer}; 6use crate::dma::{AnyChannel, Channel, Transfer};
6use crate::gpio::Pull; 7use crate::gpio::Pull;
7use crate::pio::{ 8use crate::pio::{
8 Common, Config, Direction, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, 9 Common, Config, Direction, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine,
9}; 10};
10use crate::Peri;
11 11
12/// This struct represents an i2s receiver & controller driver program 12/// This struct represents an i2s receiver & controller driver program
13pub struct PioI2sInProgram<'d, PIO: Instance> { 13pub struct PioI2sInProgram<'d, PIO: Instance> {
diff --git a/embassy-rp/src/pio_programs/onewire.rs b/embassy-rp/src/pio_programs/onewire.rs
index 980d0fe5f..09babc229 100644
--- a/embassy-rp/src/pio_programs/onewire.rs
+++ b/embassy-rp/src/pio_programs/onewire.rs
@@ -1,11 +1,11 @@
1//! OneWire pio driver 1//! OneWire pio driver
2 2
3use crate::Peri;
3use crate::clocks::clk_sys_freq; 4use crate::clocks::clk_sys_freq;
4use crate::gpio::Level; 5use crate::gpio::Level;
5use crate::pio::{ 6use crate::pio::{
6 Common, Config, Direction, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, 7 Common, Config, Direction, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine,
7}; 8};
8use crate::Peri;
9 9
10/// This struct represents a onewire driver program 10/// This struct represents a onewire driver program
11pub struct PioOneWireProgram<'a, PIO: Instance> { 11pub struct PioOneWireProgram<'a, PIO: Instance> {
@@ -321,11 +321,7 @@ impl PioOneWireSearch {
321 321
322 /// Search for the next address on the bus 322 /// Search for the next address on the bus
323 pub async fn next<PIO: Instance, const SM: usize>(&mut self, pio: &mut PioOneWire<'_, PIO, SM>) -> Option<u64> { 323 pub async fn next<PIO: Instance, const SM: usize>(&mut self, pio: &mut PioOneWire<'_, PIO, SM>) -> Option<u64> {
324 if self.finished { 324 if self.finished { None } else { pio.search(self).await }
325 None
326 } else {
327 pio.search(self).await
328 }
329 } 325 }
330 326
331 /// Is finished when all devices have been found 327 /// Is finished when all devices have been found
diff --git a/embassy-rp/src/pio_programs/pwm.rs b/embassy-rp/src/pio_programs/pwm.rs
index f0f837bc5..ba06bb3c1 100644
--- a/embassy-rp/src/pio_programs/pwm.rs
+++ b/embassy-rp/src/pio_programs/pwm.rs
@@ -6,7 +6,7 @@ use pio::InstructionOperands;
6 6
7use crate::gpio::Level; 7use crate::gpio::Level;
8use crate::pio::{Common, Config, Direction, Instance, LoadedProgram, Pin, PioPin, StateMachine}; 8use crate::pio::{Common, Config, Direction, Instance, LoadedProgram, Pin, PioPin, StateMachine};
9use crate::{clocks, Peri}; 9use crate::{Peri, clocks};
10 10
11/// This converts the duration provided into the number of cycles the PIO needs to run to make it take the same time 11/// This converts the duration provided into the number of cycles the PIO needs to run to make it take the same time
12fn to_pio_cycles(duration: Duration) -> u32 { 12fn to_pio_cycles(duration: Duration) -> u32 {
diff --git a/embassy-rp/src/pio_programs/rotary_encoder.rs b/embassy-rp/src/pio_programs/rotary_encoder.rs
index 70b3795e9..6347527e6 100644
--- a/embassy-rp/src/pio_programs/rotary_encoder.rs
+++ b/embassy-rp/src/pio_programs/rotary_encoder.rs
@@ -1,11 +1,11 @@
1//! PIO backed quadrature encoder 1//! PIO backed quadrature encoder
2 2
3use crate::Peri;
3use crate::gpio::Pull; 4use crate::gpio::Pull;
4use crate::pio::{ 5use crate::pio::{
5 Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine, 6 Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine,
6}; 7};
7use crate::pio_programs::clock_divider::calculate_pio_clock_divider; 8use crate::pio_programs::clock_divider::calculate_pio_clock_divider;
8use crate::Peri;
9 9
10/// This struct represents an Encoder program loaded into pio instruction memory. 10/// This struct represents an Encoder program loaded into pio instruction memory.
11pub struct PioEncoderProgram<'a, PIO: Instance> { 11pub struct PioEncoderProgram<'a, PIO: Instance> {
diff --git a/embassy-rp/src/pio_programs/stepper.rs b/embassy-rp/src/pio_programs/stepper.rs
index 0e9a8daf9..5762ee189 100644
--- a/embassy-rp/src/pio_programs/stepper.rs
+++ b/embassy-rp/src/pio_programs/stepper.rs
@@ -2,9 +2,9 @@
2 2
3use core::mem::{self, MaybeUninit}; 3use core::mem::{self, MaybeUninit};
4 4
5use crate::Peri;
5use crate::pio::{Common, Config, Direction, Instance, Irq, LoadedProgram, PioPin, StateMachine}; 6use crate::pio::{Common, Config, Direction, Instance, Irq, LoadedProgram, PioPin, StateMachine};
6use crate::pio_programs::clock_divider::calculate_pio_clock_divider; 7use crate::pio_programs::clock_divider::calculate_pio_clock_divider;
7use crate::Peri;
8 8
9/// This struct represents a Stepper driver program loaded into pio instruction memory. 9/// This struct represents a Stepper driver program loaded into pio instruction memory.
10pub struct PioStepperProgram<'a, PIO: Instance> { 10pub struct PioStepperProgram<'a, PIO: Instance> {
diff --git a/embassy-rp/src/pio_programs/uart.rs b/embassy-rp/src/pio_programs/uart.rs
index 04e39a571..444efb5db 100644
--- a/embassy-rp/src/pio_programs/uart.rs
+++ b/embassy-rp/src/pio_programs/uart.rs
@@ -5,12 +5,12 @@ use core::convert::Infallible;
5use embedded_io_async::{ErrorType, Read, Write}; 5use embedded_io_async::{ErrorType, Read, Write};
6use fixed::traits::ToFixed; 6use fixed::traits::ToFixed;
7 7
8use crate::Peri;
8use crate::clocks::clk_sys_freq; 9use crate::clocks::clk_sys_freq;
9use crate::gpio::Level; 10use crate::gpio::Level;
10use crate::pio::{ 11use crate::pio::{
11 Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine, 12 Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine,
12}; 13};
13use crate::Peri;
14 14
15/// This struct represents a uart tx program loaded into pio instruction memory. 15/// This struct represents a uart tx program loaded into pio instruction memory.
16pub struct PioUartTxProgram<'d, PIO: Instance> { 16pub struct PioUartTxProgram<'d, PIO: Instance> {
diff --git a/embassy-rp/src/pio_programs/ws2812.rs b/embassy-rp/src/pio_programs/ws2812.rs
index 37dd1c4e0..e6851b1a6 100644
--- a/embassy-rp/src/pio_programs/ws2812.rs
+++ b/embassy-rp/src/pio_programs/ws2812.rs
@@ -4,12 +4,12 @@ use embassy_time::Timer;
4use fixed::types::U24F8; 4use fixed::types::U24F8;
5use smart_leds::{RGB8, RGBW}; 5use smart_leds::{RGB8, RGBW};
6 6
7use crate::Peri;
7use crate::clocks::clk_sys_freq; 8use crate::clocks::clk_sys_freq;
8use crate::dma::{AnyChannel, Channel}; 9use crate::dma::{AnyChannel, Channel};
9use crate::pio::{ 10use crate::pio::{
10 Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, 11 Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine,
11}; 12};
12use crate::Peri;
13 13
14const T1: u8 = 2; // start bit 14const T1: u8 = 2; // start bit
15const T2: u8 = 5; // data bit 15const T2: u8 = 5; // data bit
diff --git a/embassy-rp/src/psram.rs b/embassy-rp/src/psram.rs
index 22eb1ed25..25185ead2 100644
--- a/embassy-rp/src/psram.rs
+++ b/embassy-rp/src/psram.rs
@@ -10,7 +10,7 @@
10 10
11#![cfg(feature = "_rp235x")] 11#![cfg(feature = "_rp235x")]
12 12
13use critical_section::{acquire, release, CriticalSection, RestoreState}; 13use critical_section::{CriticalSection, RestoreState, acquire, release};
14 14
15use crate::pac; 15use crate::pac;
16use crate::qmi_cs1::QmiCs1; 16use crate::qmi_cs1::QmiCs1;
diff --git a/embassy-rp/src/pwm.rs b/embassy-rp/src/pwm.rs
index 1e1ccc4c6..59a3fc9a2 100644
--- a/embassy-rp/src/pwm.rs
+++ b/embassy-rp/src/pwm.rs
@@ -3,13 +3,13 @@
3use embassy_hal_internal::{Peri, PeripheralType}; 3use embassy_hal_internal::{Peri, PeripheralType};
4pub use embedded_hal_1::pwm::SetDutyCycle; 4pub use embedded_hal_1::pwm::SetDutyCycle;
5use embedded_hal_1::pwm::{Error, ErrorKind, ErrorType}; 5use embedded_hal_1::pwm::{Error, ErrorKind, ErrorType};
6use fixed::traits::ToFixed;
7use fixed::FixedU16; 6use fixed::FixedU16;
7use fixed::traits::ToFixed;
8use pac::pwm::regs::{ChDiv, Intr}; 8use pac::pwm::regs::{ChDiv, Intr};
9use pac::pwm::vals::Divmode; 9use pac::pwm::vals::Divmode;
10 10
11use crate::gpio::{AnyPin, Pin as GpioPin, Pull, SealedPin as _}; 11use crate::gpio::{AnyPin, Pin as GpioPin, Pull, SealedPin as _};
12use crate::{pac, peripherals, RegExt}; 12use crate::{RegExt, pac, peripherals};
13 13
14/// The configuration of a PWM slice. 14/// The configuration of a PWM slice.
15/// Note the period in clock cycles of a slice can be computed as: 15/// Note the period in clock cycles of a slice can be computed as:
diff --git a/embassy-rp/src/rtc/mod.rs b/embassy-rp/src/rtc/mod.rs
index 8b0deed21..68fb3b765 100644
--- a/embassy-rp/src/rtc/mod.rs
+++ b/embassy-rp/src/rtc/mod.rs
@@ -2,7 +2,7 @@
2mod filter; 2mod filter;
3 3
4use core::future::poll_fn; 4use core::future::poll_fn;
5use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; 5use core::sync::atomic::{AtomicBool, Ordering, compiler_fence};
6use core::task::Poll; 6use core::task::Poll;
7 7
8use embassy_hal_internal::{Peri, PeripheralType}; 8use embassy_hal_internal::{Peri, PeripheralType};
diff --git a/embassy-rp/src/time_driver.rs b/embassy-rp/src/time_driver.rs
index d598287a9..ec1c17ed5 100644
--- a/embassy-rp/src/time_driver.rs
+++ b/embassy-rp/src/time_driver.rs
@@ -2,8 +2,8 @@
2use core::cell::{Cell, RefCell}; 2use core::cell::{Cell, RefCell};
3 3
4use critical_section::CriticalSection; 4use critical_section::CriticalSection;
5use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
6use embassy_sync::blocking_mutex::Mutex; 5use embassy_sync::blocking_mutex::Mutex;
6use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
7use embassy_time_driver::Driver; 7use embassy_time_driver::Driver;
8use embassy_time_queue_utils::Queue; 8use embassy_time_queue_utils::Queue;
9#[cfg(feature = "rp2040")] 9#[cfg(feature = "rp2040")]
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs
index 6f4e2ee07..43187df2d 100644
--- a/embassy-rp/src/uart/mod.rs
+++ b/embassy-rp/src/uart/mod.rs
@@ -4,7 +4,7 @@ use core::marker::PhantomData;
4use core::task::Poll; 4use core::task::Poll;
5 5
6use atomic_polyfill::{AtomicU16, Ordering}; 6use atomic_polyfill::{AtomicU16, Ordering};
7use embassy_futures::select::{select, Either}; 7use embassy_futures::select::{Either, select};
8use embassy_hal_internal::{Peri, PeripheralType}; 8use embassy_hal_internal::{Peri, PeripheralType};
9use embassy_sync::waitqueue::AtomicWaker; 9use embassy_sync::waitqueue::AtomicWaker;
10use embassy_time::{Delay, Timer}; 10use embassy_time::{Delay, Timer};
@@ -16,7 +16,7 @@ use crate::gpio::{AnyPin, SealedPin};
16use crate::interrupt::typelevel::{Binding, Interrupt as _}; 16use crate::interrupt::typelevel::{Binding, Interrupt as _};
17use crate::interrupt::{Interrupt, InterruptExt}; 17use crate::interrupt::{Interrupt, InterruptExt};
18use crate::pac::io::vals::{Inover, Outover}; 18use crate::pac::io::vals::{Inover, Outover};
19use crate::{interrupt, pac, peripherals, RegExt}; 19use crate::{RegExt, interrupt, pac, peripherals};
20 20
21mod buffered; 21mod buffered;
22pub use buffered::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, BufferedUartTx}; 22pub use buffered::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, BufferedUartTx};
@@ -863,11 +863,7 @@ impl<'d, M: Mode> Uart<'d, M> {
863 if let Some(pin) = &tx { 863 if let Some(pin) = &tx {
864 let funcsel = { 864 let funcsel = {
865 let pin_number = ((pin.gpio().as_ptr() as u32) & 0x1FF) / 8; 865 let pin_number = ((pin.gpio().as_ptr() as u32) & 0x1FF) / 8;
866 if (pin_number % 4) == 0 { 866 if (pin_number % 4) == 0 { 2 } else { 11 }
867 2
868 } else {
869 11
870 }
871 }; 867 };
872 pin.gpio().ctrl().write(|w| { 868 pin.gpio().ctrl().write(|w| {
873 w.set_funcsel(funcsel); 869 w.set_funcsel(funcsel);
@@ -886,11 +882,7 @@ impl<'d, M: Mode> Uart<'d, M> {
886 if let Some(pin) = &rx { 882 if let Some(pin) = &rx {
887 let funcsel = { 883 let funcsel = {
888 let pin_number = ((pin.gpio().as_ptr() as u32) & 0x1FF) / 8; 884 let pin_number = ((pin.gpio().as_ptr() as u32) & 0x1FF) / 8;
889 if ((pin_number - 1) % 4) == 0 { 885 if ((pin_number - 1) % 4) == 0 { 2 } else { 11 }
890 2
891 } else {
892 11
893 }
894 }; 886 };
895 pin.gpio().ctrl().write(|w| { 887 pin.gpio().ctrl().write(|w| {
896 w.set_funcsel(funcsel); 888 w.set_funcsel(funcsel);
diff --git a/embassy-rp/src/usb.rs b/embassy-rp/src/usb.rs
index 671ecbd32..e8273c3f2 100644
--- a/embassy-rp/src/usb.rs
+++ b/embassy-rp/src/usb.rs
@@ -2,7 +2,7 @@
2use core::future::poll_fn; 2use core::future::poll_fn;
3use core::marker::PhantomData; 3use core::marker::PhantomData;
4use core::slice; 4use core::slice;
5use core::sync::atomic::{compiler_fence, Ordering}; 5use core::sync::atomic::{Ordering, compiler_fence};
6use core::task::Poll; 6use core::task::Poll;
7 7
8use embassy_hal_internal::PeripheralType; 8use embassy_hal_internal::PeripheralType;
@@ -13,7 +13,7 @@ use embassy_usb_driver::{
13}; 13};
14 14
15use crate::interrupt::typelevel::{Binding, Interrupt}; 15use crate::interrupt::typelevel::{Binding, Interrupt};
16use crate::{interrupt, pac, peripherals, Peri, RegExt}; 16use crate::{Peri, RegExt, interrupt, pac, peripherals};
17 17
18trait SealedInstance { 18trait SealedInstance {
19 fn regs() -> crate::pac::usb::Usb; 19 fn regs() -> crate::pac::usb::Usb;
@@ -545,11 +545,7 @@ impl<'d, T: Instance> driver::Endpoint for Endpoint<'d, T, In> {
545 poll_fn(|cx| { 545 poll_fn(|cx| {
546 EP_IN_WAKERS[index].register(cx.waker()); 546 EP_IN_WAKERS[index].register(cx.waker());
547 let val = T::dpram().ep_in_control(self.info.addr.index() - 1).read(); 547 let val = T::dpram().ep_in_control(self.info.addr.index() - 1).read();
548 if val.enable() { 548 if val.enable() { Poll::Ready(()) } else { Poll::Pending }
549 Poll::Ready(())
550 } else {
551 Poll::Pending
552 }
553 }) 549 })
554 .await; 550 .await;
555 trace!("wait_enabled IN OK"); 551 trace!("wait_enabled IN OK");
@@ -567,11 +563,7 @@ impl<'d, T: Instance> driver::Endpoint for Endpoint<'d, T, Out> {
567 poll_fn(|cx| { 563 poll_fn(|cx| {
568 EP_OUT_WAKERS[index].register(cx.waker()); 564 EP_OUT_WAKERS[index].register(cx.waker());
569 let val = T::dpram().ep_out_control(self.info.addr.index() - 1).read(); 565 let val = T::dpram().ep_out_control(self.info.addr.index() - 1).read();
570 if val.enable() { 566 if val.enable() { Poll::Ready(()) } else { Poll::Pending }
571 Poll::Ready(())
572 } else {
573 Poll::Pending
574 }
575 }) 567 })
576 .await; 568 .await;
577 trace!("wait_enabled OUT OK"); 569 trace!("wait_enabled OUT OK");
diff --git a/embassy-rp/src/watchdog.rs b/embassy-rp/src/watchdog.rs
index 49cf03850..d42601745 100644
--- a/embassy-rp/src/watchdog.rs
+++ b/embassy-rp/src/watchdog.rs
@@ -11,7 +11,7 @@ use core::marker::PhantomData;
11use embassy_time::Duration; 11use embassy_time::Duration;
12 12
13use crate::peripherals::WATCHDOG; 13use crate::peripherals::WATCHDOG;
14use crate::{pac, Peri}; 14use crate::{Peri, pac};
15 15
16/// The reason for a system reset from the watchdog. 16/// The reason for a system reset from the watchdog.
17#[derive(Debug, Copy, Clone, PartialEq, Eq)] 17#[derive(Debug, Copy, Clone, PartialEq, Eq)]