894: rp: GPIO fixes r=Dirbaio a=Dirbaio



Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This commit is contained in:
bors[bot] 2022-08-08 10:49:51 +00:00 committed by GitHub
commit b400e6aa75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,27 +85,27 @@ impl<'d, T: Pin> Input<'d, T> {
} }
#[inline] #[inline]
pub async fn wait_for_high<'a>(&mut self) { pub async fn wait_for_high(&mut self) {
self.pin.wait_for_high().await; self.pin.wait_for_high().await;
} }
#[inline] #[inline]
pub async fn wait_for_low<'a>(&mut self) { pub async fn wait_for_low(&mut self) {
self.pin.wait_for_low().await; self.pin.wait_for_low().await;
} }
#[inline] #[inline]
pub async fn wait_for_rising_edge<'a>(&mut self) { pub async fn wait_for_rising_edge(&mut self) {
self.pin.wait_for_rising_edge().await; self.pin.wait_for_rising_edge().await;
} }
#[inline] #[inline]
pub async fn wait_for_falling_edge<'a>(&mut self) { pub async fn wait_for_falling_edge(&mut self) {
self.pin.wait_for_falling_edge().await; self.pin.wait_for_falling_edge().await;
} }
#[inline] #[inline]
pub async fn wait_for_any_edge<'a>(&mut self) { pub async fn wait_for_any_edge(&mut self) {
self.pin.wait_for_any_edge().await; self.pin.wait_for_any_edge().await;
} }
} }
@ -152,7 +152,8 @@ unsafe fn IO_IRQ_BANK0() {
let event = (intsx.read().0 >> pin_group * 4) & 0xf as u32; let event = (intsx.read().0 >> pin_group * 4) & 0xf as u32;
if let Some(trigger) = InterruptTrigger::from_u32(event) { if let Some(trigger) = InterruptTrigger::from_u32(event) {
proc_intx.inte(pin / 8).write(|w| match trigger { critical_section::with(|_| {
proc_intx.inte(pin / 8).modify(|w| match trigger {
InterruptTrigger::AnyEdge => { InterruptTrigger::AnyEdge => {
w.set_edge_high(pin_group, false); w.set_edge_high(pin_group, false);
w.set_edge_low(pin_group, false); w.set_edge_low(pin_group, false);
@ -171,6 +172,7 @@ unsafe fn IO_IRQ_BANK0() {
w.set_edge_low(pin_group, false); w.set_edge_low(pin_group, false);
} }
}); });
});
INTERRUPT_WAKERS[pin as usize].wake(); INTERRUPT_WAKERS[pin as usize].wake();
} }
} }
@ -193,7 +195,8 @@ impl<'d, T: Pin> InputFuture<'d, T> {
// pin, and each group consists of LEVEL_LOW, LEVEL_HIGH, EDGE_LOW, // pin, and each group consists of LEVEL_LOW, LEVEL_HIGH, EDGE_LOW,
// and EGDE_HIGH. // and EGDE_HIGH.
let pin_group = (pin.pin() % 8) as usize; let pin_group = (pin.pin() % 8) as usize;
pin.int_proc().inte((pin.pin() / 8) as usize).write(|w| match level { critical_section::with(|_| {
pin.int_proc().inte((pin.pin() / 8) as usize).modify(|w| match level {
InterruptTrigger::LevelHigh => { InterruptTrigger::LevelHigh => {
debug!("InputFuture::new enable LevelHigh for pin {} \n", pin.pin()); debug!("InputFuture::new enable LevelHigh for pin {} \n", pin.pin());
w.set_level_high(pin_group, true); w.set_level_high(pin_group, true);
@ -211,6 +214,7 @@ impl<'d, T: Pin> InputFuture<'d, T> {
// noop // noop
} }
}); });
});
irq.enable(); irq.enable();
} }
@ -545,29 +549,29 @@ impl<'d, T: Pin> Flex<'d, T> {
} }
#[inline] #[inline]
pub async fn wait_for_high<'a>(&mut self) { pub async fn wait_for_high(&mut self) {
InputFuture::new(&mut self.pin, InterruptTrigger::LevelHigh).await; InputFuture::new(&mut self.pin, InterruptTrigger::LevelHigh).await;
} }
#[inline] #[inline]
pub async fn wait_for_low<'a>(&mut self) { pub async fn wait_for_low(&mut self) {
InputFuture::new(&mut self.pin, InterruptTrigger::LevelLow).await; InputFuture::new(&mut self.pin, InterruptTrigger::LevelLow).await;
} }
#[inline] #[inline]
pub async fn wait_for_rising_edge<'a>(&mut self) { pub async fn wait_for_rising_edge(&mut self) {
self.wait_for_low().await; self.wait_for_low().await;
self.wait_for_high().await; self.wait_for_high().await;
} }
#[inline] #[inline]
pub async fn wait_for_falling_edge<'a>(&mut self) { pub async fn wait_for_falling_edge(&mut self) {
self.wait_for_high().await; self.wait_for_high().await;
self.wait_for_low().await; self.wait_for_low().await;
} }
#[inline] #[inline]
pub async fn wait_for_any_edge<'a>(&mut self) { pub async fn wait_for_any_edge(&mut self) {
if self.is_high() { if self.is_high() {
self.wait_for_low().await; self.wait_for_low().await;
} else { } else {