Adding new GPIO20 define for Arduino framework

marius
Posts: 4
Joined: Sun Jul 08, 2018 8:03 am

Adding new GPIO20 define for Arduino framework

Postby marius » Tue Jan 12, 2021 12:11 pm

I'm testing the new ESP32-Pico-Mini-02 module which features GPIO20 that was previously unavailable. The current version of the Arduino framework doesn't contain definitions for GPIO20 and I'm getting errors like:

Code: Select all

"GPIO_NUM_20" is undefined
Is there an easy way I could define GPIO20 in my current project main.h header file? What is the correct syntax for doing that? This way it would keep existing libraries and code working with the new pin.

Thanks!

boarchuz
Posts: 604
Joined: Tue Aug 21, 2018 5:28 am

Re: Adding new GPIO20 define for Arduino framework

Postby boarchuz » Wed Jan 13, 2021 6:08 am

You might still run into problems if any drivers check the validity of the pin (eg. pinMode(20, OUTPUT) -> error?).

Something like this will make the compiler stop complaining but don't expect correct functionality:
#define GPIO_NUM_20 ((gpio_num_t)(20))

Using a different pin for now would be best.

marius
Posts: 4
Joined: Sun Jul 08, 2018 8:03 am

Re: Adding new GPIO20 define for Arduino framework

Postby marius » Wed Jan 13, 2021 6:33 am

Defining it that way does allow the code to compile fine but as expected I don't get correct functionality, not even a simple blinky with digitalWrite() function.

I have also tried experimenting with modifying ..\tools\sdk\include\driver\driver\gpio.h specifically:
line 59 adding "#define GPIO_SEL_20 (BIT(20))"
line 156 adding "GPIO_NUM_20 = 20,"

But with no luck, I still don't get functionality for writing to that pin.

boarchuz
Posts: 604
Joined: Tue Aug 21, 2018 5:28 am

Re: Adding new GPIO20 define for Arduino framework

Postby boarchuz » Wed Jan 13, 2021 8:18 am

Yeah there's a lot more to it. A lot of the Arduino stuff is precompiled so making changes there won't achieve much.

If you're really motivated and you only need simple IO, you might look at ESP-IDF to learn how to initialise and read/write using the registers directly.

I would pick a different pin!

marius
Posts: 4
Joined: Sun Jul 08, 2018 8:03 am

Re: Adding new GPIO20 define for Arduino framework

Postby marius » Wed Jan 13, 2021 9:48 am

Okay, thanks for the info.

Who is online

Users browsing this forum: Baidu [Spider] and 91 guests