Are there C, C++ ESP 8266 / ESP 32 specific commands or functions besides Arduino language reference?

Hi …

When using ESP 8266 / ESP 32 on PlatformIO within Arduino Framework,

is their C / C++ mix called Arduino language restricted to its own reference

( Arduino Reference - Arduino Reference ) or are there other commands,

functions or any other kind of C / C++ stuff specific to those uC,

besides the Arduino language itself ?

Lots of thanks in advance,

Miguel

Yes indeed there are.

Taking the Arduino Uno as an example, it uses an Atmel ATmega328p (or variant of it).

So, you need to set pin D13 to be an output, in Arduino, we use pinMode(13, OUTPUT). In AVR C/C++ we set one bit in a Data Direction Register:

\\ Set D13, aka PORT B, Pin 5 as output.
DDRB |= (1 << DDB5);

In AVR C/C++, you can set multiple pins to output (or input) all at the same time:

\\ Set PORT B, Pins 2 and 5 as output.
DDRB |= (1 << DDB5) | (1 << DDB2));

The Arduino Language would need two pinMode() calls.

Most of the Arduino Language drops down to statements like those above. This is not surprising as it is “just” a library of useful functions based on the registers/functions/commands of the underlying device.

For the other microcontrollers, the language stays the same, but what goes on beneath is different for each one. This is useful, as people can migrate from device to device, and with minimum changes, run the same (Arduino) code on all of them.

If you need to know more, there’s a good book around which explains the entire Arduino Language and how it works. Modesty prevents me from saying the author’s name. :wink:

HTH

Cheers,
Norm.

1 Like

Thanks for your answer Normam.

You gave me a differences example between ATmega and AVR and later you said:

“For the other microcontrollers, the language stays the same, but what goes on beneath is different for each one”

Here are you referring to or including ESP 8266 / ESP32 uC ?

That’s because my main question was about them and if there are any specific
C / C++ “commands” for ESP 8266 / ESP32 uC ( PlatformIO )
that differ from “standard” Arduino C / C++ language set .

Note:
By “commands” I mean C / C++ functions, variables kind, … … …
or any other C / C++ programming stuff.

Thanks again in advance,

Miguel

Well, that’s a really broad question – you can include any header from the ESP8266 / ESP32 core and call into any publically exposed function. Or library.

See e.g. GitHub - esp8266/Arduino at 2.7.4 for the Arduino-ESP8266 core.

These functions are documented at Welcome to ESP8266 Arduino Core’s documentation! — ESP8266 Arduino Core 3.1.2-21-ga348833 documentation.

Some hardware specific calls are e.g. available through the Esp class defined here. Otherwise you can include every header file in the core, the SDK that Arduino-ESP8266 builds on (Espressif NONOS SDK) and use all core-provided libraries.

Functions that are e.g. expanded from the regular Arduino core would be analogWriteRange(new_range), analogWriteResolution, analogWriteMode, analogWriteFreq, Serial.swap, Serial.detectBaudrate, the entire WiFi class, the entire Esp class, etc. etc…

For the ESP32, see GitHub - espressif/arduino-esp32: Arduino core for the ESP32. Since Arduino-ESP32 is an extension of the ESP-IDF, it overlaps with the ESP-IDF documentation available at ESP-IDF Programming Guide - ESP32 - — ESP-IDF Programming Guide latest documentation. But, the Arduino core usually gives you abstraction layers above all these ESP-IDF functions so you shouldn’t call them directly.

Again, the available functions are all of the core, the ESP-IDF SDK and the libraries.

You can see that ESP32-hardware specific examples are e.g. listed at arduino-esp32/libraries/ESP32/examples at master · espressif/arduino-esp32 · GitHub and most of the ESP32 peripheral registers and abstractions are at https://github.com/espressif/arduino-esp32/tree/master/tools/sdk/include/esp32.

Thanks for your answer, maxgerhardt.

I have now some orientation of what is beyond Arduino C / C++ ordinary programming,
when we enter the Espressif ESP 8266 / ESP32 uC world .

Miguel

Sorry, I wasn’t very clear there, my mistake.

What I meant was that for the other devices, if there is an Arduino framework, you will have the same pinMode() function names, but whatever they do underneath will be different to the Atmel AVR commands and regisrers.

The data sheets for the various microcontrollers will (should!) document the registers, sys calls etc. There may even be examples in C/C++ as in the Atmel docs, but I don’t have too much experience outside of AVRs at the moment – I’ve not had time to play with my BluePills, Wemos D1 Minis etc, yet.

Cheers,
Norm.