@@ -16,8 +16,11 @@ use crate::pac::{twim0, P0, TWIM0};
1616#[ cfg( any( feature = "52832" , feature = "52833" , feature = "52840" ) ) ]
1717use crate :: pac:: TWIM1 ;
1818
19+ #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
20+ use crate :: pac:: P1 ;
21+
1922use 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} ;
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