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

GPIO driver #4463

Open
cepetr opened this issue Jan 2, 2025 · 0 comments
Open

GPIO driver #4463

cepetr opened this issue Jan 2, 2025 · 0 comments
Labels
code Code improvements

Comments

@cepetr
Copy link
Contributor

cepetr commented Jan 2, 2025

Introduce a custom GPIO driver with a better abstraction tailored to our specific needs. This interface aims to simplify GPIO handling and improve code clarity while resolving issues like duplicated initialization in RCC.

The following is an initial idea/proposal for further discussion:

Initialization/deinitialization with reference counting and automatic clock enabling/disabling (similar to i2c_bus approach):

gpio_pin_t gpio_pin_open(uint32_t port, uint8_t pin, const gpio_pin_config_t* config);
void gpio_pin_close(gpis_port_t pin);

A routine for pin configuration:

typedef struct {
   mode;
   pull;
   speed;
   altfunc;
} gpio_pin_config_t;

void gpio_pin_configure(gpio_pin_t pin, const gpio_pin_config_t* config);

and introduce few constant with typical gpio configuration:

GPIO_PIN_INPUT
GPIO_PIN_INPUT_PU
GPIO_PIN_OUTPUT_PP
GPIO_PIN_OUTPUT_OD
GPIO_PIN_ANALOG

Read and write routines

void gpio_pin_write(gpio_pin_t pin);
void gpio_pin_set(gpio_pin_t pin);
void gpio_pin_reset(gpio_pin_t pin);
bool gpio_pin_read(gpio_pin_t pin);
@cepetr cepetr added the code Code improvements label Jan 2, 2025
@TychoVrahe TychoVrahe moved this to 🎯 To do in Firmware Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Code improvements
Projects
Status: 🎯 To do
Development

No branches or pull requests

1 participant