aboutsummaryrefslogtreecommitdiff
path: root/examples/src/lib.rs
blob: be4761c3206a58fc3c3ec9410fa9d50a68595fa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#![no_std]
#![allow(clippy::missing_safety_doc)]

//! Shared board-specific helpers for the FRDM-MCXA276 examples.
//! These live with the examples so the HAL stays generic.

use hal::{clocks, pins};
use {embassy_mcxa as hal, panic_probe as _};

/// Initialize clocks and pin muxing for UART2 debug console.
/// Safe to call multiple times; writes are idempotent for our use.
pub unsafe fn init_uart2_pins(_p: &hal::pac::Peripherals) {
    // NOTE: Lpuart has been updated to properly enable + reset its own clocks.
    // GPIO has not.
    _ = clocks::enable_and_reset::<hal::peripherals::PORT2>(&clocks::NoConfig);
    pins::configure_uart2_pins_port2();
}

/// Initialize clocks for the LED GPIO/PORT used by the blink example.
pub unsafe fn init_led_gpio_clocks(_p: &hal::pac::Peripherals) {
    _ = clocks::enable_and_reset::<hal::peripherals::PORT3>(&clocks::NoConfig);
    _ = clocks::enable_and_reset::<hal::peripherals::GPIO3>(&clocks::NoConfig);
}

/// Initialize clocks and pin muxing for ADC.
pub unsafe fn init_adc_pins(_p: &hal::pac::Peripherals) {
    // NOTE: Lpuart has been updated to properly enable + reset its own clocks.
    // GPIO has not.
    _ = clocks::enable_and_reset::<hal::peripherals::PORT1>(&clocks::NoConfig);
    pins::configure_adc_pins();
}