Arduino-Scheduler
Portable Collaborative Multi-Tasking Scheduler for Arduino
SchedulerWatchdogTemplate.ino
Go to the documentation of this file.
1 
24 #include <Scheduler.h>
25 #include "Watchdog.h"
26 
27 // Check for SparkFun SAMD21 Breakout
28 #if defined(ARDUINO_ARCH_SAMD) && (USB_PID == 0x8D21)
29 #define Serial SerialUSB
30 #endif
31 
32 unsigned long count = 0;
33 
34 void alarm(unsigned long ms)
35 {
36  Serial.print(millis());
37  Serial.print(':');
38  Serial.print(count);
39  Serial.print(F(":watchdog alarm:ms="));
40  Serial.println(ms);
41  count = 0;
42 }
43 
45 
46 void setup()
47 {
48  Serial.begin(57600);
49  while (!Serial);
50  Serial.println(F("SchedulerWatchdogTemplate: started"));
51  Scheduler.start(watchdog.setup, watchdog.loop);
52 }
53 
54 void loop()
55 {
56  delayMicroseconds(random(17000));
57  yield();
58  count += 1;
59 }
60 
61 
Watchdog< 15, alarm > watchdog
static void setup()
Definition: Watchdog.h:28
static void loop()
Definition: Watchdog.h:31
unsigned long count
void alarm(unsigned long ms)
SchedulerClass Scheduler
Definition: Scheduler.cpp:53
static bool start(func_t taskSetup, func_t taskLoop, size_t stackSize=DEFAULT_STACK_SIZE)
Definition: Scheduler.cpp:76
void yield(void)
Definition: Scheduler.cpp:153