@@ -43,7 +43,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct(
43
43
self -> pin = pin ;
44
44
45
45
GPIO_InitTypeDef GPIO_InitStruct = {0 };
46
- GPIO_InitStruct .Pin = 1 << self -> pin -> number ;
46
+ GPIO_InitStruct .Pin = pin_mask ( self -> pin -> number ) ;
47
47
GPIO_InitStruct .Mode = GPIO_MODE_INPUT ;
48
48
GPIO_InitStruct .Pull = GPIO_NOPULL ;
49
49
GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_LOW ;
@@ -69,7 +69,7 @@ void common_hal_digitalio_digitalinout_switch_to_input(
69
69
digitalio_digitalinout_obj_t * self , digitalio_pull_t pull ) {
70
70
71
71
GPIO_InitTypeDef GPIO_InitStruct = {0 };
72
- GPIO_InitStruct .Pin = 1 << self -> pin -> number ;
72
+ GPIO_InitStruct .Pin = pin_mask ( self -> pin -> number ) ;
73
73
GPIO_InitStruct .Mode = GPIO_MODE_INPUT ;
74
74
GPIO_InitStruct .Pull = GPIO_NOPULL ;
75
75
GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_LOW ;
@@ -89,27 +89,27 @@ void common_hal_digitalio_digitalinout_switch_to_output(
89
89
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction (
90
90
digitalio_digitalinout_obj_t * self ) {
91
91
92
- return (LL_GPIO_GetPinMode (pin_port (self -> pin -> number ), 1 << self -> pin -> number )
92
+ return (LL_GPIO_GetPinMode (pin_port (self -> pin -> number ), pin_mask ( self -> pin -> number ) )
93
93
== LL_GPIO_MODE_INPUT ) ? DIRECTION_INPUT : DIRECTION_OUTPUT ;
94
94
}
95
95
96
96
void common_hal_digitalio_digitalinout_set_value (
97
97
digitalio_digitalinout_obj_t * self , bool value ) {
98
- HAL_GPIO_WritePin (pin_port (self -> pin -> number ), 1 << self -> pin -> number , value );
98
+ HAL_GPIO_WritePin (pin_port (self -> pin -> number ), pin_mask ( self -> pin -> number ) , value );
99
99
}
100
100
101
101
bool common_hal_digitalio_digitalinout_get_value (
102
102
digitalio_digitalinout_obj_t * self ) {
103
- return (LL_GPIO_GetPinMode (pin_port (self -> pin -> number ), 1 << self -> pin -> number ) == LL_GPIO_MODE_INPUT )
104
- ? HAL_GPIO_ReadPin (pin_port (self -> pin -> number ), 1 << self -> pin -> number )
105
- : LL_GPIO_IsOutputPinSet (pin_port (self -> pin -> number ), 1 << self -> pin -> number );
103
+ return (LL_GPIO_GetPinMode (pin_port (self -> pin -> number ), pin_mask ( self -> pin -> number ) ) == LL_GPIO_MODE_INPUT )
104
+ ? HAL_GPIO_ReadPin (pin_port (self -> pin -> number ), pin_mask ( self -> pin -> number ) )
105
+ : LL_GPIO_IsOutputPinSet (pin_port (self -> pin -> number ), pin_mask ( self -> pin -> number ) );
106
106
}
107
107
108
108
void common_hal_digitalio_digitalinout_set_drive_mode (
109
109
digitalio_digitalinout_obj_t * self ,
110
110
digitalio_drive_mode_t drive_mode ) {
111
111
GPIO_InitTypeDef GPIO_InitStruct = {0 };
112
- GPIO_InitStruct .Pin = 1 << self -> pin -> number ;
112
+ GPIO_InitStruct .Pin = pin_mask ( self -> pin -> number ) ;
113
113
GPIO_InitStruct .Mode = (drive_mode == DRIVE_MODE_OPEN_DRAIN ?
114
114
GPIO_MODE_OUTPUT_OD : GPIO_MODE_OUTPUT_PP );
115
115
GPIO_InitStruct .Pull = GPIO_NOPULL ;
@@ -120,7 +120,7 @@ void common_hal_digitalio_digitalinout_set_drive_mode(
120
120
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode (
121
121
digitalio_digitalinout_obj_t * self ) {
122
122
123
- return LL_GPIO_GetPinOutputType (pin_port (self -> pin -> number ), 1 << self -> pin -> number )
123
+ return LL_GPIO_GetPinOutputType (pin_port (self -> pin -> number ), pin_mask ( self -> pin -> number ) )
124
124
== LL_GPIO_OUTPUT_OPENDRAIN ? DRIVE_MODE_OPEN_DRAIN : DRIVE_MODE_PUSH_PULL ;
125
125
}
126
126
@@ -129,13 +129,13 @@ void common_hal_digitalio_digitalinout_set_pull(
129
129
130
130
switch (pull ) {
131
131
case PULL_UP :
132
- LL_GPIO_SetPinPull (pin_port (self -> pin -> number ), 1 << self -> pin -> number ,LL_GPIO_PULL_UP );
132
+ LL_GPIO_SetPinPull (pin_port (self -> pin -> number ), pin_mask ( self -> pin -> number ) ,LL_GPIO_PULL_UP );
133
133
break ;
134
134
case PULL_DOWN :
135
- LL_GPIO_SetPinPull (pin_port (self -> pin -> number ), 1 << self -> pin -> number ,LL_GPIO_PULL_DOWN );
135
+ LL_GPIO_SetPinPull (pin_port (self -> pin -> number ), pin_mask ( self -> pin -> number ) ,LL_GPIO_PULL_DOWN );
136
136
break ;
137
137
case PULL_NONE :
138
- LL_GPIO_SetPinPull (pin_port (self -> pin -> number ), 1 << self -> pin -> number ,LL_GPIO_PULL_NO );
138
+ LL_GPIO_SetPinPull (pin_port (self -> pin -> number ), pin_mask ( self -> pin -> number ) ,LL_GPIO_PULL_NO );
139
139
break ;
140
140
default :
141
141
break ;
@@ -146,7 +146,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
146
146
digitalio_digitalinout_obj_t * self ) {
147
147
148
148
149
- switch (LL_GPIO_GetPinPull (pin_port (self -> pin -> number ), 1 << self -> pin -> number )) {
149
+ switch (LL_GPIO_GetPinPull (pin_port (self -> pin -> number ), pin_mask ( self -> pin -> number ) )) {
150
150
case LL_GPIO_PULL_UP :
151
151
return PULL_UP ;
152
152
case LL_GPIO_PULL_DOWN :
0 commit comments