mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-06-12 02:36:00 +00:00
59 lines
1.1 KiB
C++
59 lines
1.1 KiB
C++
#include <sta/rtos2/watchdog.hpp>
|
|
|
|
#ifdef STA_RTOS2_WATCHDOG_ENABLE
|
|
|
|
#include <sta/rtos2/defs.hpp>
|
|
#include <sta/rtos2/system_event.hpp>
|
|
|
|
#include <main.h>
|
|
|
|
#include <cmsis_os2.h>
|
|
|
|
|
|
#ifndef STA_RTOS2_WATCHDOG_HANDLE
|
|
# define STA_RTOS2_WATCHDOG_HANDLE watchdogHandle
|
|
#endif // !STA_RTOS2_WATCHDOG_HANDLE
|
|
|
|
#ifndef STA_RTOS2_WATCHDOG_ENTRY_FUNCTION
|
|
# define STA_RTOS2_WATCHDOG_ENTRY_FUNCTION watchdogTask
|
|
#endif // !STA_RTOS2_WATCHDOG_ENTRY_FUNCTION
|
|
|
|
|
|
// Access handle from freertos.c
|
|
extern osThreadId_t STA_RTOS2_WATCHDOG_HANDLE;
|
|
|
|
|
|
namespace sta
|
|
{
|
|
void notifyWatchdog(uint32_t flags)
|
|
{
|
|
osThreadFlagsSet(STA_RTOS2_WATCHDOG_HANDLE, flags);
|
|
}
|
|
|
|
|
|
// Handler for watchdog events
|
|
extern void watchdogEventHandler(void * arg, uint32_t flags);
|
|
} // namespace sta
|
|
|
|
|
|
// Declare with C linkage
|
|
extern "C"
|
|
{
|
|
void STA_RTOS2_WATCHDOG_ENTRY_FUNCTION(void * arg)
|
|
{
|
|
sta::waitForStartupEvent();
|
|
|
|
while (true)
|
|
{
|
|
// Wait for any flag to be set
|
|
uint32_t flags = osThreadFlagsWait(STA_RTOS2_THREAD_FLAGS_VALID_BITS, osFlagsWaitAny, osWaitForever);
|
|
|
|
// Call event handler
|
|
sta::watchdogEventHandler(arg, flags);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
#endif // STA_RTOS2_WATCHDOG_ENABLE
|