Page 1 of 1

Is there anyway to get access to GPIO input value in boot loader_start.c?

Posted: Tue May 29, 2018 7:25 pm
by TimLee
I'm trying to get a value from a GPIO during the boot stage to decide which partition I would like to jump into.
I've tried to include driver/gpio.h and link driver/gpio.c but it compiled failed with cannot find GPIO in gpio.o
so I've checked rom/gpio.h and find there are a not documented function GPIO_INPUT_GET which I can use.
but I can only get 1 from this function no matter how I tried.

So is there any way I can get a valid value from a GPIO here(in application I use it with input mode and pulldown set to true).

Re: Is there anyway to get access to GPIO input value in boot loader_start.c?

Posted: Wed May 30, 2018 1:27 am
by ESP_Angus
Hi Tim,

You can use the GPIO_INPUT_GET(N) macro to read a GPIO input pin via ROM code functions:
https://github.com/espressif/esp-idf/bl ... gpio.h#L64

It's also possible to read the GPIO registers directly, but there's not much point unless you need very fast reads in a tight loop.

Re: Is there anyway to get access to GPIO input value in boot loader_start.c?

Posted: Wed May 30, 2018 4:24 am
by WiFive

Re: Is there anyway to get access to GPIO input value in boot loader_start.c?

Posted: Wed May 30, 2018 7:13 am
by TimLee
Didn't noticed that, that's really helpful, thx very much :)