diff options
| author | maor1993 <[email protected]> | 2025-10-07 15:05:09 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-07 15:05:09 +0300 |
| commit | 04a36e9f62385fb4338908de66045f36fec664ea (patch) | |
| tree | 714fcc21114946e33b2be8eb6037bdc3dd9bb596 /embassy-rp/src | |
| parent | cd91fe3b30dbb3d5b3c9c7d9e7cb151d721fb8d5 (diff) | |
| parent | 07016a4ffbe0b0ea689b83a6ddf19ab1b6a9a79a (diff) | |
Merge branch 'embassy-rs:main' into main
Diffstat (limited to 'embassy-rp/src')
28 files changed, 71 insertions, 110 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 14f9e46aa..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 | /// |
| @@ -36,7 +36,7 @@ mod ram_helpers { | |||
| 36 | /// This function must live in ram. It uses inline asm to avoid any | 36 | /// This function must live in ram. It uses inline asm to avoid any |
| 37 | /// potential calls to ABI functions that might be in flash. | 37 | /// potential calls to ABI functions that might be in flash. |
| 38 | #[inline(never)] | 38 | #[inline(never)] |
| 39 | #[link_section = ".data.ram_func"] | 39 | #[unsafe(link_section = ".data.ram_func")] |
| 40 | #[cfg(target_arch = "arm")] | 40 | #[cfg(target_arch = "arm")] |
| 41 | pub unsafe fn read_cs_status() -> GpioStatus { | 41 | pub unsafe fn read_cs_status() -> GpioStatus { |
| 42 | let result: u32; | 42 | let result: u32; |
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 8c809090e..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}; |
| @@ -627,7 +627,7 @@ mod ram_helpers { | |||
| 627 | /// Length of data must be a multiple of 4096 | 627 | /// Length of data must be a multiple of 4096 |
| 628 | /// addr must be aligned to 4096 | 628 | /// addr must be aligned to 4096 |
| 629 | #[inline(never)] | 629 | #[inline(never)] |
| 630 | #[link_section = ".data.ram_func"] | 630 | #[unsafe(link_section = ".data.ram_func")] |
| 631 | #[cfg(feature = "rp2040")] | 631 | #[cfg(feature = "rp2040")] |
| 632 | unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) { | 632 | unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) { |
| 633 | #[cfg(target_arch = "arm")] | 633 | #[cfg(target_arch = "arm")] |
| @@ -692,7 +692,7 @@ mod ram_helpers { | |||
| 692 | /// Length of data must be a multiple of 4096 | 692 | /// Length of data must be a multiple of 4096 |
| 693 | /// addr must be aligned to 4096 | 693 | /// addr must be aligned to 4096 |
| 694 | #[inline(never)] | 694 | #[inline(never)] |
| 695 | #[link_section = ".data.ram_func"] | 695 | #[unsafe(link_section = ".data.ram_func")] |
| 696 | #[cfg(feature = "_rp235x")] | 696 | #[cfg(feature = "_rp235x")] |
| 697 | unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) { | 697 | unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) { |
| 698 | let data = data.map(|d| d.as_ptr()).unwrap_or(core::ptr::null()); | 698 | let data = data.map(|d| d.as_ptr()).unwrap_or(core::ptr::null()); |
| @@ -811,7 +811,7 @@ mod ram_helpers { | |||
| 811 | /// | 811 | /// |
| 812 | /// Credit: taken from `rp2040-flash` (also licensed Apache+MIT) | 812 | /// Credit: taken from `rp2040-flash` (also licensed Apache+MIT) |
| 813 | #[inline(never)] | 813 | #[inline(never)] |
| 814 | #[link_section = ".data.ram_func"] | 814 | #[unsafe(link_section = ".data.ram_func")] |
| 815 | #[cfg(feature = "rp2040")] | 815 | #[cfg(feature = "rp2040")] |
| 816 | unsafe fn read_flash_inner(cmd: FlashCommand, ptrs: *const FlashFunctionPointers) { | 816 | unsafe fn read_flash_inner(cmd: FlashCommand, ptrs: *const FlashFunctionPointers) { |
| 817 | #[cfg(target_arch = "arm")] | 817 | #[cfg(target_arch = "arm")] |
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/intrinsics.rs b/embassy-rp/src/intrinsics.rs index 69d5d92de..aed8a3227 100644 --- a/embassy-rp/src/intrinsics.rs +++ b/embassy-rp/src/intrinsics.rs | |||
| @@ -223,7 +223,7 @@ macro_rules! intrinsics { | |||
| 223 | 223 | ||
| 224 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | 224 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] |
| 225 | mod $name { | 225 | mod $name { |
| 226 | #[no_mangle] | 226 | #[unsafe(no_mangle)] |
| 227 | $(#[$($attr)*])* | 227 | $(#[$($attr)*])* |
| 228 | pub extern $abi fn $name( $($argname: $ty),* ) -> $ret { | 228 | pub extern $abi fn $name( $($argname: $ty),* ) -> $ret { |
| 229 | super::$name($($argname),*) | 229 | super::$name($($argname),*) |
| @@ -257,7 +257,7 @@ macro_rules! intrinsics { | |||
| 257 | 257 | ||
| 258 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | 258 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] |
| 259 | mod $name { | 259 | mod $name { |
| 260 | #[no_mangle] | 260 | #[unsafe(no_mangle)] |
| 261 | $(#[$($attr)*])* | 261 | $(#[$($attr)*])* |
| 262 | pub unsafe extern $abi fn $name( $($argname: $ty),* ) -> $ret { | 262 | pub unsafe extern $abi fn $name( $($argname: $ty),* ) -> $ret { |
| 263 | super::$name($($argname),*) | 263 | super::$name($($argname),*) |
| @@ -392,7 +392,7 @@ macro_rules! division_function { | |||
| 392 | ); | 392 | ); |
| 393 | 393 | ||
| 394 | #[cfg(target_arch = "arm")] | 394 | #[cfg(target_arch = "arm")] |
| 395 | extern "aapcs" { | 395 | unsafe extern "aapcs" { |
| 396 | // Connect a local name to global symbol above through FFI. | 396 | // Connect a local name to global symbol above through FFI. |
| 397 | #[link_name = concat!("_erphal_", stringify!($name)) ] | 397 | #[link_name = concat!("_erphal_", stringify!($name)) ] |
| 398 | fn $name(n: $argty, d: $argty) -> u64; | 398 | fn $name(n: $argty, d: $argty) -> u64; |
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index d03ba1fef..4cb1a0912 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 4 | #![allow(unused_unsafe)] | ||
| 3 | #![doc = include_str!("../README.md")] | 5 | #![doc = include_str!("../README.md")] |
| 4 | #![warn(missing_docs)] | 6 | #![warn(missing_docs)] |
| 5 | 7 | ||
| @@ -190,7 +192,7 @@ macro_rules! bind_interrupts { | |||
| 190 | 192 | ||
| 191 | $( | 193 | $( |
| 192 | #[allow(non_snake_case)] | 194 | #[allow(non_snake_case)] |
| 193 | #[no_mangle] | 195 | #[unsafe(no_mangle)] |
| 194 | $(#[cfg($cond_irq)])? | 196 | $(#[cfg($cond_irq)])? |
| 195 | unsafe extern "C" fn $irq() { | 197 | unsafe extern "C" fn $irq() { |
| 196 | unsafe { | 198 | unsafe { |
| @@ -446,13 +448,13 @@ macro_rules! select_bootloader { | |||
| 446 | ( $( $feature:literal => $loader:ident, )+ default => $default:ident ) => { | 448 | ( $( $feature:literal => $loader:ident, )+ default => $default:ident ) => { |
| 447 | $( | 449 | $( |
| 448 | #[cfg(feature = $feature)] | 450 | #[cfg(feature = $feature)] |
| 449 | #[link_section = ".boot2"] | 451 | #[unsafe(link_section = ".boot2")] |
| 450 | #[used] | 452 | #[used] |
| 451 | static BOOT2: [u8; 256] = rp2040_boot2::$loader; | 453 | static BOOT2: [u8; 256] = rp2040_boot2::$loader; |
| 452 | )* | 454 | )* |
| 453 | 455 | ||
| 454 | #[cfg(not(any( $( feature = $feature),* )))] | 456 | #[cfg(not(any( $( feature = $feature),* )))] |
| 455 | #[link_section = ".boot2"] | 457 | #[unsafe(link_section = ".boot2")] |
| 456 | #[used] | 458 | #[used] |
| 457 | static BOOT2: [u8; 256] = rp2040_boot2::$default; | 459 | static BOOT2: [u8; 256] = rp2040_boot2::$default; |
| 458 | } | 460 | } |
| @@ -475,13 +477,13 @@ macro_rules! select_imagedef { | |||
| 475 | ( $( $feature:literal => $imagedef:ident, )+ default => $default:ident ) => { | 477 | ( $( $feature:literal => $imagedef:ident, )+ default => $default:ident ) => { |
| 476 | $( | 478 | $( |
| 477 | #[cfg(feature = $feature)] | 479 | #[cfg(feature = $feature)] |
| 478 | #[link_section = ".start_block"] | 480 | #[unsafe(link_section = ".start_block")] |
| 479 | #[used] | 481 | #[used] |
| 480 | static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$imagedef(); | 482 | static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$imagedef(); |
| 481 | )* | 483 | )* |
| 482 | 484 | ||
| 483 | #[cfg(not(any( $( feature = $feature),* )))] | 485 | #[cfg(not(any( $( feature = $feature),* )))] |
| 484 | #[link_section = ".start_block"] | 486 | #[unsafe(link_section = ".start_block")] |
| 485 | #[used] | 487 | #[used] |
| 486 | static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$default(); | 488 | static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$default(); |
| 487 | } | 489 | } |
| @@ -528,7 +530,7 @@ select_imagedef! { | |||
| 528 | /// } | 530 | /// } |
| 529 | /// ``` | 531 | /// ``` |
| 530 | pub fn install_core0_stack_guard() -> Result<(), ()> { | 532 | pub fn install_core0_stack_guard() -> Result<(), ()> { |
| 531 | extern "C" { | 533 | unsafe extern "C" { |
| 532 | static mut _stack_end: usize; | 534 | static mut _stack_end: usize; |
| 533 | } | 535 | } |
| 534 | unsafe { install_stack_guard(core::ptr::addr_of_mut!(_stack_end)) } | 536 | unsafe { install_stack_guard(core::ptr::addr_of_mut!(_stack_end)) } |
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs index adedc98ad..3b120e349 100644 --- a/embassy-rp/src/multicore.rs +++ b/embassy-rp/src/multicore.rs | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | //! use embassy_rp::multicore::Stack; | 14 | //! use embassy_rp::multicore::Stack; |
| 15 | //! use static_cell::StaticCell; | 15 | //! use static_cell::StaticCell; |
| 16 | //! use embassy_executor::Executor; | 16 | //! use embassy_executor::Executor; |
| 17 | //! use core::ptr::addr_of_mut; | ||
| 17 | //! | 18 | //! |
| 18 | //! static mut CORE1_STACK: Stack<4096> = Stack::new(); | 19 | //! static mut CORE1_STACK: Stack<4096> = Stack::new(); |
| 19 | //! static EXECUTOR0: StaticCell<Executor> = StaticCell::new(); | 20 | //! static EXECUTOR0: StaticCell<Executor> = StaticCell::new(); |
| @@ -36,7 +37,7 @@ | |||
| 36 | //! fn main() -> ! { | 37 | //! fn main() -> ! { |
| 37 | //! let p = embassy_rp::init(Default::default()); | 38 | //! let p = embassy_rp::init(Default::default()); |
| 38 | //! | 39 | //! |
| 39 | //! embassy_rp::multicore::spawn_core1(p.CORE1, unsafe { &mut CORE1_STACK }, move || { | 40 | //! embassy_rp::multicore::spawn_core1(p.CORE1, unsafe { &mut *addr_of_mut!(CORE1_STACK) }, move || { |
| 40 | //! let executor1 = EXECUTOR1.init(Executor::new()); | 41 | //! let executor1 = EXECUTOR1.init(Executor::new()); |
| 41 | //! executor1.run(|spawner| spawner.spawn(core1_task().unwrap())); | 42 | //! executor1.run(|spawner| spawner.spawn(core1_task().unwrap())); |
| 42 | //! }); | 43 | //! }); |
| @@ -47,11 +48,11 @@ | |||
| 47 | //! ``` | 48 | //! ``` |
| 48 | 49 | ||
| 49 | use core::mem::ManuallyDrop; | 50 | use core::mem::ManuallyDrop; |
| 50 | use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; | 51 | use core::sync::atomic::{AtomicBool, Ordering, compiler_fence}; |
| 51 | 52 | ||
| 52 | use crate::interrupt::InterruptExt; | 53 | use crate::interrupt::InterruptExt; |
| 53 | use crate::peripherals::CORE1; | 54 | use crate::peripherals::CORE1; |
| 54 | use crate::{gpio, install_stack_guard, interrupt, pac, Peri}; | 55 | use crate::{Peri, gpio, install_stack_guard, interrupt, pac}; |
| 55 | 56 | ||
| 56 | const PAUSE_TOKEN: u32 = 0xDEADBEEF; | 57 | const PAUSE_TOKEN: u32 = 0xDEADBEEF; |
| 57 | const RESUME_TOKEN: u32 = !0xDEADBEEF; | 58 | const RESUME_TOKEN: u32 = !0xDEADBEEF; |
| @@ -110,7 +111,6 @@ impl<const SIZE: usize> Stack<SIZE> { | |||
| 110 | 111 | ||
| 111 | #[cfg(all(feature = "rt", feature = "rp2040"))] | 112 | #[cfg(all(feature = "rt", feature = "rp2040"))] |
| 112 | #[interrupt] | 113 | #[interrupt] |
| 113 | #[link_section = ".data.ram_func"] | ||
| 114 | unsafe fn SIO_IRQ_PROC1() { | 114 | unsafe fn SIO_IRQ_PROC1() { |
| 115 | let sio = pac::SIO; | 115 | let sio = pac::SIO; |
| 116 | // Clear IRQ | 116 | // Clear IRQ |
| @@ -135,7 +135,6 @@ unsafe fn SIO_IRQ_PROC1() { | |||
| 135 | 135 | ||
| 136 | #[cfg(all(feature = "rt", feature = "_rp235x"))] | 136 | #[cfg(all(feature = "rt", feature = "_rp235x"))] |
| 137 | #[interrupt] | 137 | #[interrupt] |
| 138 | #[link_section = ".data.ram_func"] | ||
| 139 | unsafe fn SIO_IRQ_FIFO() { | 138 | unsafe fn SIO_IRQ_FIFO() { |
| 140 | let sio = pac::SIO; | 139 | let sio = pac::SIO; |
| 141 | // Clear IRQ | 140 | // Clear IRQ |
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 ae43dd5aa..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; |
| @@ -251,7 +251,7 @@ impl<'d> Psram<'d> { | |||
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | /// Verify APS6404L PSRAM device matches expected configuration. | 253 | /// Verify APS6404L PSRAM device matches expected configuration. |
| 254 | #[link_section = ".data.ram_func"] | 254 | #[unsafe(link_section = ".data.ram_func")] |
| 255 | #[inline(never)] | 255 | #[inline(never)] |
| 256 | fn verify_aps6404l(qmi: &pac::qmi::Qmi, expected_size: usize) -> Result<(), Error> { | 256 | fn verify_aps6404l(qmi: &pac::qmi::Qmi, expected_size: usize) -> Result<(), Error> { |
| 257 | // APS6404L-specific constants | 257 | // APS6404L-specific constants |
| @@ -306,7 +306,7 @@ impl<'d> Psram<'d> { | |||
| 306 | Ok(()) | 306 | Ok(()) |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | #[link_section = ".data.ram_func"] | 309 | #[unsafe(link_section = ".data.ram_func")] |
| 310 | #[inline(never)] | 310 | #[inline(never)] |
| 311 | unsafe fn read_aps6404l_kgd_eid(qmi: &pac::qmi::Qmi) -> (u32, u32) { | 311 | unsafe fn read_aps6404l_kgd_eid(qmi: &pac::qmi::Qmi) -> (u32, u32) { |
| 312 | const RESET_ENABLE_CMD: u8 = 0xf5; | 312 | const RESET_ENABLE_CMD: u8 = 0xf5; |
| @@ -435,7 +435,7 @@ impl<'d> Psram<'d> { | |||
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | /// Initialize PSRAM with proper timing. | 437 | /// Initialize PSRAM with proper timing. |
| 438 | #[link_section = ".data.ram_func"] | 438 | #[unsafe(link_section = ".data.ram_func")] |
| 439 | #[inline(never)] | 439 | #[inline(never)] |
| 440 | fn init_psram(qmi: &pac::qmi::Qmi, xip_ctrl: &pac::xip_ctrl::XipCtrl, config: &Config) -> Result<(), Error> { | 440 | fn init_psram(qmi: &pac::qmi::Qmi, xip_ctrl: &pac::xip_ctrl::XipCtrl, config: &Config) -> Result<(), Error> { |
| 441 | // Set PSRAM timing for APS6404 | 441 | // Set PSRAM timing for APS6404 |
| @@ -610,7 +610,7 @@ impl<'d> Psram<'d> { | |||
| 610 | Ok(()) | 610 | Ok(()) |
| 611 | } | 611 | } |
| 612 | 612 | ||
| 613 | #[link_section = ".data.ram_func"] | 613 | #[unsafe(link_section = ".data.ram_func")] |
| 614 | #[inline(never)] | 614 | #[inline(never)] |
| 615 | unsafe fn direct_csr_send_init_command(config: &Config, init_cmd: u8) { | 615 | unsafe fn direct_csr_send_init_command(config: &Config, init_cmd: u8) { |
| 616 | #[cfg(target_arch = "arm")] | 616 | #[cfg(target_arch = "arm")] |
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)] |
