diff options
| author | James Munns <[email protected]> | 2025-11-17 15:02:26 +0100 |
|---|---|---|
| committer | James Munns <[email protected]> | 2025-11-17 15:02:26 +0100 |
| commit | a0c8e2d0299f3ae8eb24cd264d2b8e87f2bce464 (patch) | |
| tree | 063cd0e6fe0a7b06c86d175addc54f5712e3a0d1 | |
| parent | a8ca36cdbe06e83019279e441ac386a448c12edb (diff) | |
Restore examples
| -rw-r--r-- | examples/src/lib.rs | 8 | ||||
| -rw-r--r-- | src/clocks/mod.rs | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/examples/src/lib.rs b/examples/src/lib.rs index be4761c32..2018a3c25 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs | |||
| @@ -12,20 +12,20 @@ use {embassy_mcxa as hal, panic_probe as _}; | |||
| 12 | pub unsafe fn init_uart2_pins(_p: &hal::pac::Peripherals) { | 12 | pub unsafe fn init_uart2_pins(_p: &hal::pac::Peripherals) { |
| 13 | // NOTE: Lpuart has been updated to properly enable + reset its own clocks. | 13 | // NOTE: Lpuart has been updated to properly enable + reset its own clocks. |
| 14 | // GPIO has not. | 14 | // GPIO has not. |
| 15 | _ = clocks::enable_and_reset::<hal::peripherals::PORT2>(&clocks::NoConfig); | 15 | _ = clocks::enable_and_reset::<hal::peripherals::PORT2>(&clocks::periph_helpers::NoConfig); |
| 16 | pins::configure_uart2_pins_port2(); | 16 | pins::configure_uart2_pins_port2(); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | /// Initialize clocks for the LED GPIO/PORT used by the blink example. | 19 | /// Initialize clocks for the LED GPIO/PORT used by the blink example. |
| 20 | pub unsafe fn init_led_gpio_clocks(_p: &hal::pac::Peripherals) { | 20 | pub unsafe fn init_led_gpio_clocks(_p: &hal::pac::Peripherals) { |
| 21 | _ = clocks::enable_and_reset::<hal::peripherals::PORT3>(&clocks::NoConfig); | 21 | _ = clocks::enable_and_reset::<hal::peripherals::PORT3>(&clocks::periph_helpers::NoConfig); |
| 22 | _ = clocks::enable_and_reset::<hal::peripherals::GPIO3>(&clocks::NoConfig); | 22 | _ = clocks::enable_and_reset::<hal::peripherals::GPIO3>(&clocks::periph_helpers::NoConfig); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | /// Initialize clocks and pin muxing for ADC. | 25 | /// Initialize clocks and pin muxing for ADC. |
| 26 | pub unsafe fn init_adc_pins(_p: &hal::pac::Peripherals) { | 26 | pub unsafe fn init_adc_pins(_p: &hal::pac::Peripherals) { |
| 27 | // NOTE: Lpuart has been updated to properly enable + reset its own clocks. | 27 | // NOTE: Lpuart has been updated to properly enable + reset its own clocks. |
| 28 | // GPIO has not. | 28 | // GPIO has not. |
| 29 | _ = clocks::enable_and_reset::<hal::peripherals::PORT1>(&clocks::NoConfig); | 29 | _ = clocks::enable_and_reset::<hal::peripherals::PORT1>(&clocks::periph_helpers::NoConfig); |
| 30 | pins::configure_adc_pins(); | 30 | pins::configure_adc_pins(); |
| 31 | } | 31 | } |
diff --git a/src/clocks/mod.rs b/src/clocks/mod.rs index 40acb11ec..74a1f1a1f 100644 --- a/src/clocks/mod.rs +++ b/src/clocks/mod.rs | |||
| @@ -319,7 +319,7 @@ pub trait Gate { | |||
| 319 | /// | 319 | /// |
| 320 | /// This peripheral must not yet be in use prior to calling `enable_and_reset`. | 320 | /// This peripheral must not yet be in use prior to calling `enable_and_reset`. |
| 321 | #[inline] | 321 | #[inline] |
| 322 | pub(crate) unsafe fn enable_and_reset<G: Gate>(cfg: &G::MrccPeriphConfig) -> Result<u32, ClockError> { | 322 | pub unsafe fn enable_and_reset<G: Gate>(cfg: &G::MrccPeriphConfig) -> Result<u32, ClockError> { |
| 323 | let freq = enable::<G>(cfg).inspect_err(|_| disable::<G>())?; | 323 | let freq = enable::<G>(cfg).inspect_err(|_| disable::<G>())?; |
| 324 | pulse_reset::<G>(); | 324 | pulse_reset::<G>(); |
| 325 | Ok(freq) | 325 | Ok(freq) |
| @@ -334,7 +334,7 @@ pub(crate) unsafe fn enable_and_reset<G: Gate>(cfg: &G::MrccPeriphConfig) -> Res | |||
| 334 | /// | 334 | /// |
| 335 | /// This peripheral must not yet be in use prior to calling `enable`. | 335 | /// This peripheral must not yet be in use prior to calling `enable`. |
| 336 | #[inline] | 336 | #[inline] |
| 337 | pub(crate) unsafe fn enable<G: Gate>(cfg: &G::MrccPeriphConfig) -> Result<u32, ClockError> { | 337 | pub unsafe fn enable<G: Gate>(cfg: &G::MrccPeriphConfig) -> Result<u32, ClockError> { |
| 338 | G::enable_clock(); | 338 | G::enable_clock(); |
| 339 | while !G::is_clock_enabled() {} | 339 | while !G::is_clock_enabled() {} |
| 340 | core::arch::asm!("dsb sy; isb sy", options(nomem, nostack, preserves_flags)); | 340 | core::arch::asm!("dsb sy; isb sy", options(nomem, nostack, preserves_flags)); |
| @@ -357,14 +357,14 @@ pub(crate) unsafe fn enable<G: Gate>(cfg: &G::MrccPeriphConfig) -> Result<u32, C | |||
| 357 | /// This peripheral must no longer be in use prior to calling `enable`. | 357 | /// This peripheral must no longer be in use prior to calling `enable`. |
| 358 | #[allow(dead_code)] | 358 | #[allow(dead_code)] |
| 359 | #[inline] | 359 | #[inline] |
| 360 | pub(crate) unsafe fn disable<G: Gate>() { | 360 | pub unsafe fn disable<G: Gate>() { |
| 361 | G::disable_clock(); | 361 | G::disable_clock(); |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | /// Check whether a gate is currently enabled. | 364 | /// Check whether a gate is currently enabled. |
| 365 | #[allow(dead_code)] | 365 | #[allow(dead_code)] |
| 366 | #[inline] | 366 | #[inline] |
| 367 | pub(crate) fn is_clock_enabled<G: Gate>() -> bool { | 367 | pub fn is_clock_enabled<G: Gate>() -> bool { |
| 368 | G::is_clock_enabled() | 368 | G::is_clock_enabled() |
| 369 | } | 369 | } |
| 370 | 370 | ||
| @@ -376,7 +376,7 @@ pub(crate) fn is_clock_enabled<G: Gate>() -> bool { | |||
| 376 | /// | 376 | /// |
| 377 | /// This peripheral must not yet be in use prior to calling `release_reset`. | 377 | /// This peripheral must not yet be in use prior to calling `release_reset`. |
| 378 | #[inline] | 378 | #[inline] |
| 379 | pub(crate) unsafe fn release_reset<G: Gate>() { | 379 | pub unsafe fn release_reset<G: Gate>() { |
| 380 | G::release_reset(); | 380 | G::release_reset(); |
| 381 | } | 381 | } |
| 382 | 382 | ||
| @@ -388,13 +388,13 @@ pub(crate) unsafe fn release_reset<G: Gate>() { | |||
| 388 | /// | 388 | /// |
| 389 | /// This peripheral must not yet be in use prior to calling `assert_reset`. | 389 | /// This peripheral must not yet be in use prior to calling `assert_reset`. |
| 390 | #[inline] | 390 | #[inline] |
| 391 | pub(crate) unsafe fn assert_reset<G: Gate>() { | 391 | pub unsafe fn assert_reset<G: Gate>() { |
| 392 | G::assert_reset(); | 392 | G::assert_reset(); |
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | /// Check whether the peripheral is held in reset. | 395 | /// Check whether the peripheral is held in reset. |
| 396 | #[inline] | 396 | #[inline] |
| 397 | pub(crate) unsafe fn is_reset_released<G: Gate>() -> bool { | 397 | pub unsafe fn is_reset_released<G: Gate>() -> bool { |
| 398 | G::is_reset_released() | 398 | G::is_reset_released() |
| 399 | } | 399 | } |
| 400 | 400 | ||
| @@ -406,7 +406,7 @@ pub(crate) unsafe fn is_reset_released<G: Gate>() -> bool { | |||
| 406 | /// | 406 | /// |
| 407 | /// This peripheral must not yet be in use prior to calling `release_reset`. | 407 | /// This peripheral must not yet be in use prior to calling `release_reset`. |
| 408 | #[inline] | 408 | #[inline] |
| 409 | pub(crate) unsafe fn pulse_reset<G: Gate>() { | 409 | pub unsafe fn pulse_reset<G: Gate>() { |
| 410 | G::assert_reset(); | 410 | G::assert_reset(); |
| 411 | cortex_m::asm::nop(); | 411 | cortex_m::asm::nop(); |
| 412 | cortex_m::asm::nop(); | 412 | cortex_m::asm::nop(); |
