Restructure SW watchdog and fix bug for >3 channels

The feed function considered max. number of channels and not actual number
of registered channels, which resulted in undefined behavior if not all
channels were used.

Also introducing more simple API to hide the software implementation.
This commit is contained in:
Martin Jäger
2020-07-23 17:34:41 +02:00
parent ed374e8e99
commit 3b486f3193
4 changed files with 66 additions and 67 deletions
+2 -2
View File
@@ -117,7 +117,7 @@ void leds_update_thread()
bool flicker_state = true;
struct device *led_devs[NUM_LED_PINS];
int wdt_channel = sw_watchdog_register(1000);
int wdt_channel = watchdog_register(1000);
for (int pin = 0; pin < NUM_LED_PINS; pin++) {
led_devs[pin] = device_get_binding(led_ports[pin]);
@@ -127,7 +127,7 @@ void leds_update_thread()
while (true) {
sw_watchdog_feed(wdt_channel);
watchdog_feed(wdt_channel);
// could be increased to value >NUM_LEDS to reduce on-time
if (led_count >= NUM_LEDS) {