Software watchdog for multiple threads

This commit is contained in:
Rhushabh
2020-06-23 15:59:31 +02:00
committed by Martin Jäger
parent 54bc5eaee8
commit 1dc5cdd7ef
5 changed files with 78 additions and 15 deletions
+5 -4
View File
@@ -5,8 +5,6 @@
*/
#include "leds.h"
#include "hardware.h"
#include "board.h"
static int led_states[NUM_LEDS]; // must be one of enum LedState
@@ -20,6 +18,7 @@ static bool charging = false;
#include <zephyr.h>
#include <drivers/gpio.h>
#include "hardware.h"
#define SLEEP_TIME_MS (1000/60/NUM_LEDS) // 60 Hz
@@ -29,7 +28,8 @@ 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);
int wdt_channel = sw_watchdog_register(1000);
for (int pin = 0; pin < NUM_LED_PINS; pin++) {
led_devs[pin] = device_get_binding(led_ports[pin]);
@@ -38,7 +38,8 @@ void leds_update_thread()
leds_init();
while (1) {
watchdog_feed(wdt_channel);
sw_watchdog_feed(wdt_channel);
// could be increased to value >NUM_LEDS to reduce on-time
if (led_count >= NUM_LEDS) {