From c277f1d9ac32f866c468e4b4cfef4b0c03a1bef9 Mon Sep 17 00:00:00 2001 From: zys Date: Wed, 4 Mar 2026 13:48:16 +0800 Subject: [PATCH] config(cmake): deleted unneedded files --- CMakeLists.txt | 6 +----- include/watchdog.hpp | 26 ++++++++++++++++++++++++++ src/main.cpp | 4 ++-- 3 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 include/watchdog.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f70cd3..55b8376 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,11 +3,7 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(app_photomagnetic) +target_include_directories(app PRIVATE include) target_sources(app PRIVATE src/main.cpp) -set(ZEPHYR_EXTRA_MODULES "${CMAKE_SOURCE_DIR}/../../modules/godtek_temp") -set(ZEPHYR_EXTRA_MODULES "${CMAKE_SOURCE_DIR}/../../modules/photomagnetic_com") -target_include_directories(app PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../modules/photomagnetic_com/include -) \ No newline at end of file diff --git a/include/watchdog.hpp b/include/watchdog.hpp new file mode 100644 index 0000000..02078c4 --- /dev/null +++ b/include/watchdog.hpp @@ -0,0 +1,26 @@ +#ifndef __ZPP_WATCHDOG_HPP +#define __ZPP_WATCHDOG_HPP +#include +#include +namespace app { +class WatchDogConfig { +public: + WatchDogConfig() { + if (!device_is_ready(m_wtd)) { + __ASSERT_NO_MSG(0); + } + wdt_install_timeout(m_wtd, &wdt_timeout_cfg); + + if (auto err = wdt_setup(m_wtd, WDT_OPT_PAUSE_HALTED_BY_DBG); err < 0) { + __ASSERT_NO_MSG(0); + } + wdt_timeout_cfg cfg; + } + +private: + const device *m_wtd{DEVICE_DT_GET(DT_ALIAS(watchdog0))}; +}; + +} // namespace app + +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index fc910f9..810ba08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,4 @@ +#include "watchdog.h" #include "zpp/fmt.hpp" #include #include @@ -13,7 +14,6 @@ enum Command { kTemp = 0x00, kGetId, kRunningState }; enum RunningState {}; constexpr auto kDeviceIdSize = 20; enum StatusId : uint8_t { kRunning, kPause, kError, kStandby }; - } // namespace volatile bool flag{false}; @@ -21,7 +21,7 @@ auto main(void) -> int { pmc.SetRxCallback(kGetId, [](uart_com::DataType data) -> void { uint8_t buffer[kDeviceIdSize]; auto size = hwinfo_get_device_id(buffer, sizeof(buffer)); - pmc.Send("id", uart_com::DataType(buffer, size)); + pmc.Send(kGetId, uart_com::DataType(buffer, size)); }); pmc.SetRxCallback(kRunningState, [](uart_com::DataType data) -> void {