Skip to content

Commit

Permalink
drivers/gpio: fix potential issue which cause by enabling pull-up/pul…
Browse files Browse the repository at this point in the history
…l-down.

For PIO3 enabling the pull-down resistor while the pull-up resistor is still enabled is not possible. Likewise, enabling the pull-up resistor while the pull-down resistor is still enabled is not possible.

Signed-off-by: Jeff Lin <[email protected]>
  • Loading branch information
JeffLinSHA committed Sep 30, 2019
1 parent 8b2ac00 commit a730b43
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/gpio/pio3.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,18 @@ void pio_configure(const struct _pin *pin_list, uint32_t size)
if (pin->type == PIO_INPUT)
pmc_configure_peripheral(_pio_get_periph_id(pin->group), NULL, true);

/* Disable pull-down and pull-up resistors */
assert((pin->attribute & (PIO_PULLUP | PIO_PULLDOWN)) != (PIO_PULLUP | PIO_PULLDOWN));
pio->PIO_PPDDR = pin->mask;
pio->PIO_PUDR = pin->mask;

/* Enable pull-up resistors as requested */
if (pin->attribute & PIO_PULLUP)
pio->PIO_PUER = pin->mask;
else
pio->PIO_PUDR = pin->mask;

/* Enable pull-down resistors as requested */
if (pin->attribute & PIO_PULLDOWN)
pio->PIO_PPDER = pin->mask;
else
pio->PIO_PPDDR = pin->mask;

/* Select open-drain output stage as requested */
if (pin->attribute & PIO_OPENDRAIN)
Expand Down

0 comments on commit a730b43

Please sign in to comment.