mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/auto_init: control the wdt thread
This commit is contained in:
parent
8179312d06
commit
df8e4d182f
@ -24,6 +24,7 @@
|
||||
|
||||
#include "architecture.h"
|
||||
#include "periph/wdt.h"
|
||||
#include "wdt_thread.h"
|
||||
#include "ztimer.h"
|
||||
|
||||
#ifndef WDT_THREAD_STACKSIZE
|
||||
@ -36,6 +37,14 @@
|
||||
|
||||
static char WORD_ALIGNED wdt_stack[WDT_THREAD_STACKSIZE];
|
||||
|
||||
static bool _wdt_enabled = true;
|
||||
|
||||
void wdt_thread_stop(void)
|
||||
{
|
||||
_wdt_enabled = false;
|
||||
wdt_stop();
|
||||
}
|
||||
|
||||
static void *_wdt_thread(void *ctx)
|
||||
{
|
||||
(void)ctx;
|
||||
@ -43,6 +52,9 @@ static void *_wdt_thread(void *ctx)
|
||||
/ 2;
|
||||
while (1) {
|
||||
ztimer_sleep(ZTIMER_MSEC, sleep_ms);
|
||||
if (!_wdt_enabled) {
|
||||
break;
|
||||
}
|
||||
wdt_kick();
|
||||
}
|
||||
|
||||
|
41
sys/include/wdt_thread.h
Normal file
41
sys/include/wdt_thread.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2024 ML!PA Consulting GmbH
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup sys_wdt_thread wdt thread control
|
||||
* @ingroup sys
|
||||
* @brief Utility functions for controlling the wdt thread
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
* @brief WDT thread control functions
|
||||
*
|
||||
* @author Mariem Charrada <mariem.charrada@ml-pa.com>
|
||||
*/
|
||||
|
||||
#ifndef WDT_THREAD_H
|
||||
#define WDT_THREAD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Stop the wdt thread
|
||||
*
|
||||
* This function is useful for stopping at any time the wdt thread
|
||||
*/
|
||||
void wdt_thread_stop(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WDT_THREAD_H */
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user