nrf/gpiote: fix port1 on nrf5340

This commit is contained in:
Dario Nieuwenhuis 2024-06-25 22:28:38 +02:00
parent cab17434d5
commit 292dbcc991

View file

@ -19,9 +19,9 @@ const CHANNEL_COUNT: usize = 4;
/// Amount of GPIOTE channels in the chip.
const CHANNEL_COUNT: usize = 8;
#[cfg(any(feature = "nrf52833", feature = "nrf52840"))]
#[cfg(any(feature = "nrf52833", feature = "nrf52840", feature = "_nrf5340"))]
const PIN_COUNT: usize = 48;
#[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))]
#[cfg(not(any(feature = "nrf52833", feature = "nrf52840", feature = "_nrf5340")))]
const PIN_COUNT: usize = 32;
#[allow(clippy::declare_interior_mutable_const)]
@ -67,9 +67,9 @@ pub(crate) fn init(irq_prio: crate::interrupt::Priority) {
// no latched GPIO detect in nrf51.
#[cfg(not(feature = "_nrf51"))]
{
#[cfg(any(feature = "nrf52833", feature = "nrf52840"))]
#[cfg(any(feature = "nrf52833", feature = "nrf52840", feature = "_nrf5340"))]
let ports = unsafe { &[&*pac::P0::ptr(), &*pac::P1::ptr()] };
#[cfg(not(any(feature = "_nrf51", feature = "nrf52833", feature = "nrf52840")))]
#[cfg(not(any(feature = "_nrf51", feature = "nrf52833", feature = "nrf52840", feature = "_nrf5340")))]
let ports = unsafe { &[&*pac::P0::ptr()] };
for &p in ports {
@ -130,9 +130,9 @@ unsafe fn handle_gpiote_interrupt() {
if g.events_port.read().bits() != 0 {
g.events_port.write(|w| w);
#[cfg(any(feature = "nrf52833", feature = "nrf52840"))]
#[cfg(any(feature = "nrf52833", feature = "nrf52840", feature = "_nrf5340"))]
let ports = &[&*pac::P0::ptr(), &*pac::P1::ptr()];
#[cfg(not(any(feature = "_nrf51", feature = "nrf52833", feature = "nrf52840")))]
#[cfg(not(any(feature = "_nrf51", feature = "nrf52833", feature = "nrf52840", feature = "_nrf5340")))]
let ports = &[&*pac::P0::ptr()];
#[cfg(feature = "_nrf51")]
let ports = unsafe { &[&*pac::GPIO::ptr()] };
@ -214,7 +214,7 @@ impl<'d> InputChannel<'d> {
InputChannelPolarity::None => w.mode().event().polarity().none(),
InputChannelPolarity::Toggle => w.mode().event().polarity().toggle(),
};
#[cfg(any(feature = "nrf52833", feature = "nrf52840"))]
#[cfg(any(feature = "nrf52833", feature = "nrf52840", feature = "_nrf5340"))]
w.port().bit(match pin.pin.pin.port() {
crate::gpio::Port::Port0 => false,
crate::gpio::Port::Port1 => true,
@ -288,7 +288,7 @@ impl<'d> OutputChannel<'d> {
OutputChannelPolarity::Clear => w.polarity().hi_to_lo(),
OutputChannelPolarity::Toggle => w.polarity().toggle(),
};
#[cfg(any(feature = "nrf52833", feature = "nrf52840"))]
#[cfg(any(feature = "nrf52833", feature = "nrf52840", feature = "_nrf5340"))]
w.port().bit(match pin.pin.pin.port() {
crate::gpio::Port::Port0 => false,
crate::gpio::Port::Port1 => true,