Go Down

Topic: "Android ARM <Scheduler.h> PORTED on AVR and included in SCoop V1.2 (Read 3035 times) previous topic - next topic



I was playing with the Scheduler.h provided with the Arduino 1.51 library for the Arduino DUE / ARM Board, and I was frustrated not being able to use it on the Arduino UNO or Teensy2 based on AVR platform.

This is now solve  : I have added a task context switching in AVR asm which makes the library now compatible with both platform !

only 2560 (with __AVR_3_BYTE_PC__) s not compatible as I didnt want to break the original code behaviour.

you can download the libray from the SCoop google code project here:

and start playing with the MultipleBlink example provided.

in term of changes compared to the original version, I have added a Scheduler.delay(), including a call to yield(), to compensate the lack of this in the arduino library <1.5. So you can use this library in arduino 1.0.2/1.03 as long as you replace your delay() by this Scheduler.delay(), otherwise your scheduler will not schedule anything !

2 other macros were added to bring atomic protection and non-rentrance /concurrent protection:
yieldPORTECT() and yieldATOMIC { }

yieldPROTECT() shall just be used at the begining of the function to protect. it will yield() until the function can be reused by another task.

yieldATOMIC { } give the possibility to write a bloc of code (typically containing a delay() ), between bracket. then the global yield() will not be executed for this piece of code.

hope you enjoy it. We shall use this thread to bring support and feedback on it.

I have also included this port in the SCoop V1.2 suite which provides a more serious Cooperative scheduler approach, and fully compatible with this Scheduler.h originally witten by the Android team, so you can make your test and choose the one you prefer.
link on SCoop V1.2 announcement :

edit : source code has been submited in the 1.5 scheduler branch on arduino github for further review/integration :

Go Up