diff options
| author | Felipe Balbi <[email protected]> | 2025-11-07 10:06:55 -0800 |
|---|---|---|
| committer | Felipe Balbi <[email protected]> | 2025-11-07 10:06:55 -0800 |
| commit | cb2ac2790f4b037056f9571abeb4d62360199426 (patch) | |
| tree | f9f163e4340d11ddc54c24ab8cf7624e83f1fd18 /src/lib.rs | |
| parent | a71eff2e1cea55b393e793c023b8e51e5cc369a1 (diff) | |
Reduce number of features
We don't need features for drivers that always exist.
Signed-off-by: Felipe Balbi <[email protected]>
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 59 |
1 files changed, 18 insertions, 41 deletions
diff --git a/src/lib.rs b/src/lib.rs index eb4727106..518fe01d2 100644 --- a/src/lib.rs +++ b/src/lib.rs | |||
| @@ -1,31 +1,19 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | 2 | ||
| 3 | pub mod clocks; // still provide clock helpers | 3 | pub mod clocks; // still provide clock helpers |
| 4 | #[cfg(feature = "gpio")] | ||
| 5 | pub mod gpio; | 4 | pub mod gpio; |
| 6 | pub mod pins; // pin mux helpers | 5 | pub mod pins; // pin mux helpers |
| 7 | pub mod reset; // reset control helpers | 6 | pub mod reset; // reset control helpers |
| 8 | 7 | ||
| 8 | pub mod adc; | ||
| 9 | pub mod config; | 9 | pub mod config; |
| 10 | pub mod interrupt; | 10 | pub mod interrupt; |
| 11 | pub mod ostimer; | ||
| 12 | pub mod uart; | ||
| 13 | pub mod lpuart; | 11 | pub mod lpuart; |
| 12 | pub mod ostimer; | ||
| 14 | pub mod rtc; | 13 | pub mod rtc; |
| 15 | pub mod adc; | 14 | pub mod uart; |
| 16 | 15 | ||
| 17 | embassy_hal_internal::peripherals!( | 16 | embassy_hal_internal::peripherals!(LPUART2, OSTIMER0, GPIO, RTC0, ADC1,); |
| 18 | #[cfg(feature = "lpuart2")] | ||
| 19 | LPUART2, | ||
| 20 | #[cfg(feature = "ostimer0")] | ||
| 21 | OSTIMER0, | ||
| 22 | #[cfg(feature = "gpio")] | ||
| 23 | GPIO, | ||
| 24 | #[cfg(feature = "rtc0")] | ||
| 25 | RTC0, | ||
| 26 | #[cfg(feature = "adc1")] | ||
| 27 | ADC1, | ||
| 28 | ); | ||
| 29 | 17 | ||
| 30 | /// Get access to the PAC Peripherals for low-level register access. | 18 | /// Get access to the PAC Peripherals for low-level register access. |
| 31 | /// This is a lazy-initialized singleton that can be called after init(). | 19 | /// This is a lazy-initialized singleton that can be called after init(). |
| @@ -42,43 +30,32 @@ pub fn pac() -> &'static pac::Peripherals { | |||
| 42 | } | 30 | } |
| 43 | } | 31 | } |
| 44 | 32 | ||
| 45 | pub use cortex_m_rt; | 33 | #[cfg(feature = "unstable-pac")] |
| 46 | pub use mcxa276_pac as pac; | 34 | pub use mcxa_pac as pac; |
| 35 | #[cfg(not(feature = "unstable-pac"))] | ||
| 36 | pub(crate) use mcxa_pac as pac; | ||
| 37 | |||
| 47 | // Use cortex-m-rt's #[interrupt] attribute directly; PAC does not re-export it. | 38 | // Use cortex-m-rt's #[interrupt] attribute directly; PAC does not re-export it. |
| 48 | 39 | ||
| 49 | // Re-export interrupt traits and types | 40 | // Re-export interrupt traits and types |
| 41 | pub use adc::Adc1 as Adc1Token; | ||
| 42 | pub use gpio::{AnyPin, Flex, Gpio as GpioToken, Input, Level, Output, pins::*}; | ||
| 50 | pub use interrupt::InterruptExt; | 43 | pub use interrupt::InterruptExt; |
| 51 | #[cfg(feature = "ostimer0")] | ||
| 52 | pub use ostimer::Ostimer0 as Ostimer0Token; | 44 | pub use ostimer::Ostimer0 as Ostimer0Token; |
| 53 | #[cfg(feature = "lpuart2")] | ||
| 54 | pub use uart::Lpuart2 as Uart2Token; | ||
| 55 | #[cfg(feature = "rtc0")] | ||
| 56 | pub use rtc::Rtc0 as Rtc0Token; | 45 | pub use rtc::Rtc0 as Rtc0Token; |
| 57 | #[cfg(feature = "adc1")] | 46 | pub use uart::Lpuart2 as Uart2Token; |
| 58 | pub use adc::Adc1 as Adc1Token; | ||
| 59 | #[cfg(feature = "gpio")] | ||
| 60 | pub use gpio::{pins::*, AnyPin, Flex, Gpio as GpioToken, Input, Level, Output}; | ||
| 61 | 47 | ||
| 62 | /// 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. |
| 63 | /// 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). |
| 64 | #[allow(unused_variables)] | 50 | #[allow(unused_variables)] |
| 65 | pub fn init(cfg: crate::config::Config) -> Peripherals { | 51 | pub fn init(cfg: crate::config::Config) -> Peripherals { |
| 66 | let peripherals = Peripherals::take(); | 52 | let peripherals = Peripherals::take(); |
| 67 | #[cfg(feature = "ostimer0")] | 53 | // Apply user-configured priority early; enabling is left to examples/apps |
| 68 | { | 54 | crate::interrupt::OS_EVENT.set_priority(cfg.time_interrupt_priority); |
| 69 | // Apply user-configured priority early; enabling is left to examples/apps | 55 | // Apply user-configured priority early; enabling is left to examples/apps |
| 70 | crate::interrupt::OS_EVENT.set_priority(cfg.time_interrupt_priority); | 56 | crate::interrupt::RTC.set_priority(cfg.rtc_interrupt_priority); |
| 71 | } | 57 | // Apply user-configured priority early; enabling is left to examples/apps |
| 72 | #[cfg(feature = "rtc0")] | 58 | crate::interrupt::ADC1.set_priority(cfg.adc_interrupt_priority); |
| 73 | { | ||
| 74 | // Apply user-configured priority early; enabling is left to examples/apps | ||
| 75 | crate::interrupt::RTC.set_priority(cfg.rtc_interrupt_priority); | ||
| 76 | } | ||
| 77 | #[cfg(feature = "adc1")] | ||
| 78 | { | ||
| 79 | // Apply user-configured priority early; enabling is left to examples/apps | ||
| 80 | crate::interrupt::ADC1.set_priority(cfg.adc_interrupt_priority); | ||
| 81 | } | ||
| 82 | peripherals | 59 | peripherals |
| 83 | } | 60 | } |
| 84 | 61 | ||
