@@ -16,8 +16,11 @@ use crate::pac::{twim0, P0, TWIM0};
16
16
#[ cfg( any( feature = "52832" , feature = "52833" , feature = "52840" ) ) ]
17
17
use crate :: pac:: TWIM1 ;
18
18
19
+ #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
20
+ use crate :: pac:: P1 ;
21
+
19
22
use crate :: {
20
- gpio:: { Floating , Input , Pin } ,
23
+ gpio:: { Floating , Input , Pin , Port } ,
21
24
slice_in_ram, slice_in_ram_or,
22
25
target_constants:: { EASY_DMA_SIZE , FORCE_COPY_BUFFER_SIZE } ,
23
26
} ;
48
51
// the pins through the raw peripheral API. All of the following is
49
52
// safe, as we own the pins now and have exclusive access to their
50
53
// 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| {
53
61
w. dir ( )
54
62
. input ( )
55
63
. input ( )
0 commit comments