Skip to content

Commit

Permalink
fix(PeriphDrivers): Flip strong vs weak pull-up bit values (#1145)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Carter authored Sep 4, 2024
1 parent 2ad3a8d commit a5cc8d5
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 61 deletions.
10 changes: 6 additions & 4 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_ai85.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,28 +175,30 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
gpio->padctrl1 &= ~cfg->mask;
break;

// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
case MXC_GPIO_PAD_WEAK_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

case MXC_GPIO_PAD_WEAK_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

default:
Expand Down
10 changes: 6 additions & 4 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_ai87.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,28 +175,30 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
gpio->padctrl1 &= ~cfg->mask;
break;

// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
case MXC_GPIO_PAD_WEAK_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

case MXC_GPIO_PAD_WEAK_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

default:
Expand Down
10 changes: 6 additions & 4 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_es17.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,30 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
gpio->pdpu_sel1 &= ~cfg->mask;
break;

// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
case MXC_GPIO_PAD_WEAK_PULL_UP:
gpio->pdpu_sel0 |= cfg->mask;
gpio->pdpu_sel1 &= ~cfg->mask;
gpio->pssel &= ~cfg->mask;
gpio->pssel |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->pdpu_sel0 |= cfg->mask;
gpio->pdpu_sel1 &= ~cfg->mask;
gpio->pssel |= cfg->mask;
gpio->pssel &= ~cfg->mask;
break;

case MXC_GPIO_PAD_WEAK_PULL_DOWN:
gpio->pdpu_sel0 &= ~cfg->mask;
gpio->pdpu_sel1 |= cfg->mask;
gpio->pssel &= ~cfg->mask;
gpio->pssel |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->pdpu_sel0 &= ~cfg->mask;
gpio->pdpu_sel1 |= cfg->mask;
gpio->pssel |= cfg->mask;
gpio->pssel &= ~cfg->mask;
break;

default:
Expand Down
10 changes: 6 additions & 4 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_me13.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,28 +123,30 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
gpio->pad_cfg2 &= ~cfg->mask;
break;

// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
case MXC_GPIO_PAD_WEAK_PULL_UP:
gpio->pad_cfg1 |= cfg->mask;
gpio->pad_cfg2 &= ~cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->pad_cfg1 |= cfg->mask;
gpio->pad_cfg2 &= ~cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

case MXC_GPIO_PAD_WEAK_PULL_DOWN:
gpio->pad_cfg1 &= ~cfg->mask;
gpio->pad_cfg2 |= cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->pad_cfg1 &= ~cfg->mask;
gpio->pad_cfg2 |= cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

default:
Expand Down
10 changes: 6 additions & 4 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_me14.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,30 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
gpio->pad_cfg2 &= ~cfg->mask;
break;

// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
case MXC_GPIO_PAD_WEAK_PULL_UP:
gpio->pad_cfg1 |= cfg->mask;
gpio->pad_cfg2 &= ~cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->pad_cfg1 |= cfg->mask;
gpio->pad_cfg2 &= ~cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

case MXC_GPIO_PAD_WEAK_PULL_DOWN:
gpio->pad_cfg1 &= ~cfg->mask;
gpio->pad_cfg2 |= cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->pad_cfg1 &= ~cfg->mask;
gpio->pad_cfg2 |= cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

default:
Expand Down
10 changes: 6 additions & 4 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_me17.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,28 +175,30 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
gpio->padctrl1 &= ~cfg->mask;
break;

// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
case MXC_GPIO_PAD_WEAK_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

case MXC_GPIO_PAD_WEAK_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

default:
Expand Down
10 changes: 6 additions & 4 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_me18.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,28 +194,30 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
gpio->padctrl1 &= ~cfg->mask;
break;

// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
case MXC_GPIO_PAD_WEAK_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

case MXC_GPIO_PAD_WEAK_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

default:
Expand Down
10 changes: 6 additions & 4 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_me20.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,28 +172,30 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
gpio->padctrl1 &= ~cfg->mask;
break;

// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
case MXC_GPIO_PAD_WEAK_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

case MXC_GPIO_PAD_WEAK_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->ps &= ~cfg->mask;
gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->ps |= cfg->mask;
gpio->ps &= ~cfg->mask;
break;

default:
Expand Down
10 changes: 6 additions & 4 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_me30.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,30 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
gpio->padctrl1 &= ~cfg->mask;
break;

// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
case MXC_GPIO_PAD_WEAK_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
// gpio->ps &= ~cfg->mask;
// gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
// gpio->ps |= cfg->mask;
// gpio->ps &= ~cfg->mask;
break;

case MXC_GPIO_PAD_WEAK_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
// gpio->ps &= ~cfg->mask;
// gpio->ps |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
// gpio->ps |= cfg->mask;
// gpio->ps &= ~cfg->mask;
break;

default:
Expand Down
10 changes: 6 additions & 4 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_me55.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,30 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg)
gpio->padctrl1 &= ~cfg->mask;
break;

// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
case MXC_GPIO_PAD_WEAK_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->pssel &= ~cfg->mask;
gpio->pssel |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
gpio->pssel |= cfg->mask;
gpio->pssel &= ~cfg->mask;
break;

case MXC_GPIO_PAD_WEAK_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->pssel &= ~cfg->mask;
gpio->pssel |= cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
gpio->pssel |= cfg->mask;
gpio->pssel &= ~cfg->mask;
break;

default:
Expand Down
16 changes: 7 additions & 9 deletions Libraries/PeriphDrivers/Source/GPIO/gpio_revb.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "gpio_common.h"

/* **** Functions **** */
// NOTE(JC): This function doesn't actually seem to be used anywhere. The MEXX parts re-implement this...
// TODO(JC): Consolidate to actually use this (would help with code repetition) but psMask seems dubious
int MXC_GPIO_RevB_Config(const mxc_gpio_cfg_t *cfg, uint8_t psMask)
{
mxc_gpio_regs_t *gpio = cfg->port;
Expand Down Expand Up @@ -75,29 +77,25 @@ int MXC_GPIO_RevB_Config(const mxc_gpio_cfg_t *cfg, uint8_t psMask)
}

// Configure the pad
// Note: for "ps" field set 1 for weak and 0 for strong.
// As of 8-28-2024 most UG tables have this flipped the wrong way
switch (cfg->pad) {
case MXC_GPIO_PAD_NONE:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
if (psMask == MXC_GPIO_PS_PULL_SELECT) {
gpio->ps &= ~cfg->mask;
}
gpio->ps &= ~cfg->mask;
break;

case MXC_GPIO_PAD_PULL_UP:
gpio->padctrl0 |= cfg->mask;
gpio->padctrl1 &= ~cfg->mask;
if (psMask == MXC_GPIO_PS_PULL_SELECT) {
gpio->ps |= cfg->mask;
}
gpio->ps &= ~cfg->mask;
break;

case MXC_GPIO_PAD_PULL_DOWN:
gpio->padctrl0 &= ~cfg->mask;
gpio->padctrl1 |= cfg->mask;
if (psMask == MXC_GPIO_PS_PULL_SELECT) {
gpio->ps &= ~cfg->mask;
}
gpio->ps |= cfg->mask;
break;

default:
Expand Down
Loading

0 comments on commit a5cc8d5

Please sign in to comment.