diff options
| author | James Munns <[email protected]> | 2025-11-18 14:19:09 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-18 14:19:09 +0100 |
| commit | 5b1149a52dbec9e3bdd10dc341dc0751ab4798a6 (patch) | |
| tree | 3ff7098471cf660a54a707464a0e2feb2080b09e /src/lib.rs | |
| parent | 62e297c130ac26afe4d7d5752bb79709bd370e39 (diff) | |
| parent | c8942aec2478ff077b55da0e86801f8a6a88a7de (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.rs | 10 |
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 @@ | |||
| 6 | pub mod clocks; // still provide clock helpers | 6 | pub mod clocks; // still provide clock helpers |
| 7 | pub mod gpio; | 7 | pub mod gpio; |
| 8 | pub mod pins; // pin mux helpers | 8 | pub mod pins; // pin mux helpers |
| 9 | pub mod reset; // reset control helpers | ||
| 10 | 9 | ||
| 11 | pub mod adc; | 10 | pub mod adc; |
| 12 | pub mod config; | 11 | pub mod config; |
| @@ -14,9 +13,8 @@ pub mod interrupt; | |||
| 14 | pub mod lpuart; | 13 | pub mod lpuart; |
| 15 | pub mod ostimer; | 14 | pub mod ostimer; |
| 16 | pub mod rtc; | 15 | pub mod rtc; |
| 17 | pub mod uart; | ||
| 18 | 16 | ||
| 19 | embassy_hal_internal::peripherals!(LPUART2, OSTIMER0, GPIO, RTC0, ADC1,); | 17 | embassy_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; | |||
| 46 | pub(crate) use mcxa_pac as pac; | 44 | pub(crate) use mcxa_pac as pac; |
| 47 | pub use ostimer::Ostimer0 as Ostimer0Token; | 45 | pub use ostimer::Ostimer0 as Ostimer0Token; |
| 48 | pub use rtc::Rtc0 as Rtc0Token; | 46 | pub use rtc::Rtc0 as Rtc0Token; |
| 49 | pub 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)] | ||
| 54 | pub fn init(cfg: crate::config::Config) -> Peripherals { | 50 | pub 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 | ||
