diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-10-06 22:56:31 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-10-06 23:19:53 +0200 |
| commit | 8730a013c395cf0bf4c2fa8eeb7f138288103039 (patch) | |
| tree | 39eca5fbc4570bd0129c9a291f134de5dab98820 /embassy-rp/src | |
| parent | abc8e450f936567ad42cb34b5d2a7941b206aa5d (diff) | |
Rustfmt for edition 2024.
Diffstat (limited to 'embassy-rp/src')
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. |
| 2 | use core::future::{poll_fn, Future}; | 2 | use core::future::{Future, poll_fn}; |
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | use core::mem; | 4 | use core::mem; |
| 5 | use core::sync::atomic::{compiler_fence, Ordering}; | 5 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | 9 | ||
| 10 | use crate::gpio::{self, AnyPin, Pull, SealedPin as GpioPin}; | 10 | use crate::gpio::{self, AnyPin, Pull, SealedPin as GpioPin}; |
| 11 | use crate::interrupt::typelevel::Binding; | ||
| 12 | use crate::interrupt::InterruptExt; | 11 | use crate::interrupt::InterruptExt; |
| 12 | use crate::interrupt::typelevel::Binding; | ||
| 13 | use crate::pac::dma::vals::TreqSel; | 13 | use crate::pac::dma::vals::TreqSel; |
| 14 | use crate::peripherals::{ADC, ADC_TEMP_SENSOR}; | 14 | use crate::peripherals::{ADC, ADC_TEMP_SENSOR}; |
| 15 | use crate::{dma, interrupt, pac, peripherals, Peri, RegExt}; | 15 | use crate::{Peri, RegExt, dma, interrupt, pac, peripherals}; |
| 16 | 16 | ||
| 17 | static WAKER: AtomicWaker = AtomicWaker::new(); | 17 | static 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 | ||
| 10 | use crate::flash::in_ram; | ||
| 11 | use crate::Peri; | 10 | use crate::Peri; |
| 11 | use 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}; | |||
| 72 | use pac::clocks::vals::*; | 72 | use pac::clocks::vals::*; |
| 73 | 73 | ||
| 74 | use crate::gpio::{AnyPin, SealedPin}; | 74 | use crate::gpio::{AnyPin, SealedPin}; |
| 75 | use crate::pac::common::{Reg, RW}; | 75 | use crate::pac::common::{RW, Reg}; |
| 76 | use crate::{pac, reset, Peri}; | 76 | use 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) |
| 2 | use core::future::Future; | 2 | use core::future::Future; |
| 3 | use core::pin::Pin; | 3 | use core::pin::Pin; |
| 4 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 5 | use core::task::{Context, Poll}; | 5 | use core::task::{Context, Poll}; |
| 6 | 6 | ||
| 7 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 7 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use pac::dma::vals::DataSize; | 9 | use 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 | ||
| 7 | use embassy_hal_internal::{Peri, PeripheralType}; | 7 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 8 | use embedded_storage::nor_flash::{ | 8 | use 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 | ||
| 13 | use crate::dma::{AnyChannel, Channel, Transfer}; | 13 | use 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 | ||
| 23 | fn le_abi<F: Float + ROMCmp>(a: F, b: F) -> i32 { | 23 | fn 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 | ||
| 31 | fn ge_abi<F: Float + ROMCmp>(a: F, b: F) -> i32 { | 27 | fn 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 | ||
| 39 | intrinsics! { | 31 | intrinsics! { |
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 | ||
| 116 | fn ln<F: Float + ROMFunctions>(f: F) -> F { | 116 | fn 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 | ||
| 124 | fn exp<F: Float + ROMFunctions>(f: F) -> F { | 120 | fn 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 | ||
| 132 | fn sin<F: Float + ROMFunctions>(f: F) -> F { | 124 | fn 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; | |||
| 5 | use core::pin::Pin as FuturePin; | 5 | use core::pin::Pin as FuturePin; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::interrupt::InterruptExt; | 11 | use crate::interrupt::InterruptExt; |
| 12 | use crate::pac::common::{Reg, RW}; | ||
| 13 | use crate::pac::SIO; | 12 | use crate::pac::SIO; |
| 14 | use crate::{interrupt, pac, peripherals, RegExt}; | 13 | use crate::pac::common::{RW, Reg}; |
| 14 | use crate::{RegExt, interrupt, pac, peripherals}; | ||
| 15 | 15 | ||
| 16 | #[cfg(any(feature = "rp2040", feature = "rp235xa"))] | 16 | #[cfg(any(feature = "rp2040", feature = "rp235xa"))] |
| 17 | pub(crate) const BANK0_PIN_COUNT: usize = 30; | 17 | pub(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 | ||
| 6 | use pac::i2c; | 6 | use pac::i2c; |
| 7 | 7 | ||
| 8 | use crate::i2c::{set_up_i2c_pin, AbortReason, Instance, InterruptHandler, SclPin, SdaPin, FIFO_SIZE}; | 8 | use crate::i2c::{AbortReason, FIFO_SIZE, Instance, InterruptHandler, SclPin, SdaPin, set_up_i2c_pin}; |
| 9 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 9 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 10 | use crate::{pac, Peri}; | 10 | use 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 | ||
| 50 | use core::mem::ManuallyDrop; | 50 | use core::mem::ManuallyDrop; |
| 51 | use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; | 51 | use core::sync::atomic::{AtomicBool, Ordering, compiler_fence}; |
| 52 | 52 | ||
| 53 | use crate::interrupt::InterruptExt; | 53 | use crate::interrupt::InterruptExt; |
| 54 | use crate::peripherals::CORE1; | 54 | use crate::peripherals::CORE1; |
| 55 | use crate::{gpio, install_stack_guard, interrupt, pac, Peri}; | 55 | use crate::{Peri, gpio, install_stack_guard, interrupt, pac}; |
| 56 | 56 | ||
| 57 | const PAUSE_TOKEN: u32 = 0xDEADBEEF; | 57 | const PAUSE_TOKEN: u32 = 0xDEADBEEF; |
| 58 | const RESUME_TOKEN: u32 = !0xDEADBEEF; | 58 | const 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 @@ | |||
| 2 | use core::future::Future; | 2 | use core::future::Future; |
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | use core::pin::Pin as FuturePin; | 4 | use core::pin::Pin as FuturePin; |
| 5 | use core::sync::atomic::{compiler_fence, Ordering}; | 5 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use atomic_polyfill::{AtomicU64, AtomicU8}; | 8 | use atomic_polyfill::{AtomicU8, AtomicU64}; |
| 9 | use embassy_hal_internal::{Peri, PeripheralType}; | 9 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| 11 | use fixed::types::extra::U8; | ||
| 12 | use fixed::FixedU32; | 11 | use fixed::FixedU32; |
| 12 | use fixed::types::extra::U8; | ||
| 13 | use pio::{Program, SideSet, Wrap}; | 13 | use pio::{Program, SideSet, Wrap}; |
| 14 | 14 | ||
| 15 | use crate::dma::{self, Channel, Transfer, Word}; | 15 | use crate::dma::{self, Channel, Transfer, Word}; |
| 16 | use crate::gpio::{self, AnyPin, Drive, Level, Pull, SealedPin, SlewRate}; | 16 | use crate::gpio::{self, AnyPin, Drive, Level, Pull, SealedPin, SlewRate}; |
| 17 | use crate::interrupt::typelevel::{Binding, Handler, Interrupt}; | 17 | use crate::interrupt::typelevel::{Binding, Handler, Interrupt}; |
| 18 | use crate::relocate::RelocatedProgram; | 18 | use crate::relocate::RelocatedProgram; |
| 19 | use crate::{pac, peripherals, RegExt}; | 19 | use crate::{RegExt, pac, peripherals}; |
| 20 | 20 | ||
| 21 | mod instr; | 21 | mod 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 | ||
| 3 | use crate::Peri; | ||
| 3 | use crate::dma::{AnyChannel, Channel}; | 4 | use crate::dma::{AnyChannel, Channel}; |
| 4 | use crate::pio::{ | 5 | use 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 | }; |
| 8 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; | 9 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; |
| 9 | use 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>) |
| 12 | pub struct PioHD44780CommandWordProgram<'a, PIO: Instance> { | 12 | pub 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 | ||
| 3 | use fixed::traits::ToFixed; | 3 | use fixed::traits::ToFixed; |
| 4 | 4 | ||
| 5 | use crate::Peri; | ||
| 5 | use crate::dma::{AnyChannel, Channel, Transfer}; | 6 | use crate::dma::{AnyChannel, Channel, Transfer}; |
| 6 | use crate::gpio::Pull; | 7 | use crate::gpio::Pull; |
| 7 | use crate::pio::{ | 8 | use 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 | }; |
| 10 | use crate::Peri; | ||
| 11 | 11 | ||
| 12 | /// This struct represents an i2s receiver & controller driver program | 12 | /// This struct represents an i2s receiver & controller driver program |
| 13 | pub struct PioI2sInProgram<'d, PIO: Instance> { | 13 | pub 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 | ||
| 3 | use crate::Peri; | ||
| 3 | use crate::clocks::clk_sys_freq; | 4 | use crate::clocks::clk_sys_freq; |
| 4 | use crate::gpio::Level; | 5 | use crate::gpio::Level; |
| 5 | use crate::pio::{ | 6 | use crate::pio::{ |
| 6 | Common, Config, Direction, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, | 7 | Common, Config, Direction, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, |
| 7 | }; | 8 | }; |
| 8 | use crate::Peri; | ||
| 9 | 9 | ||
| 10 | /// This struct represents a onewire driver program | 10 | /// This struct represents a onewire driver program |
| 11 | pub struct PioOneWireProgram<'a, PIO: Instance> { | 11 | pub 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 | ||
| 7 | use crate::gpio::Level; | 7 | use crate::gpio::Level; |
| 8 | use crate::pio::{Common, Config, Direction, Instance, LoadedProgram, Pin, PioPin, StateMachine}; | 8 | use crate::pio::{Common, Config, Direction, Instance, LoadedProgram, Pin, PioPin, StateMachine}; |
| 9 | use crate::{clocks, Peri}; | 9 | use 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 |
| 12 | fn to_pio_cycles(duration: Duration) -> u32 { | 12 | fn 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 | ||
| 3 | use crate::Peri; | ||
| 3 | use crate::gpio::Pull; | 4 | use crate::gpio::Pull; |
| 4 | use crate::pio::{ | 5 | use 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 | }; |
| 7 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; | 8 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; |
| 8 | use 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. |
| 11 | pub struct PioEncoderProgram<'a, PIO: Instance> { | 11 | pub 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 | ||
| 3 | use core::mem::{self, MaybeUninit}; | 3 | use core::mem::{self, MaybeUninit}; |
| 4 | 4 | ||
| 5 | use crate::Peri; | ||
| 5 | use crate::pio::{Common, Config, Direction, Instance, Irq, LoadedProgram, PioPin, StateMachine}; | 6 | use crate::pio::{Common, Config, Direction, Instance, Irq, LoadedProgram, PioPin, StateMachine}; |
| 6 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; | 7 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; |
| 7 | use 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. |
| 10 | pub struct PioStepperProgram<'a, PIO: Instance> { | 10 | pub 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; | |||
| 5 | use embedded_io_async::{ErrorType, Read, Write}; | 5 | use embedded_io_async::{ErrorType, Read, Write}; |
| 6 | use fixed::traits::ToFixed; | 6 | use fixed::traits::ToFixed; |
| 7 | 7 | ||
| 8 | use crate::Peri; | ||
| 8 | use crate::clocks::clk_sys_freq; | 9 | use crate::clocks::clk_sys_freq; |
| 9 | use crate::gpio::Level; | 10 | use crate::gpio::Level; |
| 10 | use crate::pio::{ | 11 | use 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 | }; |
| 13 | use 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. |
| 16 | pub struct PioUartTxProgram<'d, PIO: Instance> { | 16 | pub 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; | |||
| 4 | use fixed::types::U24F8; | 4 | use fixed::types::U24F8; |
| 5 | use smart_leds::{RGB8, RGBW}; | 5 | use smart_leds::{RGB8, RGBW}; |
| 6 | 6 | ||
| 7 | use crate::Peri; | ||
| 7 | use crate::clocks::clk_sys_freq; | 8 | use crate::clocks::clk_sys_freq; |
| 8 | use crate::dma::{AnyChannel, Channel}; | 9 | use crate::dma::{AnyChannel, Channel}; |
| 9 | use crate::pio::{ | 10 | use crate::pio::{ |
| 10 | Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, | 11 | Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, |
| 11 | }; | 12 | }; |
| 12 | use crate::Peri; | ||
| 13 | 13 | ||
| 14 | const T1: u8 = 2; // start bit | 14 | const T1: u8 = 2; // start bit |
| 15 | const T2: u8 = 5; // data bit | 15 | const 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 | ||
| 13 | use critical_section::{acquire, release, CriticalSection, RestoreState}; | 13 | use critical_section::{CriticalSection, RestoreState, acquire, release}; |
| 14 | 14 | ||
| 15 | use crate::pac; | 15 | use crate::pac; |
| 16 | use crate::qmi_cs1::QmiCs1; | 16 | use 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 @@ | |||
| 3 | use embassy_hal_internal::{Peri, PeripheralType}; | 3 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 4 | pub use embedded_hal_1::pwm::SetDutyCycle; | 4 | pub use embedded_hal_1::pwm::SetDutyCycle; |
| 5 | use embedded_hal_1::pwm::{Error, ErrorKind, ErrorType}; | 5 | use embedded_hal_1::pwm::{Error, ErrorKind, ErrorType}; |
| 6 | use fixed::traits::ToFixed; | ||
| 7 | use fixed::FixedU16; | 6 | use fixed::FixedU16; |
| 7 | use fixed::traits::ToFixed; | ||
| 8 | use pac::pwm::regs::{ChDiv, Intr}; | 8 | use pac::pwm::regs::{ChDiv, Intr}; |
| 9 | use pac::pwm::vals::Divmode; | 9 | use pac::pwm::vals::Divmode; |
| 10 | 10 | ||
| 11 | use crate::gpio::{AnyPin, Pin as GpioPin, Pull, SealedPin as _}; | 11 | use crate::gpio::{AnyPin, Pin as GpioPin, Pull, SealedPin as _}; |
| 12 | use crate::{pac, peripherals, RegExt}; | 12 | use 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 @@ | |||
| 2 | mod filter; | 2 | mod filter; |
| 3 | 3 | ||
| 4 | use core::future::poll_fn; | 4 | use core::future::poll_fn; |
| 5 | use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; | 5 | use core::sync::atomic::{AtomicBool, Ordering, compiler_fence}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{Peri, PeripheralType}; | 8 | use 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 @@ | |||
| 2 | use core::cell::{Cell, RefCell}; | 2 | use core::cell::{Cell, RefCell}; |
| 3 | 3 | ||
| 4 | use critical_section::CriticalSection; | 4 | use critical_section::CriticalSection; |
| 5 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 6 | use embassy_sync::blocking_mutex::Mutex; | 5 | use embassy_sync::blocking_mutex::Mutex; |
| 6 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 7 | use embassy_time_driver::Driver; | 7 | use embassy_time_driver::Driver; |
| 8 | use embassy_time_queue_utils::Queue; | 8 | use 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; | |||
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use atomic_polyfill::{AtomicU16, Ordering}; | 6 | use atomic_polyfill::{AtomicU16, Ordering}; |
| 7 | use embassy_futures::select::{select, Either}; | 7 | use embassy_futures::select::{Either, select}; |
| 8 | use embassy_hal_internal::{Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | use embassy_time::{Delay, Timer}; | 10 | use embassy_time::{Delay, Timer}; |
| @@ -16,7 +16,7 @@ use crate::gpio::{AnyPin, SealedPin}; | |||
| 16 | use crate::interrupt::typelevel::{Binding, Interrupt as _}; | 16 | use crate::interrupt::typelevel::{Binding, Interrupt as _}; |
| 17 | use crate::interrupt::{Interrupt, InterruptExt}; | 17 | use crate::interrupt::{Interrupt, InterruptExt}; |
| 18 | use crate::pac::io::vals::{Inover, Outover}; | 18 | use crate::pac::io::vals::{Inover, Outover}; |
| 19 | use crate::{interrupt, pac, peripherals, RegExt}; | 19 | use crate::{RegExt, interrupt, pac, peripherals}; |
| 20 | 20 | ||
| 21 | mod buffered; | 21 | mod buffered; |
| 22 | pub use buffered::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, BufferedUartTx}; | 22 | pub 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 @@ | |||
| 2 | use core::future::poll_fn; | 2 | use core::future::poll_fn; |
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | use core::slice; | 4 | use core::slice; |
| 5 | use core::sync::atomic::{compiler_fence, Ordering}; | 5 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::PeripheralType; | 8 | use embassy_hal_internal::PeripheralType; |
| @@ -13,7 +13,7 @@ use embassy_usb_driver::{ | |||
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| 15 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 15 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 16 | use crate::{interrupt, pac, peripherals, Peri, RegExt}; | 16 | use crate::{Peri, RegExt, interrupt, pac, peripherals}; |
| 17 | 17 | ||
| 18 | trait SealedInstance { | 18 | trait 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; | |||
| 11 | use embassy_time::Duration; | 11 | use embassy_time::Duration; |
| 12 | 12 | ||
| 13 | use crate::peripherals::WATCHDOG; | 13 | use crate::peripherals::WATCHDOG; |
| 14 | use crate::{pac, Peri}; | 14 | use 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)] |
