@@ -37,6 +37,9 @@ pub enum Level {
3737pub enum Port {
3838 /// Port 0, available on all nRF52 and nRF51 MCUs.
3939 Port0 ,
40+ /// Port 0 Secure, available on nRF53
41+ #[ cfg( any( feature = "5340-app" ) ) ]
42+ Port0Secure ,
4043
4144 /// Port 1, only available on some nRF52 MCUs.
4245 #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
@@ -60,10 +63,13 @@ pub struct Pin<MODE> {
6063#[ cfg( feature = "51" ) ]
6164use crate :: pac:: { gpio, GPIO as P0 } ;
6265
63- #[ cfg( feature = "9160" ) ]
66+ #[ cfg( any ( feature = "5340-app" , feature = " 9160") ) ]
6467use crate :: pac:: { p0_ns as gpio, P0_NS as P0 } ;
6568
66- #[ cfg( not( any( feature = "9160" , feature = "51" ) ) ) ]
69+ #[ cfg( feature = "5340-app" ) ]
70+ use crate :: pac:: P0_S ;
71+
72+ #[ cfg( not( any( feature = "9160" , feature = "5340-app" , feature = "51" ) ) ) ]
6773use crate :: pac:: { p0 as gpio, P0 } ;
6874
6975#[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
@@ -76,6 +82,8 @@ impl<MODE> Pin<MODE> {
7682 fn new ( port : Port , pin : u8 ) -> Self {
7783 let port_bits = match port {
7884 Port :: Port0 => 0x00 ,
85+ #[ cfg( any( feature = "5340-app" ) ) ]
86+ Port :: Port0Secure => 0x20 ,
7987 #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
8088 Port :: Port1 => 0x20 ,
8189 } ;
@@ -94,12 +102,12 @@ impl<MODE> Pin<MODE> {
94102
95103 #[ inline]
96104 pub fn pin ( & self ) -> u8 {
97- #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
105+ #[ cfg( any( feature = "52833" , feature = "52840" , feature = "5340-app" ) ) ]
98106 {
99107 self . pin_port & 0x1f
100108 }
101109
102- #[ cfg( not( any( feature = "52833" , feature = "52840" ) ) ) ]
110+ #[ cfg( not( any( feature = "52833" , feature = "52840" , feature = "5340-app" ) ) ) ]
103111 {
104112 self . pin_port
105113 }
@@ -116,7 +124,16 @@ impl<MODE> Pin<MODE> {
116124 }
117125 }
118126
119- #[ cfg( not( any( feature = "52833" , feature = "52840" ) ) ) ]
127+ #[ cfg( any( feature = "5340-app" ) ) ]
128+ {
129+ if self . pin_port & 0x20 == 0 {
130+ Port :: Port0
131+ } else {
132+ Port :: Port0Secure
133+ }
134+ }
135+
136+ #[ cfg( not( any( feature = "52833" , feature = "52840" , feature = "5340-app" ) ) ) ]
120137 {
121138 Port :: Port0
122139 }
@@ -130,6 +147,8 @@ impl<MODE> Pin<MODE> {
130147 fn block ( & self ) -> & gpio:: RegisterBlock {
131148 let ptr = match self . port ( ) {
132149 Port :: Port0 => P0 :: ptr ( ) ,
150+ #[ cfg( any( feature = "5340-app" ) ) ]
151+ Port :: Port0Secure => P0_S :: ptr ( ) ,
133152 #[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
134153 Port :: Port1 => P1 :: ptr ( ) ,
135154 } ;
@@ -320,10 +339,10 @@ pub enum OpenDrainConfig {
320339#[ cfg( feature = "51" ) ]
321340use crate :: pac:: gpio:: pin_cnf;
322341
323- #[ cfg( feature = "9160" ) ]
342+ #[ cfg( any ( feature = "5340-app" , feature = " 9160") ) ]
324343use crate :: pac:: p0_ns:: pin_cnf;
325344
326- #[ cfg( not( any( feature = "9160" , feature = "51" ) ) ) ]
345+ #[ cfg( not( any( feature = "9160" , feature = "5340-app" , feature = " 51") ) ) ]
327346use crate :: pac:: p0:: pin_cnf;
328347
329348impl OpenDrainConfig {
@@ -647,3 +666,39 @@ gpio!(P1, p0, p1, Port::Port1, [
647666 P1_14 : ( p1_14, 14 , Disconnected ) ,
648667 P1_15 : ( p1_15, 15 , Disconnected ) ,
649668] ) ;
669+
670+ #[ cfg( any( feature = "5340-app" ) ) ]
671+ gpio ! ( P0_S , p0, p0_s, Port :: Port0Secure , [
672+ P0_00 : ( p0_00, 0 , Disconnected ) ,
673+ P0_01 : ( p0_01, 1 , Disconnected ) ,
674+ P0_02 : ( p0_02, 2 , Disconnected ) ,
675+ P0_03 : ( p0_03, 3 , Disconnected ) ,
676+ P0_04 : ( p0_04, 4 , Disconnected ) ,
677+ P0_05 : ( p0_05, 5 , Disconnected ) ,
678+ P0_06 : ( p0_06, 6 , Disconnected ) ,
679+ P0_07 : ( p0_07, 7 , Disconnected ) ,
680+ P0_08 : ( p0_08, 8 , Disconnected ) ,
681+ P0_09 : ( p0_09, 9 , Disconnected ) ,
682+ P0_10 : ( p0_10, 10 , Disconnected ) ,
683+ P0_11 : ( p0_11, 11 , Disconnected ) ,
684+ P0_12 : ( p0_12, 12 , Disconnected ) ,
685+ P0_13 : ( p0_13, 13 , Disconnected ) ,
686+ P0_14 : ( p0_14, 14 , Disconnected ) ,
687+ P0_15 : ( p0_15, 15 , Disconnected ) ,
688+ P0_16 : ( p0_16, 16 , Disconnected ) ,
689+ P0_17 : ( p0_17, 17 , Disconnected ) ,
690+ P0_18 : ( p0_18, 18 , Disconnected ) ,
691+ P0_19 : ( p0_19, 19 , Disconnected ) ,
692+ P0_20 : ( p0_20, 20 , Disconnected ) ,
693+ P0_21 : ( p0_21, 21 , Disconnected ) ,
694+ P0_22 : ( p0_22, 22 , Disconnected ) ,
695+ P0_23 : ( p0_23, 23 , Disconnected ) ,
696+ P0_24 : ( p0_24, 24 , Disconnected ) ,
697+ P0_25 : ( p0_25, 25 , Disconnected ) ,
698+ P0_26 : ( p0_26, 26 , Disconnected ) ,
699+ P0_27 : ( p0_27, 27 , Disconnected ) ,
700+ P0_28 : ( p0_28, 28 , Disconnected ) ,
701+ P0_29 : ( p0_29, 29 , Disconnected ) ,
702+ P0_30 : ( p0_30, 30 , Disconnected ) ,
703+ P0_31 : ( p0_31, 31 , Disconnected ) ,
704+ ] ) ;
0 commit comments