SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
Loading...
Searching...
No Matches
io_wdg.hpp
Go to the documentation of this file.
1/*
2 * SatNOGS-COMMS MCU software
3 *
4 * Copyright (C) 2024, Libre Space Foundation <http://libre.space>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * SPDX-License-Identifier: GNU General Public License v3.0 or later
20 */
21
22#pragma once
23
24#include <zephyr/kernel.h>
25
26namespace satnogs::comms
27{
28
41class io_wdg
42{
43public:
47 static constexpr uint32_t min_period_mins = 240;
48
52 static constexpr uint32_t max_period_mins = 20160;
53
54 static constexpr uint32_t task_wdg_interval = 30000;
55
61 static io_wdg &
63 {
64 static io_wdg instance;
65 return instance;
66 }
67
68 io_wdg(io_wdg const &) = delete;
69
70 void
71 operator=(io_wdg const &) = delete;
72
73 void
74 start();
75
76 void
77 set_period(uint32_t period_mins);
78
79 uint32_t
81
82 void
83 reset();
84
85private:
86 static void
87 monitor_thread(void *arg1, void *arg2, void *arg3);
88
89 io_wdg();
90
91 struct k_thread m_thread_data;
92 k_tid_t m_tid;
93 k_mutex m_mtx;
94 uint32_t m_period_mins;
95 int64_t m_last_reset_ts;
96};
97
98} // namespace satnogs::comms
uint32_t period_mins()
Gets the currently configured period in minutes.
Definition io_wdg.cpp:74
void start()
Starts the io_wdg. This method should be called after the board initialization process (satnogs::comm...
Definition io_wdg.cpp:54
io_wdg(io_wdg const &)=delete
void set_period(uint32_t period_mins)
Updates the watchdog period in both the currently running instance and at the persistent storage.
Definition io_wdg.cpp:135
static constexpr uint32_t task_wdg_interval
Definition io_wdg.hpp:54
static io_wdg & get_instance()
Singleton access to the io_wdg subsystem.
Definition io_wdg.hpp:62
void operator=(io_wdg const &)=delete
void reset()
Resets the watchdog timer.
Definition io_wdg.cpp:160
static constexpr uint32_t min_period_mins
Definition io_wdg.hpp:47
static constexpr uint32_t max_period_mins
Definition io_wdg.hpp:52