diff options
Diffstat (limited to 'examples/src/lib.rs')
| -rw-r--r-- | examples/src/lib.rs | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/examples/src/lib.rs b/examples/src/lib.rs index cf4194559..4bb334da5 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs | |||
| @@ -1,63 +1,31 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(clippy::missing_safety_doc)] | ||
| 2 | 3 | ||
| 3 | //! Shared board-specific helpers for the FRDM-MCXA276 examples. | 4 | //! Shared board-specific helpers for the FRDM-MCXA276 examples. |
| 4 | //! These live with the examples so the HAL stays generic. | 5 | //! These live with the examples so the HAL stays generic. |
| 5 | 6 | ||
| 6 | use hal::{clocks, pins, reset}; | 7 | use hal::{clocks, pins}; |
| 7 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; | 8 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; |
| 8 | 9 | ||
| 9 | /// Initialize clocks and pin muxing for UART2 debug console. | 10 | /// Initialize clocks and pin muxing for UART2 debug console. |
| 10 | /// Safe to call multiple times; writes are idempotent for our use. | 11 | /// Safe to call multiple times; writes are idempotent for our use. |
| 11 | /// | 12 | pub unsafe fn init_uart2_pins(_p: &hal::pac::Peripherals) { |
| 12 | /// # Safety | 13 | // NOTE: Lpuart has been updated to properly enable + reset its own clocks. |
| 13 | /// | 14 | // GPIO has not. |
| 14 | /// Called only once to initialize the peripheral | 15 | _ = clocks::enable_and_reset::<hal::peripherals::PORT2>(&clocks::periph_helpers::NoConfig); |
| 15 | #[allow(dead_code)] | ||
| 16 | pub unsafe fn init_uart2(p: &hal::pac::Peripherals) { | ||
| 17 | clocks::ensure_frolf_running(p); | ||
| 18 | clocks::enable_uart2_port2(p); | ||
| 19 | reset::release_reset_port2(p); | ||
| 20 | reset::release_reset_lpuart2(p); | ||
| 21 | pins::configure_uart2_pins_port2(); | 16 | pins::configure_uart2_pins_port2(); |
| 22 | clocks::select_uart2_clock(p); | ||
| 23 | } | 17 | } |
| 24 | 18 | ||
| 25 | /// 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. |
| 26 | /// | 20 | pub unsafe fn init_led_gpio_clocks(_p: &hal::pac::Peripherals) { |
| 27 | /// # Safety | 21 | _ = clocks::enable_and_reset::<hal::peripherals::PORT3>(&clocks::periph_helpers::NoConfig); |
| 28 | /// | 22 | _ = clocks::enable_and_reset::<hal::peripherals::GPIO3>(&clocks::periph_helpers::NoConfig); |
| 29 | /// Called only once to initialize the peripheral | ||
| 30 | #[allow(dead_code)] | ||
| 31 | pub unsafe fn init_led(p: &hal::pac::Peripherals) { | ||
| 32 | clocks::enable_led_port(p); | ||
| 33 | reset::release_reset_gpio3(p); | ||
| 34 | reset::release_reset_port3(p); | ||
| 35 | } | ||
| 36 | |||
| 37 | /// Initialize clocks for OSTIMER0 (1 MHz source). | ||
| 38 | /// | ||
| 39 | /// # Safety | ||
| 40 | /// | ||
| 41 | /// Called only once to initialize the peripheral | ||
| 42 | #[allow(dead_code)] | ||
| 43 | pub unsafe fn init_ostimer0(p: &hal::pac::Peripherals) { | ||
| 44 | clocks::ensure_frolf_running(p); | ||
| 45 | clocks::enable_ostimer0(p); | ||
| 46 | reset::release_reset_ostimer0(p); | ||
| 47 | clocks::select_ostimer0_clock_1m(p); | ||
| 48 | } | 23 | } |
| 49 | 24 | ||
| 50 | /// Initialize clocks and pin muxing for ADC. | 25 | /// Initialize clocks and pin muxing for ADC. |
| 51 | /// | 26 | pub unsafe fn init_adc_pins(_p: &hal::pac::Peripherals) { |
| 52 | /// # Safety | 27 | // NOTE: Lpuart has been updated to properly enable + reset its own clocks. |
| 53 | /// | 28 | // GPIO has not. |
| 54 | /// Called only once to initialize the peripheral | 29 | _ = clocks::enable_and_reset::<hal::peripherals::PORT1>(&clocks::periph_helpers::NoConfig); |
| 55 | #[allow(dead_code)] | ||
| 56 | pub unsafe fn init_adc(p: &hal::pac::Peripherals) { | ||
| 57 | clocks::ensure_frolf_running(p); | ||
| 58 | clocks::enable_adc(p); | ||
| 59 | reset::release_reset_port1(p); | ||
| 60 | reset::release_reset_adc1(p); | ||
| 61 | pins::configure_adc_pins(); | 30 | pins::configure_adc_pins(); |
| 62 | clocks::select_adc_clock(p); | ||
| 63 | } | 31 | } |
