Open robertinant opened 8 years ago
From @rei-vilo on June 20, 2015 9:40
The file main.template
has been edited with
///
/// @brief main setup function
/// @note rtosSetup() is called before all other tasks
/// * Optional declaration
/// * Defined in main sketch or in rtosGlobals
/// @warning No delay() in rtosSetup()!
///
void rtosSetup() __attribute__((weak));
///
/// @brief Proxy function for Task_create()
/// @note Task_create() requires non-weak functions
///
void rtos_Setup() { rtosSetup(); };
///
/// @brief Proxy function for Task_create()
/// @note Task_create() requires non-weak functions
///
void rtos_Loop() { ; }
and
// Add rtosSetup() as first tasks
taskParams.arg0 = (xdc_UArg) rtos_Setup;
taskParams.arg1 = (xdc_UArg) rtos_Loop;
taskParams.instance->name = (xdc_String) "rtosSetup";
Task_create(the_task, &taskParams, NULL);
The function rtosSetup()
is declared —or not— on main sketch —or the optional rtosGloblas.h
. Here, in file MainSetup.ino
.
// Optional rtosSetup function
// defined in main sketch or in rtosGlobals
// no delay() in rtosSetup()!
void rtosSetup()
{
Serial.begin(115200);
Serial.print("rtosSetup...");
pinMode(BLUE_LED, OUTPUT);
digitalWrite(BLUE_LED, HIGH);
Serial.println("done");
}
See pull-request https://github.com/energia/Energia/commit/0a2b4bc75e05ece4a8908aad28c88b2b858eaa1d on #629
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.cpp
and
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