diff options
Diffstat (limited to 'examples/common/mod.rs')
| -rw-r--r-- | examples/common/mod.rs | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/examples/common/mod.rs b/examples/common/mod.rs index 8c52c8e86..7b197a590 100644 --- a/examples/common/mod.rs +++ b/examples/common/mod.rs | |||
| @@ -1,45 +1,31 @@ | |||
| 1 | //! Shared board-specific helpers for the FRDM-MCXA276 examples. | 1 | //! Shared board-specific helpers for the FRDM-MCXA276 examples. |
| 2 | //! These live with the examples so the HAL stays generic. | 2 | //! These live with the examples so the HAL stays generic. |
| 3 | 3 | ||
| 4 | use hal::{clocks, pins, reset}; | 4 | use hal::{clocks, pins}; |
| 5 | use {embassy_mcxa276 as hal, panic_probe as _}; | 5 | use {embassy_mcxa276 as hal, panic_probe as _}; |
| 6 | 6 | ||
| 7 | /// Initialize clocks and pin muxing for UART2 debug console. | 7 | /// Initialize clocks and pin muxing for UART2 debug console. |
| 8 | /// Safe to call multiple times; writes are idempotent for our use. | 8 | /// Safe to call multiple times; writes are idempotent for our use. |
| 9 | #[allow(dead_code)] | 9 | #[allow(dead_code)] |
| 10 | pub unsafe fn init_uart2(p: &mcxa_pac::Peripherals) { | 10 | pub unsafe fn init_uart2(_p: &mcxa_pac::Peripherals) { |
| 11 | clocks::ensure_frolf_running(p); | 11 | // NOTE: Lpuart has been updated to properly enable + reset its own clocks. |
| 12 | clocks::enable_uart2_port2(p); | 12 | // GPIO has not. |
| 13 | reset::release_reset_port2(p); | 13 | _ = clocks::enable_and_reset::<hal::peripherals::PORT2>(&clocks::NoConfig); |
| 14 | reset::release_reset_lpuart2(p); | ||
| 15 | pins::configure_uart2_pins_port2(); | 14 | pins::configure_uart2_pins_port2(); |
| 16 | clocks::select_uart2_clock(p); | ||
| 17 | } | 15 | } |
| 18 | 16 | ||
| 19 | /// Initialize clocks for the LED GPIO/PORT used by the blink example. | 17 | /// Initialize clocks for the LED GPIO/PORT used by the blink example. |
| 20 | #[allow(dead_code)] | 18 | #[allow(dead_code)] |
| 21 | pub unsafe fn init_led(p: &mcxa_pac::Peripherals) { | 19 | pub unsafe fn init_led(_p: &mcxa_pac::Peripherals) { |
| 22 | clocks::enable_led_port(p); | 20 | _ = clocks::enable_and_reset::<hal::peripherals::PORT3>(&clocks::NoConfig); |
| 23 | reset::release_reset_gpio3(p); | 21 | _ = clocks::enable_and_reset::<hal::peripherals::GPIO3>(&clocks::NoConfig); |
| 24 | reset::release_reset_port3(p); | ||
| 25 | } | ||
| 26 | |||
| 27 | /// Initialize clocks for OSTIMER0 (1 MHz source). | ||
| 28 | #[allow(dead_code)] | ||
| 29 | pub unsafe fn init_ostimer0(p: &mcxa_pac::Peripherals) { | ||
| 30 | clocks::ensure_frolf_running(p); | ||
| 31 | clocks::enable_ostimer0(p); | ||
| 32 | reset::release_reset_ostimer0(p); | ||
| 33 | clocks::select_ostimer0_clock_1m(p); | ||
| 34 | } | 22 | } |
| 35 | 23 | ||
| 36 | /// Initialize clocks and pin muxing for ADC. | 24 | /// Initialize clocks and pin muxing for ADC. |
| 37 | #[allow(dead_code)] | 25 | #[allow(dead_code)] |
| 38 | pub unsafe fn init_adc(p: &mcxa_pac::Peripherals) { | 26 | pub unsafe fn init_adc(_p: &mcxa_pac::Peripherals) { |
| 39 | clocks::ensure_frolf_running(p); | 27 | // NOTE: Lpuart has been updated to properly enable + reset its own clocks. |
| 40 | clocks::enable_adc(p); | 28 | // GPIO has not. |
| 41 | reset::release_reset_port1(p); | 29 | _ = clocks::enable_and_reset::<hal::peripherals::PORT1>(&clocks::NoConfig); |
| 42 | reset::release_reset_adc1(p); | ||
| 43 | pins::configure_adc_pins(); | 30 | pins::configure_adc_pins(); |
| 44 | clocks::select_adc_clock(p); | ||
| 45 | } | 31 | } |
