Skip to content

Commit 901e5bd

Browse files
James Munnsjamesmunns
authored andcommitted
Fix init behavior for P1 pins
1 parent a31fdd5 commit 901e5bd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

nrf-hal-common/src/twim.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ use crate::pac::{twim0, P0, TWIM0};
1616
#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
1717
use crate::pac::TWIM1;
1818

19+
#[cfg(any(feature = "52833", feature = "52840"))]
20+
use crate::pac::P1;
21+
1922
use crate::{
20-
gpio::{Floating, Input, Pin},
23+
gpio::{Floating, Input, Pin, Port},
2124
slice_in_ram, slice_in_ram_or,
2225
target_constants::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE},
2326
};
@@ -48,8 +51,13 @@ where
4851
// the pins through the raw peripheral API. All of the following is
4952
// safe, as we own the pins now and have exclusive access to their
5053
// registers.
51-
for &pin in &[pins.scl.pin(), pins.sda.pin()] {
52-
unsafe { &*P0::ptr() }.pin_cnf[pin as usize].write(|w| {
54+
for &pin in &[&pins.scl, &pins.sda] {
55+
let port_ptr = match pin.port() {
56+
Port::Port0 => P0::ptr(),
57+
#[cfg(any(feature = "52833", feature = "52840"))]
58+
Port::Port1 => P1::ptr(),
59+
};
60+
unsafe { &*port_ptr }.pin_cnf[pin.pin() as usize].write(|w| {
5361
w.dir()
5462
.input()
5563
.input()

0 commit comments

Comments
 (0)