-->
Page 1 of 1

Newbi and direct Pin Manipulation

PostPosted: Fri Mar 04, 2022 12:45 pm
by Holzwurm
Hello,
I am a ESP Newbi and want to make some tests with a Wemos D1 mini. It works with Arduino IDE and the
Arduino instructions without problem. I found informations about the direct bit manipulation and see
GPOS = (1 << D6); and GPOC = (1 << D6); to set a bit high or low. Where I can get some more informations. With what command can I read the Bit-Status?
Many thanks for every answer
Hans

Re: Newbi and direct Pin Manipulation

PostPosted: Fri Mar 18, 2022 10:03 am
by rpiloverbd
Reading a particular pin of the ESP8266 is as same as Arduino. For example, if you want to read the digital value of the pin D2, you have to write

Code: Select alldigitalRead(2)

Re: Newbi and direct Pin Manipulation

PostPosted: Fri Mar 18, 2022 11:16 am
by btidey
Look for the file esp8266_peri.h which will be in the Arduino esp8266 package under cores\esp8266\

This has all the macro definitions for the direct register operations that are used by the high level Arduino operations like digitalRead. It is useful not only for GPIO but all the other internal registers

Using these can operate significantly faster than the high level routines and are particularly useful when you want to operate on several GPIOs in one operation. Also if you want to have a bi-directional pin swapping from input to output that can be achieved much faster than using pinMode which is quite a complex routine.

The GPO and GPI macros give direct access to the registers that write and read the registers for all GPIO0-15.

GPOP and GPIP give the masked versions that just operate on one bit.