mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-06-12 02:36:00 +00:00
142 lines
3.0 KiB
C++
142 lines
3.0 KiB
C++
/**
|
|
* @file
|
|
* @brief Implementation of watchdog system task.
|
|
*/
|
|
#ifndef STA_RTOS_SYSTEM_WATCHDOG_HPP
|
|
#define STA_RTOS_SYSTEM_WATCHDOG_HPP
|
|
|
|
#include <sta/rtos/system/names.hpp>
|
|
|
|
|
|
/**
|
|
* @defgroup STA_RTOS_Watchdog Watchdog task
|
|
* @ingroup STA_RTOS_API
|
|
* @brief Watchdog system task.
|
|
*
|
|
* Check @ref STA_RTOS_BuildConfig for configuration options.
|
|
*/
|
|
|
|
#ifdef DOXYGEN
|
|
/**
|
|
* @brief Enable module.
|
|
*
|
|
* @ingroup STA_RTOS_BuildConfig
|
|
*/
|
|
# define STA_RTOS_WATCHDOG_ENABLE
|
|
#endif // DOXYGEN
|
|
|
|
|
|
/**
|
|
* @def STA_RTOS_WATCHDOG_TIMER_PERIOD
|
|
* @brief Set period in ticks of heartbeat timer.
|
|
*
|
|
* @ingroup STA_RTOS_BuildConfig
|
|
*/
|
|
#ifndef STA_RTOS_WATCHDOG_TIMER_PERIOD
|
|
# define STA_RTOS_WATCHDOG_TIMER_PERIOD 1000
|
|
#endif // !STA_RTOS_WATCHDOG_TIMER_PERIOD
|
|
|
|
|
|
/**
|
|
* @def STA_RTOS_WATCHDOG_TIMER_NAME
|
|
* @brief Set name of watchdog timer.
|
|
*
|
|
* @ingroup STA_RTOS_BuildConfig
|
|
*/
|
|
#ifndef STA_RTOS_WATCHDOG_TIMER_NAME
|
|
# define STA_RTOS_WATCHDOG_TIMER_NAME heartbeat
|
|
#endif // !STA_RTOS_WATCHDOG_TIMER_NAME
|
|
|
|
/**
|
|
* @def STA_RTOS_WATCHDOG_TIMER_HANDLE
|
|
* @brief Set variable name of heartbeat timer handle.
|
|
*
|
|
* @ingroup STA_RTOS_BuildConfig
|
|
*/
|
|
#ifndef STA_RTOS_WATCHDOG_TIMER_HANDLE
|
|
# define STA_RTOS_WATCHDOG_TIMER_HANDLE STA_RTOS_MAKE_HANDLE_NAME(STA_RTOS_WATCHDOG_TIMER_NAME)
|
|
#endif // !STA_RTOS_WATCHDOG_TIMER_HANDLE
|
|
|
|
/**
|
|
* @def STA_RTOS_WATCHDOG_TIMER_CALLBACK
|
|
* @brief Set name of heartbeat timer callback function.
|
|
*
|
|
* @ingroup STA_RTOS_BuildConfig
|
|
*/
|
|
#ifndef STA_RTOS_WATCHDOG_TIMER_CALLBACK
|
|
# define STA_RTOS_WATCHDOG_TIMER_CALLBACK STA_RTOS_MAKE_CALLBACK_NAME(STA_RTOS_WATCHDOG_TIMER_NAME)
|
|
#endif // !STA_RTOS_WATCHDOG_TIMER_CALLBACK
|
|
|
|
|
|
/**
|
|
* @def STA_RTOS_WATCHDOG_TASK_NAME
|
|
* @brief Set name of watchdog task.
|
|
*
|
|
* @ingroup STA_RTOS_BuildConfig
|
|
*/
|
|
#ifndef STA_RTOS_WATCHDOG_TASK_NAME
|
|
# define STA_RTOS_WATCHDOG_TASK_NAME watchdog
|
|
#endif // !STA_RTOS_WATCHDOG_TASK_NAME
|
|
|
|
/**
|
|
* @def STA_RTOS_WATCHDOG_ENTRY_FUNCTION
|
|
* @brief Set name of watchdog task entry function.
|
|
*
|
|
* @ingroup STA_RTOS_BuildConfig
|
|
*/
|
|
#ifndef STA_RTOS_WATCHDOG_ENTRY_FUNCTION
|
|
# define STA_RTOS_WATCHDOG_ENTRY_FUNCTION STA_RTOS_MAKE_ENTRY_NAME(STA_RTOS_WATCHDOG_TASK_NAME)
|
|
#endif // !STA_RTOS_WATCHDOG_ENTRY_FUNCTION
|
|
|
|
|
|
#include <sta/config.hpp>
|
|
#ifdef STA_RTOS_WATCHDOG_ENABLE
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
// Watchdog task flags
|
|
//
|
|
|
|
/**
|
|
* @brief Watchdog heartbeat flag.
|
|
*
|
|
* @ingroup STA_RTOS_Watchdog
|
|
*/
|
|
#define STA_WATCHDOG_FLAG_HEARTBEAT 0x00001000U
|
|
|
|
|
|
namespace sta
|
|
{
|
|
/**
|
|
* @brief Start heartbeat timer for watchdog.
|
|
*
|
|
* @ingroup STA_RTOS_Watchdog
|
|
*/
|
|
void startWatchdogTimer();
|
|
/**
|
|
* @brief Send notification to watchdog task.
|
|
*
|
|
* @ingroup STA_RTOS_Watchdog
|
|
*/
|
|
void notifyWatchdog(uint32_t flags);
|
|
|
|
|
|
/**
|
|
* @brief Handler for watchdog events.
|
|
*
|
|
* Must be implemented by application.
|
|
*
|
|
* @param arg Watchdog task argument
|
|
* @param flags Event flags
|
|
*
|
|
* @ingroup STA_RTOS_Watchdog
|
|
*/
|
|
void watchdogEventHandler(void * arg, uint32_t flags);
|
|
} // namespace sta
|
|
|
|
|
|
#endif // STA_RTOS_WATCHDOG_ENABLE
|
|
|
|
#endif // STA_RTOS_SYSTEM_WATCHDOG_HPP
|