Add watchdog for each thread using Zephyr API

This commit is contained in:
Martin Jäger
2020-05-06 12:53:26 +02:00
parent 1252a1ffa1
commit 2d3594d254
5 changed files with 77 additions and 9 deletions
+3
View File
@@ -6,6 +6,7 @@
#include "leds.h"
#include "hardware.h"
#include "board.h"
static int led_states[NUM_LEDS]; // must be one of enum LedState
@@ -28,6 +29,7 @@ void leds_update_thread()
int flicker_count = 0;
bool flicker_state = 1;
struct device *led_devs[NUM_LED_PINS];
int wdt_channel = watchdog_register(1000);
for (int pin = 0; pin < NUM_LED_PINS; pin++) {
led_devs[pin] = device_get_binding(led_ports[pin]);
@@ -36,6 +38,7 @@ void leds_update_thread()
leds_init();
while (1) {
watchdog_feed(wdt_channel);
// could be increased to value >NUM_LEDS to reduce on-time
if (led_count >= NUM_LEDS) {