Skip to content

Commit 60a83cd

Browse files
authored
Merge pull request #3 from Open-Source-Space-Foundation/more-led-blinker
Add Watchdog Petter Component
2 parents 4374483 + c9f6880 commit 60a83cd

File tree

19 files changed

+314
-239
lines changed

19 files changed

+314
-239
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Include project-wide components here
22

33
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
4-
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Led")
4+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")

FprimeZephyrReference/Components/Led/Led.cpp

Lines changed: 0 additions & 87 deletions
This file was deleted.

FprimeZephyrReference/Components/Led/Led.fpp

Lines changed: 0 additions & 67 deletions
This file was deleted.

FprimeZephyrReference/Components/Led/Led.hpp

Lines changed: 0 additions & 71 deletions
This file was deleted.

FprimeZephyrReference/Components/Led/CMakeLists.txt renamed to FprimeZephyrReference/Components/Watchdog/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
register_fprime_library(
1818
AUTOCODER_INPUTS
19-
"${CMAKE_CURRENT_LIST_DIR}/Led.fpp"
19+
"${CMAKE_CURRENT_LIST_DIR}/Watchdog.fpp"
2020
SOURCES
21-
"${CMAKE_CURRENT_LIST_DIR}/Led.cpp"
21+
"${CMAKE_CURRENT_LIST_DIR}/Watchdog.cpp"
2222
# DEPENDS
2323
# MyPackage_MyOtherModule
2424
)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// ======================================================================
2+
// \title Watchdog.cpp
3+
// \author moisesmata
4+
// \brief cpp file for Watchdog component implementation class
5+
// ======================================================================
6+
7+
#include "FprimeZephyrReference/Components/Watchdog/Watchdog.hpp"
8+
#include "config/FpConfig.hpp"
9+
10+
namespace Components {
11+
12+
// ----------------------------------------------------------------------
13+
// Component construction and destruction
14+
// ----------------------------------------------------------------------
15+
16+
Watchdog ::Watchdog(const char* const compName) : WatchdogComponentBase(compName) {}
17+
18+
Watchdog ::~Watchdog() {}
19+
20+
// ----------------------------------------------------------------------
21+
// Handler implementations for user-defined typed input ports
22+
// ----------------------------------------------------------------------
23+
24+
void Watchdog ::run_handler(FwIndexType portNum, U32 context) {
25+
// Only perform actions when stop not requested
26+
if (!this->m_stopRequested) {
27+
// Toggle state every rate group call
28+
this->m_state = (this->m_state == Fw::On::ON) ? Fw::On::OFF : Fw::On::ON;
29+
this->m_transitions++;
30+
this->tlmWrite_WatchdogTransitions(this->m_transitions);
31+
32+
this->gpioSet_out(0, (Fw::On::ON == this->m_state) ? Fw::Logic::HIGH : Fw::Logic::LOW);
33+
}
34+
}
35+
36+
void Watchdog ::stop_handler(FwIndexType portNum) {
37+
// Set the stop flag to stop watchdog petting
38+
this->m_stopRequested = true;
39+
this->log_ACTIVITY_HI_WatchdogStop();
40+
}
41+
42+
// ----------------------------------------------------------------------
43+
// Handler implementations for commands
44+
// ----------------------------------------------------------------------
45+
46+
void Watchdog ::TEST_STOP_WATCHDOG_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
47+
// call stop handler
48+
this->stop_handler(0);
49+
50+
// Provide command response
51+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
52+
}
53+
54+
} // namespace Components
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module Components {
2+
@ Component to blink an LED as a watchdog petter, driven by a rate group
3+
passive component Watchdog {
4+
5+
@ Command to stop the watchdog petter
6+
sync command TEST_STOP_WATCHDOG(
7+
)
8+
9+
@ Telemetry channel counting watchdog petter transitions
10+
telemetry WatchdogTransitions: U32
11+
12+
@ Event logged when the watchdog petter LED turns on or off
13+
event WatchdogStop() \
14+
severity activity high \
15+
format "Watchdog no longer being pet!"
16+
17+
@ Port receiving calls from the rate group
18+
sync input port run: Svc.Sched
19+
20+
@ Port to stop the watchdog petting
21+
sync input port stop: Fw.Signal
22+
23+
@ Port sending calls to the GPIO driver
24+
output port gpioSet: Drv.GpioWrite
25+
26+
###############################################################################
27+
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
28+
###############################################################################
29+
@ Port for requesting the current time
30+
time get port timeCaller
31+
32+
@ Port for sending command registrations
33+
command reg port cmdRegOut
34+
35+
@ Port for receiving commands
36+
command recv port cmdIn
37+
38+
@ Port for sending command responses
39+
command resp port cmdResponseOut
40+
41+
@ Port for sending textual representation of events
42+
text event port logTextOut
43+
44+
@ Port for sending events to downlink
45+
event port logOut
46+
47+
@ Port for sending telemetry channels to downlink
48+
telemetry port tlmOut
49+
50+
}
51+
}

0 commit comments

Comments
 (0)