Skip to content

Commit 9060df5

Browse files
dhalberttannewt
authored andcommitted
DigitalInOut: Use pin value % 32 to accomodate PORTB and up.
Fixes adafruit#407.
1 parent 7292984 commit 9060df5

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

ports/atmel-samd/common-hal/digitalio/DigitalInOut.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ bool common_hal_digitalio_digitalinout_get_value(
105105
if (!self->output) {
106106
return gpio_get_pin_level(pin);
107107
} else {
108-
if (self->open_drain && hri_port_get_DIR_reg(PORT, (enum gpio_port)GPIO_PORT(pin), 1U << pin) == 0) {
108+
if (self->open_drain && hri_port_get_DIR_reg(PORT, (enum gpio_port)GPIO_PORT(pin), 1U << GPIO_PIN(pin)) == 0) {
109109
return true;
110110
} else {
111-
return hri_port_get_OUT_reg(PORT, (enum gpio_port)GPIO_PORT(pin), 1U << pin);
111+
return hri_port_get_OUT_reg(PORT, (enum gpio_port)GPIO_PORT(pin), 1U << GPIO_PIN(pin));
112112
}
113113
}
114114
}
@@ -160,7 +160,7 @@ enum digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
160160
} else {
161161
if (hri_port_get_PINCFG_PULLEN_bit(PORT, (enum gpio_port)GPIO_PORT(pin), pin) == 0) {
162162
return PULL_NONE;
163-
} if (hri_port_get_OUT_reg(PORT, (enum gpio_port)GPIO_PORT(pin), 1U << pin) > 0) {
163+
} if (hri_port_get_OUT_reg(PORT, (enum gpio_port)GPIO_PORT(pin), 1U << GPIO_PIN(pin)) > 0) {
164164
return PULL_UP;
165165
} else {
166166
return PULL_DOWN;

0 commit comments

Comments
 (0)