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

[help]: Meaning of Port A/B in GPIO #77

Open
Sutter099 opened this issue Oct 15, 2024 · 0 comments
Open

[help]: Meaning of Port A/B in GPIO #77

Sutter099 opened this issue Oct 15, 2024 · 0 comments
Assignees

Comments

@Sutter099
Copy link

Help

There are 72 gpio pins in K230:

0  ~ 31 -> gpio0
32 ~ 63 -> gpio1
64 ~ 71 -> gpio2

But only gpio0 and gpio1 has complete register group.

In drv_gpio.c, port B registers of gpio1 was used to control direction/input/output.

like

int kd_pin_read(rt_base_t pin)
{
    int ret = check_pin_valid(pin);
    if(ret == -1)
    {
        LOG_E("pin %d not valid for read", pin);
        return -RT_ERROR;
    }
    if(pin < 32)
        return kd_gpio_reg_readl(kd_gpio[0] + DATA_INPUT, pin) == GPIO_PV_HIGH ? PIN_HIGH : PIN_LOW;
    else {
        pin -= 32;
        if(pin < 32)
            return kd_gpio_reg_readl(kd_gpio[1] + DATA_INPUT, pin) == GPIO_PV_HIGH ? PIN_HIGH : PIN_LOW;
        else {
            pin -= 32;
            return kd_gpio_reg_readl(kd_gpio[1] + DATA_INPUT + DATA_INPUT_STRIDE, pin) == GPIO_PV_HIGH ? PIN_HIGH : PIN_LOW;
                                                               ^^^^^^^^^^^^^^^^^
        }
    }
}

So, in gpio1, port A controls itself and port B controls gpio2? And how about port B of gpio0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants