Skip to content

Commit 97f5d21

Browse files
authored
Merge pull request #4052 from tannewt/get_pull
Fix DigitalInOut.pull on RP2040
2 parents 0dfa9fb + dc421a6 commit 97f5d21

File tree

3 files changed

+14
-25
lines changed

3 files changed

+14
-25
lines changed

ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CIRCUITPY_ROTARYIO = 0
2222
CIRCUITPY_RTC = 0
2323

2424
SUPEROPT_GC = 0
25-
CFLAGS_INLINE_LIMIT = 50
25+
CFLAGS_INLINE_LIMIT = 40
2626

2727

2828
# Include these Python libraries in firmware.

ports/atmel-samd/boards/qtpy_m0/mpconfigboard.mk

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ LONGINT_IMPL = NONE
1111
CIRCUITPY_FULL_BUILD = 0
1212

1313
SUPEROPT_GC = 0
14+
SUPEROPT_VM = 0
1415

1516
CFLAGS_BOARD = --param max-inline-insns-auto=15
16-
ifeq ($(TRANSLATION), zh_Latn_pinyin)
17-
RELEASE_NEEDS_CLEAN_BUILD = 1
18-
CFLAGS_INLINE_LIMIT = 35
19-
endif
20-
ifeq ($(TRANSLATION), de_DE)
21-
RELEASE_NEEDS_CLEAN_BUILD = 1
22-
CFLAGS_INLINE_LIMIT = 35
23-
SUPEROPT_VM = 0
24-
endif

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(
7676
digitalio_drive_mode_t drive_mode) {
7777
const uint8_t pin = self->pin->number;
7878
gpio_set_dir(pin, GPIO_OUT);
79-
// Turn on "strong" pin driving (more current available). See DRVSTR doc in datasheet.
80-
// hri_port_set_PINCFG_DRVSTR_bit(PORT, (enum gpio_port)GPIO_PORT(pin), GPIO_PIN(pin));
79+
// TODO: Turn on "strong" pin driving (more current available).
8180

8281
self->output = true;
8382
common_hal_digitalio_digitalinout_set_drive_mode(self, drive_mode);
@@ -140,18 +139,16 @@ void common_hal_digitalio_digitalinout_set_pull(
140139

141140
digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
142141
digitalio_digitalinout_obj_t* self) {
143-
// uint32_t pin = self->pin->number;
144-
// if (self->output) {
145-
// mp_raise_AttributeError(translate("Cannot get pull while in output mode"));
146-
// return PULL_NONE;
147-
// } else {
148-
// if (hri_port_get_PINCFG_PULLEN_bit(PORT, GPIO_PORT(pin), GPIO_PIN(pin)) == 0) {
149-
// return PULL_NONE;
150-
// } if (hri_port_get_OUT_reg(PORT, GPIO_PORT(pin), 1U << GPIO_PIN(pin)) > 0) {
151-
// return PULL_UP;
152-
// } else {
153-
// return PULL_DOWN;
154-
// }
155-
// }
142+
uint32_t pin = self->pin->number;
143+
if (self->output) {
144+
mp_raise_AttributeError(translate("Cannot get pull while in output mode"));
145+
return PULL_NONE;
146+
} else {
147+
if (gpio_is_pulled_up(pin)) {
148+
return PULL_UP;
149+
} else if (gpio_is_pulled_down(pin)) {
150+
return PULL_DOWN;
151+
}
152+
}
156153
return PULL_NONE;
157154
}

0 commit comments

Comments
 (0)