-->
Page 1 of 2

Changing a digital pin's function

PostPosted: Mon Nov 28, 2016 3:31 pm
by Davon
The information on this page...

wiki/doku.php?id=esp8266_gpio_pin_allocations

...showing the setting of the digital pin's function doesn't work as written and I can't find either the library that would make it work or an alternate way of setting the function.

The method shown is pinMode(<pin #>,FUNCTION#). I presume, from the noted page, that the following would work:

pinMode(6,FUNCTION3)

but this gives a FUNCTION3 not declared error so I believe either there's a library that's needed (not mentioned on the page) or the term FUNCTION3 s/b replaced with something (not mentioned on the page).

Can someone clarify this and perhaps add the info to the noted page for others to see.

Re: Changing a digital pin's function

PostPosted: Tue Nov 29, 2016 8:45 am
by martinayotte
The following code should do it (note the underscore) :

Code: Select allpinMode(6,FUNCTION_3);


Also, with Native SDK, the code would be :

Code: Select allextern "C" {
#include "eagle_soc.h"
}

PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_GPIO6);

Re: Changing a digital pin's function

PostPosted: Tue Nov 29, 2016 10:46 am
by Davon
:D

Thank you Martin!

The underscore did the trick!

Re: Changing a digital pin's function

PostPosted: Wed Nov 08, 2017 7:15 pm
by RICARDO PACHECO
YOU'RE THE GUY!
I was looking for this there are many weeks!
I used in GPIO1 as INPUT, but first, I saw that I need to use pinMode(1, FUNCTION_3);

Thank you very much!