diff options
Diffstat (limited to 'embassy-mcxa')
| -rw-r--r-- | embassy-mcxa/src/adc.rs | 12 |
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}; | |||
| 18 | use crate::pac::adc1::ctrl::CalAvgs; | 18 | use crate::pac::adc1::ctrl::CalAvgs; |
| 19 | use crate::pac::adc1::tctrl::{Tcmd, Tpri}; | 19 | use crate::pac::adc1::tctrl::{Tcmd, Tpri}; |
| 20 | 20 | ||
| 21 | /// Global wait cell for alarm notifications | ||
| 22 | static WAKER: WaitCell = WaitCell::new(); | ||
| 23 | 21 | ||
| 24 | const G_LPADC_RESULT_SHIFT: u32 = 0; | 22 | const 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> { | |||
| 547 | impl<T: Instance> Handler<T::Interrupt> for InterruptHandler<T> { | 545 | impl<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 | ||
| 561 | trait SealedInstance { | 559 | trait 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>] { |
