Skip to content

Commit

Permalink
[arduino] regression: init() should be called BEFORE Serial.begin(). …
Browse files Browse the repository at this point in the history
…We use the setup() function, as in the Arduino approach.
  • Loading branch information
mbriday committed Dec 1, 2014
1 parent 81896e4 commit 18d7fb5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
12 changes: 10 additions & 2 deletions examples/avr/arduinoUno/blink/blink.cpp
Expand Up @@ -8,12 +8,20 @@

int main(void)
{
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
/** No init code should be done here
* use the setup() function
* Trampoline will init the system and call setup()
**/
StartOS(OSDEFAULTAPPMODE);
return 0;
}

void setup()
{
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}

//The TASK is activated by the alarm "periodicAl":
//* The alarm "periodicAl" is configured in the .oil file to activate task
//"periodicTask" each 1000 pulses of counter SystemCounter.
Expand Down
16 changes: 11 additions & 5 deletions examples/avr/arduinoUno/serial/serial.cpp
Expand Up @@ -8,13 +8,19 @@

int main(void)
{
init(); //init of Arduino -> should be called direclty in next versions.
/** No init code should be done here
* use the setup() function
* Trampoline will init the system and call setup()
**/
StartOS(OSDEFAULTAPPMODE);
return 0;
}

void setup()
{
Serial.begin(115200);
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
Serial.begin(115200);
StartOS(OSDEFAULTAPPMODE);
return 0;
}

//The TASK is activated by the alarm "periodicAl":
Expand All @@ -30,5 +36,5 @@ TASK(periodicTask)
else digitalWrite(13, LOW); //even

Serial.print(nb);
Serial.print(" done\n");
Serial.println(" done");
}
2 changes: 2 additions & 0 deletions machines/avr/arduino/hardware/cores/arduino/wiring.c
Expand Up @@ -43,9 +43,11 @@ static unsigned char timer0_fract = 0;

// START TRAMPOLINE SECTION
extern void trampolineSystemCounter();
extern void setup();
void tpl_init_board()
{
init();
setup();
}
// STOP TRAMPOLINE SECTION

Expand Down

0 comments on commit 18d7fb5

Please sign in to comment.