Files
MuditaOS/module-bsp/board/linux/watchdog/software_watchdog.cpp
Dawid Wojtas 54bf8311b0 [BH-1770][BH-1677] Update fsl drivers
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.
2024-02-21 18:58:12 +01:00

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