aboutsummaryrefslogtreecommitdiff
path: root/examples/src/common/mod.rs
diff options
context:
space:
mode:
authorFelipe Balbi <[email protected]>2025-11-13 13:17:44 -0800
committerGitHub <[email protected]>2025-11-13 13:17:44 -0800
commit77b2c602a60e41c7c977003a6d40367ac285930e (patch)
tree6a6490c883f84658c992af4351b8d8a8d8e1c1e4 /examples/src/common/mod.rs
parentf4b8ae36bec40a15bedd3c0493e4822f9c5238dd (diff)
Move examples to a package of their own (#16)
* Move examples to a package of their own * cargo +nightly fmt * Add missing safety doc * cargo clippy examples * fmt again --------- Co-authored-by: Felipe Balbi <[email protected]>
Diffstat (limited to 'examples/src/common/mod.rs')
-rw-r--r--examples/src/common/mod.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/examples/src/common/mod.rs b/examples/src/common/mod.rs
new file mode 100644
index 000000000..8cb4590f8
--- /dev/null
+++ b/examples/src/common/mod.rs
@@ -0,0 +1,45 @@
1//! Shared board-specific helpers for the FRDM-MCXA276 examples.
2//! These live with the examples so the HAL stays generic.
3
4use hal::{clocks, pins, reset};
5use {embassy_mcxa as hal, panic_probe as _};
6
7/// Initialize clocks and pin muxing for UART2 debug console.
8/// Safe to call multiple times; writes are idempotent for our use.
9#[allow(dead_code)]
10pub unsafe fn init_uart2(p: &hal::pac::Peripherals) {
11 clocks::ensure_frolf_running(p);
12 clocks::enable_uart2_port2(p);
13 reset::release_reset_port2(p);
14 reset::release_reset_lpuart2(p);
15 pins::configure_uart2_pins_port2();
16 clocks::select_uart2_clock(p);
17}
18
19/// Initialize clocks for the LED GPIO/PORT used by the blink example.
20#[allow(dead_code)]
21pub unsafe fn init_led(p: &hal::pac::Peripherals) {
22 clocks::enable_led_port(p);
23 reset::release_reset_gpio3(p);
24 reset::release_reset_port3(p);
25}
26
27/// Initialize clocks for OSTIMER0 (1 MHz source).
28#[allow(dead_code)]
29pub unsafe fn init_ostimer0(p: &hal::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}
35
36/// Initialize clocks and pin muxing for ADC.
37#[allow(dead_code)]
38pub unsafe fn init_adc(p: &hal::pac::Peripherals) {
39 clocks::ensure_frolf_running(p);
40 clocks::enable_adc(p);
41 reset::release_reset_port1(p);
42 reset::release_reset_adc1(p);
43 pins::configure_adc_pins();
44 clocks::select_adc_clock(p);
45}