Skip to content

Commit 6e007f4

Browse files
committed
text fixes
1 parent d888922 commit 6e007f4

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

ports/stm32f4/common-hal/digitalio/DigitalInOut.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct(
4343
self->pin = pin;
4444

4545
GPIO_InitTypeDef GPIO_InitStruct = {0};
46-
GPIO_InitStruct.Pin = 1<<self->pin->number;
46+
GPIO_InitStruct.Pin = pin_mask(self->pin->number);
4747
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
4848
GPIO_InitStruct.Pull = GPIO_NOPULL;
4949
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@@ -69,7 +69,7 @@ void common_hal_digitalio_digitalinout_switch_to_input(
6969
digitalio_digitalinout_obj_t *self, digitalio_pull_t pull) {
7070

7171
GPIO_InitTypeDef GPIO_InitStruct = {0};
72-
GPIO_InitStruct.Pin = 1<<self->pin->number;
72+
GPIO_InitStruct.Pin = pin_mask(self->pin->number);
7373
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
7474
GPIO_InitStruct.Pull = GPIO_NOPULL;
7575
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@@ -89,27 +89,27 @@ void common_hal_digitalio_digitalinout_switch_to_output(
8989
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
9090
digitalio_digitalinout_obj_t *self) {
9191

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))
9393
== LL_GPIO_MODE_INPUT) ? DIRECTION_INPUT : DIRECTION_OUTPUT;
9494
}
9595

9696
void common_hal_digitalio_digitalinout_set_value(
9797
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);
9999
}
100100

101101
bool common_hal_digitalio_digitalinout_get_value(
102102
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));
106106
}
107107

108108
void common_hal_digitalio_digitalinout_set_drive_mode(
109109
digitalio_digitalinout_obj_t *self,
110110
digitalio_drive_mode_t drive_mode) {
111111
GPIO_InitTypeDef GPIO_InitStruct = {0};
112-
GPIO_InitStruct.Pin = 1<<self->pin->number;
112+
GPIO_InitStruct.Pin = pin_mask(self->pin->number);
113113
GPIO_InitStruct.Mode = (drive_mode == DRIVE_MODE_OPEN_DRAIN ?
114114
GPIO_MODE_OUTPUT_OD : GPIO_MODE_OUTPUT_PP);
115115
GPIO_InitStruct.Pull = GPIO_NOPULL;
@@ -120,7 +120,7 @@ void common_hal_digitalio_digitalinout_set_drive_mode(
120120
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(
121121
digitalio_digitalinout_obj_t *self) {
122122

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))
124124
== LL_GPIO_OUTPUT_OPENDRAIN ? DRIVE_MODE_OPEN_DRAIN : DRIVE_MODE_PUSH_PULL;
125125
}
126126

@@ -129,13 +129,13 @@ void common_hal_digitalio_digitalinout_set_pull(
129129

130130
switch (pull) {
131131
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);
133133
break;
134134
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);
136136
break;
137137
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);
139139
break;
140140
default:
141141
break;
@@ -146,7 +146,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
146146
digitalio_digitalinout_obj_t *self) {
147147

148148

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))) {
150150
case LL_GPIO_PULL_UP:
151151
return PULL_UP;
152152
case LL_GPIO_PULL_DOWN:

ports/stm32f4/common-hal/microcontroller/Pin.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ GPIO_TypeDef * pin_port(uint8_t pin_port) {
8686
return ports[pin_port];
8787
}
8888

89-
//TODO: replace with macro?
9089
uint16_t pin_mask(uint8_t pin_number) {
9190
return 1<<pin_number;
9291
}

0 commit comments

Comments
 (0)