diff options
| author | MathisDerooNXP <[email protected]> | 2025-11-26 10:05:16 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-26 10:05:16 -0800 |
| commit | d12bc9785399991065e511efbea34f0138c7645e (patch) | |
| tree | 47472365383c3a5ad5d4ab0495e655a3418477d9 /src/lib.rs | |
| parent | 1efaaa4025120413ec17de90106244445208804a (diff) | |
Add GPIO interrupt support and embedded-hal-async trait implementation (#38)
* Add GPIO interrupt support and embedded-hal-async trait implementation
Signed-off-by: Mathis Deroo <[email protected]>
* Run cargo fmt
* Improve GPIO driver interrupt mechanism and example
- GPIO interrupt managed internally at the HAL level,
- Renamed and cleaned gpio_interrupt example; now button_async.rs,
- Use BitIter instead of simple for loop in the irq handler,
- Fix comments and add "rt" wrappen to GPIO IRQ handler.
Signed-off-by: Mathis Deroo <[email protected]>
* Modify INTERRUPT_DETECTED (AtomicBool to AtomicU32) to work with pin number and not only port number interrupt
Signed-off-by: Mathis Deroo <[email protected]>
* add embedded_hal_async::digital::* traits
Signed-off-by: Mathis Deroo <[email protected]>
* Update irq_handler with BitIter loop
Co-authored-by: Felipe Balbi <[email protected]>
* Add suggested changes
Signed-off-by: Mathis Deroo <[email protected]>
* cargo fmt
Signed-off-by: Felipe Balbi <[email protected]>
* WIP: Modify Wakers from AtomicWaker to WaitMap, with pin number (per PORT) as key
Signed-off-by: Mathis Deroo <[email protected]>
* Tweak maitake-sync usage
* Improve docs
* refactor a bit
* Move all of the async+interrupt stuff into a module
* Remove defmt debug traces
Signed-off-by: Mathis Deroo <[email protected]>
* cargo vet
* Move e-hal-async impls into the gated block
* "rt", begone!
---------
Signed-off-by: Mathis Deroo <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
Co-authored-by: Felipe Balbi <[email protected]>
Co-authored-by: Felipe Balbi <[email protected]>
Co-authored-by: Felipe Balbi <[email protected]>
Co-authored-by: James Munns <[email protected]>
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs index 7fccc86c5..fb204d27b 100644 --- a/src/lib.rs +++ b/src/lib.rs | |||
| @@ -18,7 +18,6 @@ pub mod lpuart; | |||
| 18 | pub mod ostimer; | 18 | pub mod ostimer; |
| 19 | pub mod rtc; | 19 | pub mod rtc; |
| 20 | 20 | ||
| 21 | #[cfg(feature = "rt")] | ||
| 22 | pub use crate::pac::NVIC_PRIO_BITS; | 21 | pub use crate::pac::NVIC_PRIO_BITS; |
| 23 | 22 | ||
| 24 | #[rustfmt::skip] | 23 | #[rustfmt::skip] |
| @@ -347,10 +346,24 @@ pub fn init(cfg: crate::config::Config) -> Peripherals { | |||
| 347 | crate::interrupt::RTC.set_priority(cfg.rtc_interrupt_priority); | 346 | crate::interrupt::RTC.set_priority(cfg.rtc_interrupt_priority); |
| 348 | // Apply user-configured priority early; enabling is left to examples/apps | 347 | // Apply user-configured priority early; enabling is left to examples/apps |
| 349 | crate::interrupt::ADC1.set_priority(cfg.adc_interrupt_priority); | 348 | crate::interrupt::ADC1.set_priority(cfg.adc_interrupt_priority); |
| 349 | // Apply user-configured priority early; enabling is left to examples/apps | ||
| 350 | crate::interrupt::GPIO0.set_priority(cfg.gpio_interrupt_priority); | ||
| 351 | // Apply user-configured priority early; enabling is left to examples/apps | ||
| 352 | crate::interrupt::GPIO1.set_priority(cfg.gpio_interrupt_priority); | ||
| 353 | // Apply user-configured priority early; enabling is left to examples/apps | ||
| 354 | crate::interrupt::GPIO2.set_priority(cfg.gpio_interrupt_priority); | ||
| 355 | // Apply user-configured priority early; enabling is left to examples/apps | ||
| 356 | crate::interrupt::GPIO3.set_priority(cfg.gpio_interrupt_priority); | ||
| 357 | // Apply user-configured priority early; enabling is left to examples/apps | ||
| 358 | crate::interrupt::GPIO4.set_priority(cfg.gpio_interrupt_priority); | ||
| 350 | 359 | ||
| 351 | // Configure clocks | 360 | // Configure clocks |
| 352 | crate::clocks::init(cfg.clock_cfg).unwrap(); | 361 | crate::clocks::init(cfg.clock_cfg).unwrap(); |
| 353 | 362 | ||
| 363 | unsafe { | ||
| 364 | crate::gpio::init(); | ||
| 365 | } | ||
| 366 | |||
| 354 | // Initialize embassy-time global driver backed by OSTIMER0 | 367 | // Initialize embassy-time global driver backed by OSTIMER0 |
| 355 | #[cfg(feature = "time")] | 368 | #[cfg(feature = "time")] |
| 356 | crate::ostimer::time_driver::init(crate::config::Config::default().time_interrupt_priority, 1_000_000); | 369 | crate::ostimer::time_driver::init(crate::config::Config::default().time_interrupt_priority, 1_000_000); |
