aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJames Munns <[email protected]>2025-11-18 14:19:09 +0100
committerGitHub <[email protected]>2025-11-18 14:19:09 +0100
commit5b1149a52dbec9e3bdd10dc341dc0751ab4798a6 (patch)
tree3ff7098471cf660a54a707464a0e2feb2080b09e /src/lib.rs
parent62e297c130ac26afe4d7d5752bb79709bd370e39 (diff)
parentc8942aec2478ff077b55da0e86801f8a6a88a7de (diff)
Merge pull request #11 from jamesmunns/james/impl-clocks
Implement initial `clock` driver. This PR introduces an initial two-phase clock driver system: 1. The first stage is responsible for initializing the core/system clocks at the time of `embassy_mcxa::init()` 2. The second stage is done on creation of peripherals This work is limited to currently used clocks and peripherals, but has room for expansion for later peripherals. This model is based on the preliminary refactoring performed for the `embassy-imxrt` crate.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 4e5ac0109..86c0dc45b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,7 +6,6 @@
6pub mod clocks; // still provide clock helpers 6pub mod clocks; // still provide clock helpers
7pub mod gpio; 7pub mod gpio;
8pub mod pins; // pin mux helpers 8pub mod pins; // pin mux helpers
9pub mod reset; // reset control helpers
10 9
11pub mod adc; 10pub mod adc;
12pub mod config; 11pub mod config;
@@ -14,9 +13,8 @@ pub mod interrupt;
14pub mod lpuart; 13pub mod lpuart;
15pub mod ostimer; 14pub mod ostimer;
16pub mod rtc; 15pub mod rtc;
17pub mod uart;
18 16
19embassy_hal_internal::peripherals!(LPUART2, OSTIMER0, GPIO, RTC0, ADC1,); 17embassy_hal_internal::peripherals!(PORT1, PORT2, PORT3, LPUART2, OSTIMER0, GPIO, PIO2_2, PIO2_3, GPIO3, RTC0, ADC1,);
20 18
21/// Get access to the PAC Peripherals for low-level register access. 19/// Get access to the PAC Peripherals for low-level register access.
22/// This is a lazy-initialized singleton that can be called after init(). 20/// This is a lazy-initialized singleton that can be called after init().
@@ -46,11 +44,9 @@ pub use mcxa_pac as pac;
46pub(crate) use mcxa_pac as pac; 44pub(crate) use mcxa_pac as pac;
47pub use ostimer::Ostimer0 as Ostimer0Token; 45pub use ostimer::Ostimer0 as Ostimer0Token;
48pub use rtc::Rtc0 as Rtc0Token; 46pub use rtc::Rtc0 as Rtc0Token;
49pub use uart::Lpuart2 as Uart2Token;
50 47
51/// Initialize HAL with configuration (mirrors embassy-imxrt style). Minimal: just take peripherals. 48/// Initialize HAL with configuration (mirrors embassy-imxrt style). Minimal: just take peripherals.
52/// Also applies configurable NVIC priority for the OSTIMER OS_EVENT interrupt (no enabling). 49/// Also applies configurable NVIC priority for the OSTIMER OS_EVENT interrupt (no enabling).
53#[allow(unused_variables)]
54pub fn init(cfg: crate::config::Config) -> Peripherals { 50pub fn init(cfg: crate::config::Config) -> Peripherals {
55 let peripherals = Peripherals::take(); 51 let peripherals = Peripherals::take();
56 // Apply user-configured priority early; enabling is left to examples/apps 52 // Apply user-configured priority early; enabling is left to examples/apps
@@ -59,6 +55,10 @@ pub fn init(cfg: crate::config::Config) -> Peripherals {
59 crate::interrupt::RTC.set_priority(cfg.rtc_interrupt_priority); 55 crate::interrupt::RTC.set_priority(cfg.rtc_interrupt_priority);
60 // Apply user-configured priority early; enabling is left to examples/apps 56 // Apply user-configured priority early; enabling is left to examples/apps
61 crate::interrupt::ADC1.set_priority(cfg.adc_interrupt_priority); 57 crate::interrupt::ADC1.set_priority(cfg.adc_interrupt_priority);
58
59 // Configure clocks
60 crate::clocks::init(cfg.clock_cfg).unwrap();
61
62 peripherals 62 peripherals
63} 63}
64 64