mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-26 06:52:14 -05:00
Now the system uses 2.14.0 version. Add only necessary drivers: - pit - pmu - rtwdog - snvs_hp - snvs_lp - src - trng - wdog - gpio - gpt - lpi2c - lpuart - lpuart_edma - common - common_arm - dmamux - edma - flexram - flexram_allocate - clock - cache - CMSIS - dcp - iomuxc Changed speed of the USDHC clock from ~109MHz to ~81MHz. Also changed bus timing from kMMC_HighSpeedTiming to kMMC_HighSpeed200Timing for better efficiency.
60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include "software_watchdog.hpp"
|
|
#include <critical.hpp>
|
|
#include <ticks.hpp>
|
|
#include <system/Common.hpp>
|
|
#include <log/log.hpp>
|
|
#include <cstdlib>
|
|
|
|
namespace bsp::watchdog
|
|
{
|
|
using namespace cpp_freertos;
|
|
|
|
static constexpr uint16_t stackDepthWords = 256;
|
|
|
|
SoftwareWatchdog::SoftwareWatchdog()
|
|
: Thread("SW_Watchdog", stackDepthWords, static_cast<UBaseType_t>(sys::ServicePriority::Realtime))
|
|
{}
|
|
|
|
bool SoftwareWatchdog::init(TickType_t timeoutPeriodMs)
|
|
{
|
|
#if (DISABLE_WDOG)
|
|
return true;
|
|
#else
|
|
timeoutPeriod = pdMS_TO_TICKS(timeoutPeriodMs);
|
|
const auto started = Start();
|
|
|
|
if (started) {
|
|
refresh();
|
|
}
|
|
|
|
return started;
|
|
#endif
|
|
}
|
|
|
|
void SoftwareWatchdog::refresh()
|
|
{
|
|
#if (!DISABLE_WDOG)
|
|
// Critical section not required (atomic 32-bit writes)
|
|
lastRefreshTimestamp = Ticks::GetTicks();
|
|
#endif
|
|
}
|
|
|
|
void SoftwareWatchdog::Run()
|
|
{
|
|
TickType_t lastTimeoutTimestamp = xTaskGetTickCount();
|
|
|
|
while (true) {
|
|
vTaskDelayUntil(&lastTimeoutTimestamp, timeoutPeriod);
|
|
|
|
// Critical section not required (atomic 32-bit reads)
|
|
if (lastTimeoutTimestamp - lastRefreshTimestamp >= timeoutPeriod) {
|
|
LOG_FATAL("Software watchdog timeout, exiting !!!");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
}
|
|
} // namespace bsp::watchdog
|