aboutsummaryrefslogtreecommitdiff
path: root/embassy-mcxa
diff options
context:
space:
mode:
authorMathis Deroo <[email protected]>2025-12-08 13:40:59 -0800
committerMathis Deroo <[email protected]>2025-12-09 10:52:10 -0800
commite39040afc7ee4080a1d3559d0b7d578420301726 (patch)
treef4a41138c6877c7d68a964362c9df3a183e439bf /embassy-mcxa
parent0da28a271816b319c142254cb3598fd14096813a (diff)
Implement WaitCell per ADC instance
Signed-off-by: Mathis Deroo <[email protected]>
Diffstat (limited to 'embassy-mcxa')
-rw-r--r--embassy-mcxa/src/adc.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/embassy-mcxa/src/adc.rs b/embassy-mcxa/src/adc.rs
index c2ea06e89..94d945c88 100644
--- a/embassy-mcxa/src/adc.rs
+++ b/embassy-mcxa/src/adc.rs
@@ -18,8 +18,6 @@ use crate::pac::adc1::cmdl1::{Adch, Ctype, Mode};
18use crate::pac::adc1::ctrl::CalAvgs; 18use crate::pac::adc1::ctrl::CalAvgs;
19use crate::pac::adc1::tctrl::{Tcmd, Tpri}; 19use crate::pac::adc1::tctrl::{Tcmd, Tpri};
20 20
21/// Global wait cell for alarm notifications
22static WAKER: WaitCell = WaitCell::new();
23 21
24const G_LPADC_RESULT_SHIFT: u32 = 0; 22const G_LPADC_RESULT_SHIFT: u32 = 0;
25 23
@@ -532,7 +530,7 @@ impl<'a, I: Instance> Adc<'a, I> {
532 /// # Returns 530 /// # Returns
533 /// 16-bit ADC conversion value 531 /// 16-bit ADC conversion value
534 pub async fn read(&mut self) -> u16 { 532 pub async fn read(&mut self) -> u16 {
535 let wait = WAKER.subscribe().await; 533 let wait = I::wait_cell().subscribe().await;
536 534
537 self.enable_interrupt(0x1); 535 self.enable_interrupt(0x1);
538 self.do_software_trigger(1); 536 self.do_software_trigger(1);
@@ -547,7 +545,7 @@ impl<'a, I: Instance> Adc<'a, I> {
547impl<T: Instance> Handler<T::Interrupt> for InterruptHandler<T> { 545impl<T: Instance> Handler<T::Interrupt> for InterruptHandler<T> {
548 unsafe fn on_interrupt() { 546 unsafe fn on_interrupt() {
549 T::ptr().ie().modify(|r, w| w.bits(r.bits() & !0x1)); 547 T::ptr().ie().modify(|r, w| w.bits(r.bits() & !0x1));
550 WAKER.wake(); 548 T::wait_cell().wake();
551 } 549 }
552} 550}
553 551
@@ -560,6 +558,7 @@ impl<I: GpioPin> sealed::Sealed for I {}
560 558
561trait SealedInstance { 559trait SealedInstance {
562 fn ptr() -> &'static pac::adc0::RegisterBlock; 560 fn ptr() -> &'static pac::adc0::RegisterBlock;
561 fn wait_cell() -> &'static WaitCell;
563} 562}
564 563
565/// ADC Instance 564/// ADC Instance
@@ -578,6 +577,11 @@ macro_rules! impl_instance {
578 unsafe { &*pac::[<Adc $n>]::ptr() } 577 unsafe { &*pac::[<Adc $n>]::ptr() }
579 } 578 }
580 579
580 fn wait_cell() -> &'static WaitCell {
581 static WAIT_CELL: WaitCell = WaitCell::new();
582 &WAIT_CELL
583 }
584
581 } 585 }
582 586
583 impl Instance for crate::peripherals::[<ADC $n>] { 587 impl Instance for crate::peripherals::[<ADC $n>] {