From @rei-vilo on June 15, 2015 8:25
The setup() functions in the Energia MT examples often initiliase the GPIOs, ports and objects as many times as sketches, e.g. Serial.begin(115200);.
This raises two issues.
- Some GPIOs, ports and objects don't accept to be initialised many times (e.g. Wire).
- The order the
setup() functions in the sketches isn't known, so we don't know in which sketch to initiliase GPIOs, ports and objects.
The idea is to have a specific setup() function names rtosSetup() called before all the other setup() functions of the sketches.
- Add in
main.cpp
void rtosSetup() __attribute__((weak));
and
just before BIOS_start();
- Declare
rtosSetup() in the main sketch.
Because rtosSetup() is weak, the declaration of the function rtosSetup() can be omitted.
Copied from original issue: energia/Energia#631
From @rei-vilo on June 15, 2015 8:25
The
setup()functions in the Energia MT examples often initiliase the GPIOs, ports and objects as many times as sketches, e.g.Serial.begin(115200);.This raises two issues.
setup()functions in the sketches isn't known, so we don't know in which sketch to initiliase GPIOs, ports and objects.The idea is to have a specific
setup()function namesrtosSetup()called before all the othersetup()functions of the sketches.main.cppand
just before
BIOS_start();rtosSetup()in the main sketch.Because
rtosSetup()is weak, the declaration of the functionrtosSetup()can be omitted.Copied from original issue: energia/Energia#631