Added initWatchdog function to startup

This commit is contained in:
dario 2024-01-18 00:36:22 +01:00
parent 12d6303f2e
commit 9b813832e2
3 changed files with 27 additions and 7 deletions

View File

@ -52,11 +52,17 @@ namespace sta
* @tparam T The class of the thread to be created. A subclass of TacosThread. * @tparam T The class of the thread to be created. A subclass of TacosThread.
* @param states A list of states in which the thread should run. * @param states A list of states in which the thread should run.
* @param args The constructor arguments for the provided class. * @param args The constructor arguments for the provided class.
*
* @return uint16_t A shared pointer to the created thread.
*/ */
template<typename T, typename ... Args> template<typename T, typename ... Args>
void addThread(std::list<uint16_t> states, Args ... args) std::shared_ptr<T> addThread(std::list<uint16_t> states, Args ... args)
{ {
Manager::instance()->registerThread(std::make_shared<T>(args...), states); std::shared_ptr<T> thread_ptr = std::make_shared<T>(args...);
Manager::instance()->registerThread(thread_ptr, states);
return thread_ptr;
} }
} // namespace tacos } // namespace tacos
} }

View File

@ -26,6 +26,7 @@
// Tacos-specific includes. // Tacos-specific includes.
#include <sta/tacos/manager.hpp> #include <sta/tacos/manager.hpp>
#include <sta/tacos/statemachine.hpp> #include <sta/tacos/statemachine.hpp>
#include <sta/tacos/watchdog.hpp>
// The UART mutex defined in freertos.c // The UART mutex defined in freertos.c
@ -49,8 +50,6 @@ namespace sta
UARTSettings settings = { .mode = UARTMode::RX_TX }; UARTSettings settings = { .mode = UARTMode::RX_TX };
STM32UART * intf_ptr = new STM32UART(&huart2, settings, mutex); STM32UART * intf_ptr = new STM32UART(&huart2, settings, mutex);
Debug = new PrintableUART(intf_ptr); Debug = new PrintableUART(intf_ptr);
STA_DEBUG_PRINTLN("UART SUCCESSFULLY INITIALIZED");
} }
} }
#endif // STA_DEBUGGING_ENABLED #endif // STA_DEBUGGING_ENABLED
@ -86,6 +85,19 @@ namespace sta
Manager::instance()->start(); Manager::instance()->start();
} }
#ifdef STA_TACOS_WATCHDOG_ENABLED
STA_WEAK
void onWatchdogInit()
{}
void initWatchdog()
{
onWatchdogInit();
Watchdog::instance()->start();
}
#endif // STA_TACOS_WATCHDOG_ENABLED
} // namespace tacos } // namespace tacos
@ -101,6 +113,10 @@ namespace sta
tacos::initStatemachine(); tacos::initStatemachine();
tacos::initManager(); tacos::initManager();
#ifdef STA_TACOS_WATCHDOG_ENABLED
tacos::initWatchdog();
#endif // STA_TACOS_WATCHDOG_ENABLED
} }
} // namespace rtos } // namespace rtos
} // namespace sta } // namespace sta

View File

@ -32,9 +32,7 @@ namespace sta
Watchdog::Watchdog() Watchdog::Watchdog()
: TacosThread{"Watchdog", STA_TACOS_WATCHDOG_PRIORITY} : TacosThread{"Watchdog", STA_TACOS_WATCHDOG_PRIORITY}
{ {}
}
Watchdog* Watchdog::_instance = nullptr; Watchdog* Watchdog::_instance = nullptr;
} // namespace tacos } // namespace tacos