Skip to content

Commit a730b43

Browse files
committed
drivers/gpio: fix potential issue which cause by enabling pull-up/pull-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 <min.lin@microchip.com>
1 parent 8b2ac00 commit a730b43

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/gpio/pio3.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,18 @@ void pio_configure(const struct _pin *pin_list, uint32_t size)
266266
if (pin->type == PIO_INPUT)
267267
pmc_configure_peripheral(_pio_get_periph_id(pin->group), NULL, true);
268268

269+
/* Disable pull-down and pull-up resistors */
270+
assert((pin->attribute & (PIO_PULLUP | PIO_PULLDOWN)) != (PIO_PULLUP | PIO_PULLDOWN));
271+
pio->PIO_PPDDR = pin->mask;
272+
pio->PIO_PUDR = pin->mask;
273+
269274
/* Enable pull-up resistors as requested */
270275
if (pin->attribute & PIO_PULLUP)
271276
pio->PIO_PUER = pin->mask;
272-
else
273-
pio->PIO_PUDR = pin->mask;
274277

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

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

0 commit comments

Comments
 (0)