Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(PeriphDrivers): Update MAX32662 GPIO PAD configuration #874

Merged
merged 1 commit into from
Jan 19, 2024

Conversation

hfakkiz
Copy link
Contributor

@hfakkiz hfakkiz commented Jan 15, 2024

Pull Request Template

Description

ME12 only supports high-impedance, weak pullup and weak pulldown options.

image

This commit removes other options and corrects related register values of PAD configuration.

Checklist Before Requesting Review

  • PR Title follows correct guidelines.
  • Description of changes and all other relevant information.
  • (Optional) Link any related GitHub issues using a keyword
  • (Optional) Provide info on any relevant functional testing/validation. For API changes or significant features, this is not optional.

@hfakkiz hfakkiz added the MAX32662 Related to the MAX32662 (ME12) label Jan 15, 2024
@sihyung-maxim
Copy link
Contributor

This PR is related to this one: #866

The final changes should be consistent across these two PRs.

Copy link
Contributor

@Jake-Carter Jake-Carter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To maintain consistency, I think we should also apply the approach in #866.

In this case, since weak pull-ups are only supported, the enum can be defined as:

/**
 * @brief   Enumeration type for the type of GPIO pad on a given pin.
 */
typedef enum {
    MXC_GPIO_PAD_NONE, ///< No pull-up or pull-down
    MXC_GPIO_PAD_WEAK_PULL_UP, ///< Set pad to weak pull-up
    MXC_GPIO_PAD_WEAK_PULL_DOWN, ///< Set pad to weak pull-down
    MXC_GPIO_PAD_PULL_UP = MXC_GPIO_PAD_WEAK_PULL_UP, ///< Not supported by hardware.  This sets a weak pull-up instead.
    MXC_GPIO_PAD_PULL_DOWN = MXC_GPIO_PAD_WEAK_PULL_DOWN, ///< Not supported by hardware.  This sets a weak pull-down instead.
} mxc_gpio_pad_t;

@ozersa
Copy link
Contributor

ozersa commented Jan 17, 2024

@sihyung-maxim correct the changes shall be consistent.

Default pullup pulldown shall be "MXC_GPIO_PAD_PULL_UP" and "MXC_GPIO_PAD_PULL_DOWN" to be consistent and simplify things. The below configuration will work on Zephyr side.

gpio.h file

typedef enum {
    MXC_GPIO_PAD_NONE, ///< No pull-up or pull-down
    MXC_GPIO_PAD_PULL_UP, ///< Set pad to weak pull-up
    MXC_GPIO_PAD_PULL_DOWN, ///< Set pad to weak pull-down
    MXC_GPIO_PAD_WEAK_PULL_UP = MXC_GPIO_PAD_PULL_UP, ///< Set pad to weak pull-up
    MXC_GPIO_PAD_WEAK_PULL_DOWN = MXC_GPIO_PAD_PULL_DOWN, ///< Set pad to weak pull-down
} mxc_gpio_pad_t;

gpio_me12.c file

    switch (cfg->pad) {
    case MXC_GPIO_PAD_NONE:
        gpio->padctrl0 &= ~cfg->mask;
        break;

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

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

    default:
        return E_BAD_PARAM;
    }

ME12 only supports weak pull-up and weak pull-down.
Updated PAD configuration.

Signed-off-by: Furkan Akkiz <hasanfurkan.akkiz@analog.com>
@hfakkiz
Copy link
Contributor Author

hfakkiz commented Jan 17, 2024

@sihyung-maxim correct the changes shall be consistent.

Default pullup pulldown shall be "MXC_GPIO_PAD_PULL_UP" and "MXC_GPIO_PAD_PULL_DOWN" to be consistent and simplify things. The below configuration will work on Zephyr side.

gpio.h file

typedef enum {
    MXC_GPIO_PAD_NONE, ///< No pull-up or pull-down
    MXC_GPIO_PAD_PULL_UP, ///< Set pad to weak pull-up
    MXC_GPIO_PAD_PULL_DOWN, ///< Set pad to weak pull-down
    MXC_GPIO_PAD_WEAK_PULL_UP = MXC_GPIO_PAD_PULL_UP, ///< Set pad to weak pull-up
    MXC_GPIO_PAD_WEAK_PULL_DOWN = MXC_GPIO_PAD_PULL_DOWN, ///< Set pad to weak pull-down
} mxc_gpio_pad_t;

gpio_me12.c file

    switch (cfg->pad) {
    case MXC_GPIO_PAD_NONE:
        gpio->padctrl0 &= ~cfg->mask;
        break;

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

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

    default:
        return E_BAD_PARAM;
    }

Updated code as this.

@ozersa ozersa changed the title fix(PeriphDrivers): Update ME12's GPIO PAD configuration fix(PeriphDrivers): Update MAX32662 GPIO PAD configuration Jan 18, 2024
Copy link
Contributor

@Jake-Carter Jake-Carter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my mind it makes more sense to define the weak pull-ups as the main ones, but if this helps simplify the Zephyr port then this works too

@Jake-Carter Jake-Carter merged commit 96a56a8 into main Jan 19, 2024
12 checks passed
@Jake-Carter Jake-Carter deleted the fix/me12_gpio_pad branch January 19, 2024 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MAX32662 Related to the MAX32662 (ME12)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants