Move watchdog files

This commit is contained in:
Henrik Stickann 2022-05-24 14:04:24 +02:00
parent 8e4dbe1100
commit 1cfae97cae
4 changed files with 52 additions and 28 deletions

View File

@ -2,8 +2,11 @@
* @file
* @brief Implementation of watchdog system task.
*/
#ifndef STA_RTOS_WATCHDOG_HPP
#define STA_RTOS_WATCHDOG_HPP
#ifndef STA_RTOS_SYSTEM_WATCHDOG_HPP
#define STA_RTOS_SYSTEM_WATCHDOG_HPP
#include <sta/rtos/system/names.hpp>
/**
* @defgroup STA_RTOS_Watchdog Watchdog task
@ -33,6 +36,17 @@
# 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.
@ -40,7 +54,7 @@
* @ingroup STA_RTOS_BuildConfig
*/
#ifndef STA_RTOS_WATCHDOG_TIMER_HANDLE
# define STA_RTOS_WATCHDOG_TIMER_HANDLE heartbeatHandle
# define STA_RTOS_WATCHDOG_TIMER_HANDLE STA_RTOS_MAKE_HANDLE_NAME(STA_RTOS_WATCHDOG_TIMER_NAME)
#endif // !STA_RTOS_WATCHDOG_TIMER_HANDLE
/**
@ -50,18 +64,19 @@
* @ingroup STA_RTOS_BuildConfig
*/
#ifndef STA_RTOS_WATCHDOG_TIMER_CALLBACK
# define STA_RTOS_WATCHDOG_TIMER_CALLBACK heartbeatCallback
# 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_HANDLE
* @brief Set variable name of watchdog task handle.
* @def STA_RTOS_WATCHDOG_TASK_NAME
* @brief Set name of watchdog task.
*
* @ingroup STA_RTOS_BuildConfig
*/
#ifndef STA_RTOS_WATCHDOG_HANDLE
# define STA_RTOS_WATCHDOG_HANDLE watchdogHandle
#endif // !STA_RTOS_WATCHDOG_HANDLE
#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
@ -70,7 +85,7 @@
* @ingroup STA_RTOS_BuildConfig
*/
#ifndef STA_RTOS_WATCHDOG_ENTRY_FUNCTION
# define STA_RTOS_WATCHDOG_ENTRY_FUNCTION watchdogTask
# define STA_RTOS_WATCHDOG_ENTRY_FUNCTION STA_RTOS_MAKE_ENTRY_NAME(STA_RTOS_WATCHDOG_TASK_NAME)
#endif // !STA_RTOS_WATCHDOG_ENTRY_FUNCTION
@ -123,4 +138,4 @@ namespace sta
#endif // STA_RTOS_WATCHDOG_ENABLE
#endif // STA_RTOS2_WATCHDOG_HPP
#endif // STA_RTOS_SYSTEM_WATCHDOG_HPP

View File

@ -0,0 +1,18 @@
#ifndef STA_RTOS_SYSTEM_WATCHDOG_HANDLES_HPP
#define STA_RTOS_SYSTEM_WATCHDOG_HANDLES_HPP
#include <sta/rtos/system/watchdog.hpp>
#include <cmsis_os2.h>
#define WATCHDOG_TASK_HANDLE STA_RTOS_MAKE_HANDLE_NAME(STA_RTOS_WATCHDOG_TASK_NAME)
#define WATCHDOG_TIMER_HANDLE STA_RTOS_MAKE_HANDLE_NAME(STA_RTOS_WATCHDOG_TIMER_NAME)
// Access handles from freertos.c
extern osThreadId_t WATCHDOG_TASK_HANDLE;
extern osTimerId_t WATCHDOG_TIMER_HANDLE;
#endif // STA_RTOS_SYSTEM_WATCHDOG_HANDLES_HPP

View File

@ -1,19 +1,15 @@
#include <sta/rtos/watchdog.hpp>
#include <sta/rtos/system/watchdog.hpp>
#ifdef STA_RTOS_WATCHDOG_ENABLE
#include <cmsis_os2.h>
// Access handles from freertos.c
extern osTimerId_t STA_RTOS_WATCHDOG_TIMER_HANDLE;
#include "handles.hpp"
namespace sta
{
void startWatchdogTimer()
{
osTimerStart(STA_RTOS_WATCHDOG_TIMER_HANDLE, STA_RTOS_WATCHDOG_TIMER_PERIOD);
osTimerStart(WATCHDOG_TIMER_HANDLE, STA_RTOS_WATCHDOG_TIMER_PERIOD);
}
} // namespace sta
@ -25,7 +21,7 @@ extern "C"
{
// Notify watchdog task to send heartbeat message
// Required because blocking in a timer callback is not allowed
sta::notifyWatchdog(STA_WATCHDOG_FLAG_HEARTBEAT);
osThreadFlagsSet(WATCHDOG_TASK_HANDLE, STA_WATCHDOG_FLAG_HEARTBEAT);
}
}

View File

@ -1,24 +1,19 @@
#include <sta/rtos/watchdog.hpp>
#include <sta/rtos/system/watchdog.hpp>
#ifdef STA_RTOS_WATCHDOG_ENABLE
#include <sta/rtos/defs.hpp>
#include <sta/rtos/system_event.hpp>
#include <main.h>
#include <cmsis_os2.h>
#include <sta/rtos/system/system_event.hpp>
// Access handle from freertos.c
extern osThreadId_t STA_RTOS_WATCHDOG_HANDLE;
#include "handles.hpp"
namespace sta
{
void notifyWatchdog(uint32_t flags)
{
osThreadFlagsSet(STA_RTOS_WATCHDOG_HANDLE, flags);
osThreadFlagsSet(WATCHDOG_TASK_HANDLE, flags);
}
} // namespace sta