arduino / arduino-pro-content

2 stars 8 forks source link

Explain how to use ifdef for dual core processing #19

Closed sebromero closed 4 years ago

sebromero commented 4 years ago

As an additional, more flexible option for using dual core processing, add an example with ifdef similar to the one here:

https://github.com/hpssjellis/my-examples-for-the-arduino-portentaH7/blob/master/my02-dual-core.ino

int myLED; 

// the setup function runs once when you press reset or power the board
void setup() {
   randomSeed(analogRead(0));
  #ifdef CORE_CM7  
     LL_RCC_ForceCM4Boot();  
     myLED = LEDB; // on-board blue LED
  #endif

  #ifdef CORE_CM4  
     myLED = LEDG; // on-board greeen LED
  #endif   

  pinMode(myLED, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
   digitalWrite(myLED, LOW); // turn the LED on (LOW is the voltage level)
   delay(200); // wait for a second
   digitalWrite(myLED, HIGH); // turn the LED off by making the voltage HIGH
   delay( rand() % 5000 + 1000); // wait for a random amount of time below 6 seconds.
}
sebromero commented 4 years ago

Solved via https://github.com/bcmi-labs/arduino-pro-content/pull/39