summaryrefslogtreecommitdiff
path: root/ports/raspberrypi
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2021-01-22 19:00:37 -0800
committerScott Shawcroft <scott@tannewt.org>2021-01-22 19:00:37 -0800
commitde6b05a17bd22d0ff6a8e07547128ec6001c62ea (patch)
tree1e30b101ef0e7d7d0d1da31b059587b772c5e4e1 /ports/raspberrypi
parent0dfa9fb7c1cf4a2b93275229b699d87490ee6390 (diff)
Fix DigitalInOut.pull on RP2040
It used to always return None. Fixes #4035
Diffstat (limited to 'ports/raspberrypi')
-rw-r--r--ports/raspberrypi/common-hal/digitalio/DigitalInOut.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c b/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c
index 06f0cfdd2..b0bc1b96e 100644
--- a/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c
+++ b/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c
@@ -76,8 +76,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(
digitalio_drive_mode_t drive_mode) {
const uint8_t pin = self->pin->number;
gpio_set_dir(pin, GPIO_OUT);
- // Turn on "strong" pin driving (more current available). See DRVSTR doc in datasheet.
- // hri_port_set_PINCFG_DRVSTR_bit(PORT, (enum gpio_port)GPIO_PORT(pin), GPIO_PIN(pin));
+ // TODO: Turn on "strong" pin driving (more current available).
self->output = true;
common_hal_digitalio_digitalinout_set_drive_mode(self, drive_mode);
@@ -140,18 +139,16 @@ void common_hal_digitalio_digitalinout_set_pull(
digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
digitalio_digitalinout_obj_t* self) {
- // uint32_t pin = self->pin->number;
- // if (self->output) {
- // mp_raise_AttributeError(translate("Cannot get pull while in output mode"));
- // return PULL_NONE;
- // } else {
- // if (hri_port_get_PINCFG_PULLEN_bit(PORT, GPIO_PORT(pin), GPIO_PIN(pin)) == 0) {
- // return PULL_NONE;
- // } if (hri_port_get_OUT_reg(PORT, GPIO_PORT(pin), 1U << GPIO_PIN(pin)) > 0) {
- // return PULL_UP;
- // } else {
- // return PULL_DOWN;
- // }
- // }
+ uint32_t pin = self->pin->number;
+ if (self->output) {
+ mp_raise_AttributeError(translate("Cannot get pull while in output mode"));
+ return PULL_NONE;
+ } else {
+ if (gpio_is_pulled_up(pin)) {
+ return PULL_UP;
+ } else if (gpio_is_pulled_down(pin)) {
+ return PULL_DOWN;
+ }
+ }
return PULL_NONE;
}