Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: GPIOTE does not set the port of a pin #216

Closed
trembel opened this issue Sep 10, 2020 · 0 comments · Fixed by #217
Closed

Bug: GPIOTE does not set the port of a pin #216

trembel opened this issue Sep 10, 2020 · 0 comments · Fixed by #217
Labels
bug Something isn't working

Comments

@trembel
Copy link
Contributor

trembel commented Sep 10, 2020

unsafe { w.psel().bits(pin.pin()) }

Summary

Trying to use GPIOTE on the nrf dongle for catching a button interrupt (p1.06) and changing the state of the led (p0.06) the nrf dongle got stuck. Other pin combinations worked.

Steps to Reproduce

#![no_main]
#![no_std]

use nrf52840_hal as hal;

use hal::gpio::{p0, p1};
use hal::gpio::Level;
use hal::gpiote::Gpiote;
use hal::prelude::*;

use core::panic::PanicInfo;
use cortex_m::asm;

#[cortex_m_rt::entry]
fn main() -> ! {
    let p = hal::pac::Peripherals::take().unwrap();

    let port0 = p0::Parts::new(p.P0);
    let port1 = p1::Parts::new(p.P1);
    
    let mut led = port0.p0_06.into_push_pull_output(Level::Low).degrade();
    let button = port1.p1_06.into_pullup_input().degrade();
    

    let gpiote = Gpiote::new(p.GPIOTE);
    gpiote
        .channel0()
        .input_pin(&button)
        .hi_to_lo()
        .enable_interrupt();

    led.set_low().unwrap();
    loop {
        continue;
    }
}

#[panic_handler]
fn panic(_: &PanicInfo) -> ! {
    loop {
        continue;
    }
}

Additional Debug Information

According to @Dirbaio there is a bug in gpiote.rs L260 (https://github.com/nrf-rs/nrf-hal/blob/master/nrf-hal-common/src/gpiote.rs#L260) where only the pin but not the port is being set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants