diff options
Diffstat (limited to 'examples/src/lib.rs')
| -rw-r--r-- | examples/src/lib.rs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/examples/src/lib.rs b/examples/src/lib.rs new file mode 100644 index 000000000..cf4194559 --- /dev/null +++ b/examples/src/lib.rs | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | #![no_std] | ||
| 2 | |||
| 3 | //! Shared board-specific helpers for the FRDM-MCXA276 examples. | ||
| 4 | //! These live with the examples so the HAL stays generic. | ||
| 5 | |||
| 6 | use hal::{clocks, pins, reset}; | ||
| 7 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; | ||
| 8 | |||
| 9 | /// Initialize clocks and pin muxing for UART2 debug console. | ||
| 10 | /// Safe to call multiple times; writes are idempotent for our use. | ||
| 11 | /// | ||
| 12 | /// # Safety | ||
| 13 | /// | ||
| 14 | /// Called only once to initialize the peripheral | ||
| 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(); | ||
| 22 | clocks::select_uart2_clock(p); | ||
| 23 | } | ||
| 24 | |||
| 25 | /// Initialize clocks for the LED GPIO/PORT used by the blink example. | ||
| 26 | /// | ||
| 27 | /// # Safety | ||
| 28 | /// | ||
| 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 | } | ||
| 49 | |||
| 50 | /// Initialize clocks and pin muxing for ADC. | ||
| 51 | /// | ||
| 52 | /// # Safety | ||
| 53 | /// | ||
| 54 | /// Called only once to initialize the peripheral | ||
| 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(); | ||
| 62 | clocks::select_adc_clock(p); | ||
| 63 | } | ||
