aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorFelipe Balbi <[email protected]>2025-11-07 10:06:55 -0800
committerFelipe Balbi <[email protected]>2025-11-07 10:06:55 -0800
commitcb2ac2790f4b037056f9571abeb4d62360199426 (patch)
treef9f163e4340d11ddc54c24ab8cf7624e83f1fd18 /src/lib.rs
parenta71eff2e1cea55b393e793c023b8e51e5cc369a1 (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.rs59
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
3pub mod clocks; // still provide clock helpers 3pub mod clocks; // still provide clock helpers
4#[cfg(feature = "gpio")]
5pub mod gpio; 4pub mod gpio;
6pub mod pins; // pin mux helpers 5pub mod pins; // pin mux helpers
7pub mod reset; // reset control helpers 6pub mod reset; // reset control helpers
8 7
8pub mod adc;
9pub mod config; 9pub mod config;
10pub mod interrupt; 10pub mod interrupt;
11pub mod ostimer;
12pub mod uart;
13pub mod lpuart; 11pub mod lpuart;
12pub mod ostimer;
14pub mod rtc; 13pub mod rtc;
15pub mod adc; 14pub mod uart;
16 15
17embassy_hal_internal::peripherals!( 16embassy_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
45pub use cortex_m_rt; 33#[cfg(feature = "unstable-pac")]
46pub use mcxa276_pac as pac; 34pub use mcxa_pac as pac;
35#[cfg(not(feature = "unstable-pac"))]
36pub(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
41pub use adc::Adc1 as Adc1Token;
42pub use gpio::{AnyPin, Flex, Gpio as GpioToken, Input, Level, Output, pins::*};
50pub use interrupt::InterruptExt; 43pub use interrupt::InterruptExt;
51#[cfg(feature = "ostimer0")]
52pub use ostimer::Ostimer0 as Ostimer0Token; 44pub use ostimer::Ostimer0 as Ostimer0Token;
53#[cfg(feature = "lpuart2")]
54pub use uart::Lpuart2 as Uart2Token;
55#[cfg(feature = "rtc0")]
56pub use rtc::Rtc0 as Rtc0Token; 45pub use rtc::Rtc0 as Rtc0Token;
57#[cfg(feature = "adc1")] 46pub use uart::Lpuart2 as Uart2Token;
58pub use adc::Adc1 as Adc1Token;
59#[cfg(feature = "gpio")]
60pub 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)]
65pub fn init(cfg: crate::config::Config) -> Peripherals { 51pub 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