I am learning ADC and in the example shows
//zero-initialize the config structure.
gpio_config_t io_conf = {};
//disable interrupt
io_conf.intr_type = GPIO_INTR_DISABLE;
//set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
//bit mask of the pins that you want to set,e.g.GPIO18/19
io_conf.pin_bit_mask = GPIO_OUTPUT_PIN_SEL;
//disable pull-down mode
io_conf.pull_down_en = 0;
//disable pull-up mode
io_conf.pull_up_en = 0;
//configure GPIO with the given settings
gpio_config(&io_conf);
//interrupt of rising edge
io_conf.intr_type = GPIO_INTR_POSEDGE;
//bit mask of the pins, use GPIO4/5 here
io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL;
//set as input mode
io_conf.mode = GPIO_MODE_INPUT;
//enable pull-up mode
io_conf.pull_up_en = 1;
gpio_config(&io_conf);
That use the same variable of structure to add two bit mask, one for input and one for output. But looks like one is overriding the other because gpio_config( const gpio_config_t *pGPIOConfig)
I want if the example do configuration of input and output or if one override the other and I need one variable for one bit mask and one variable for the other.
Many thanks in advance for your help.
ADC config structure.
Re: ADC config structure.
It doesn't override as gpio_config uses the argument to configure the hardware directly; it doesn't retain a link to the struct. After the call, you're free to re-use or free or whatever it, it won't change the settings for the configured GPIOs.
-
Dario Lobos
- Posts: 8
- Joined: Wed Sep 10, 2025 6:24 pm
Re: ADC config structure.
Many thanks.It doesn't override as gpio_config uses the argument to configure the hardware directly; it doesn't retain a link to the struct. After the call, you're free to re-use or free or whatever it, it won't change the settings for the configured GPIOs.
Who is online
Users browsing this forum: Google [Bot], PerplexityBot and 5 guests
