user-tasks.cpp 789 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "all-headers.h"
  2. static uint64_t gStack1 [64] ;
  3. static void task1 (USER_MODE) {
  4. digitalWrite(L0_LED, true);
  5. for (unsigned int i(0); i < 20; i++) {
  6. printChar (MODE_ '1') ;
  7. digitalWrite(L0_LED, false);
  8. waitDuring(MODE_ 500);
  9. digitalWrite(L0_LED, true);
  10. }
  11. digitalWrite(L0_LED, false);
  12. }
  13. static uint64_t gStack2 [64] ;
  14. static void task2 (USER_MODE) {
  15. digitalWrite(L1_LED, true);
  16. for (unsigned int i(0); i < 20; i++) {
  17. printChar (MODE_ '2') ;
  18. digitalWrite(L1_LED, false);
  19. waitDuring(MODE_ 400);
  20. digitalWrite(L1_LED, true);
  21. }
  22. digitalWrite(L1_LED, false);
  23. }
  24. static void initTasks (INIT_MODE) {
  25. kernel_createTask (MODE_ gStack1, sizeof (gStack1), task1) ;
  26. kernel_createTask (MODE_ gStack2, sizeof (gStack2), task2) ;
  27. }
  28. MACRO_INIT_ROUTINE (initTasks) ;