Make sure to enable the GPIO interrupt (#1394)

* Make sure to enable the GPIO interrupt

* Refactor GPIO constructors
This commit is contained in:
Björn Quentin 2024-04-04 13:24:38 +02:00 committed by GitHub
parent 839a3ba62b
commit bd9808827f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1795,8 +1795,20 @@ pub struct IO {
impl IO {
/// Initialize the I/O driver.
pub fn new(mut gpio: GPIO, io_mux: IO_MUX) -> Self {
pub fn new(gpio: GPIO, io_mux: IO_MUX) -> Self {
Self::new_with_priority(gpio, io_mux, crate::interrupt::Priority::min())
}
/// Initialize the I/O driver with a interrupt priority.
///
/// This decides the priority for the interrupt when using async.
pub fn new_with_priority(
mut gpio: GPIO,
io_mux: IO_MUX,
prio: crate::interrupt::Priority,
) -> Self {
gpio.bind_gpio_interrupt(gpio_interrupt_handler);
crate::interrupt::enable(crate::peripherals::Interrupt::GPIO, prio).unwrap();
let pins = gpio.split();
@ -1806,15 +1818,6 @@ impl IO {
}
}
/// Initialize the I/O driver with a interrupt priority.
///
/// This decides the priority for the interrupt when only using async.
pub fn new_with_priority(gpio: GPIO, io_mux: IO_MUX, prio: crate::interrupt::Priority) -> Self {
crate::interrupt::enable(crate::peripherals::Interrupt::GPIO, prio).unwrap();
Self::new(gpio, io_mux)
}
/// Install the given interrupt handler replacing any previously set
/// handler.
///