diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 69eee65..6b931ce 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -42,7 +42,6 @@ jobs: - uses: fprime-community/project-builder@main with: build_location: BroncoDeployment - target_platform: rpipico - name: Archive binary uses: actions/upload-artifact@v4 with: diff --git a/BroncoDeployment/Top/BroncoDeploymentPackets.xml b/BroncoDeployment/Top/BroncoDeploymentPackets.xml index 76445dc..5af2348 100644 --- a/BroncoDeployment/Top/BroncoDeploymentPackets.xml +++ b/BroncoDeployment/Top/BroncoDeploymentPackets.xml @@ -53,6 +53,10 @@ + + + + diff --git a/BroncoDeployment/Top/BroncoDeploymentTopology.cpp b/BroncoDeployment/Top/BroncoDeploymentTopology.cpp index 69cfff7..36b6898 100644 --- a/BroncoDeployment/Top/BroncoDeploymentTopology.cpp +++ b/BroncoDeployment/Top/BroncoDeploymentTopology.cpp @@ -77,6 +77,9 @@ void configureTopology() { // Framer and Deframer components need to be passed a protocol handler framer.setup(framing); deframer.setup(deframing); + + // Open the Watchdog GPIO pin + gpioDriver.open(21, Arduino::GpioDriver::GpioDirection::OUT); } // Public functions for use in main program are namespaced with deployment name BroncoDeployment diff --git a/BroncoDeployment/Top/instances.fpp b/BroncoDeployment/Top/instances.fpp index 336e878..c221d21 100644 --- a/BroncoDeployment/Top/instances.fpp +++ b/BroncoDeployment/Top/instances.fpp @@ -28,6 +28,11 @@ module BroncoDeployment { stack size Default.STACK_SIZE \ priority 97 + instance watchdog: Components.Watchdog base id 0x0400 \ + queue size Default.QUEUE_SIZE \ + stack size Default.STACK_SIZE \ + priority 96 + # ---------------------------------------------------------------------- # Queued component instances # ---------------------------------------------------------------------- @@ -75,4 +80,5 @@ module BroncoDeployment { # Custom Connections instance broncoOreMessageHandler: Components.BroncoOreMessageHandler base id 0x6000 + instance gpioDriver: Arduino.GpioDriver base id 0x4C00 } diff --git a/BroncoDeployment/Top/topology.fpp b/BroncoDeployment/Top/topology.fpp index 0f6a974..368e21c 100644 --- a/BroncoDeployment/Top/topology.fpp +++ b/BroncoDeployment/Top/topology.fpp @@ -27,6 +27,7 @@ module BroncoDeployment { instance fatalAdapter instance fatalHandler instance framer + instance gpioDriver instance rateDriver instance rateGroup1 instance rateGroupDriver @@ -44,6 +45,7 @@ module BroncoDeployment { #custom instances instance broncoOreMessageHandler + instance watchdog # ---------------------------------------------------------------------- # Pattern graph specifiers @@ -72,6 +74,9 @@ module BroncoDeployment { rateGroup1.RateGroupMemberOut[0] -> commDriver.schedIn rateGroup1.RateGroupMemberOut[1] -> tlmSend.Run rateGroup1.RateGroupMemberOut[2] -> systemResources.run + + # Rate Group 1 (1Hz cycle) ouput is connected to watchdog's run input + rateGroup1.RateGroupMemberOut[3] -> watchdog.run } connections FaultProtection { @@ -107,7 +112,10 @@ module BroncoDeployment { connections BroncoDeployment { # Add here connections to user-defined components broncoOreMessageHandler.send_message -> hub.portIn[0] - hub.portOut[0] -> broncoOreMessageHandler.recv_message + hub.portOut[0] -> broncoOreMessageHandler.recv_message + + # watchdog's gpioSet output is connected to gpioDriver's gpioWrite input + watchdog.gpioSet -> gpioDriver.gpioWrite } connections HubConnections { diff --git a/Components/CMakeLists.txt b/Components/CMakeLists.txt index b46227b..d56540e 100644 --- a/Components/CMakeLists.txt +++ b/Components/CMakeLists.txt @@ -4,3 +4,4 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BroncoOreMessageHandler/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Radio/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog/") diff --git a/Components/Watchdog/CMakeLists.txt b/Components/Watchdog/CMakeLists.txt new file mode 100644 index 0000000..ed3f967 --- /dev/null +++ b/Components/Watchdog/CMakeLists.txt @@ -0,0 +1,14 @@ +#### +# F prime CMakeLists.txt: +# +# SOURCE_FILES: combined list of source and autocoding files +# MOD_DEPS: (optional) module dependencies +# UT_SOURCE_FILES: list of source files for unit tests +# +#### +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Watchdog.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Watchdog.cpp" +) + +register_fprime_module() diff --git a/Components/Watchdog/Watchdog.cpp b/Components/Watchdog/Watchdog.cpp new file mode 100644 index 0000000..28cc9ab --- /dev/null +++ b/Components/Watchdog/Watchdog.cpp @@ -0,0 +1,34 @@ +// ====================================================================== +// \title Watchdog.cpp +// \author nateinaction +// \brief cpp file for Watchdog component implementation class +// ====================================================================== + +#include "Components/Watchdog/Watchdog.hpp" +#include "FpConfig.hpp" + +namespace Components { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Watchdog ::Watchdog(const char* const compName) : WatchdogComponentBase(compName) {} + +Watchdog ::~Watchdog() {} + +// ---------------------------------------------------------------------- +// Handler implementations for user-defined typed input ports +// ---------------------------------------------------------------------- + +void Watchdog ::run_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) { + // TODO (nateinaction): Convet this to use the gpio output port when it works... + digitalWrite(21, (this->cycle_count % 2) == 0 ? HIGH : LOW); + + this->pet_count += (this->cycle_count % 2) == 0 ? 1 : 0; + this->tlmWrite_WatchdogPets(pet_count); + + this->cycle_count += 1; +} + +} // namespace Components diff --git a/Components/Watchdog/Watchdog.fpp b/Components/Watchdog/Watchdog.fpp new file mode 100644 index 0000000..69e940d --- /dev/null +++ b/Components/Watchdog/Watchdog.fpp @@ -0,0 +1,29 @@ +module Components { + @ Petting the Watch Dog to keep the satellite alive. + active component Watchdog { + + @ Port receiving calls from the rate group + async input port run: Svc.Sched + + @ Port sending calls to the GPIO driver + output port gpioSet: Drv.GpioWrite + + @ Telemetry channel to report watchdog pet count. + telemetry WatchdogPets: U64 + + ############################################################################### + # Standard AC Ports: Required for Channels, Events, Commands, and Parameters # + ############################################################################### + @ Port for requesting the current time + time get port timeCaller + + @ Port for sending textual representation of events + text event port logTextOut + + @ Port for sending events to downlink + event port logOut + + @ Port for sending telemetry channels to downlink + telemetry port tlmOut + } +} diff --git a/Components/Watchdog/Watchdog.hpp b/Components/Watchdog/Watchdog.hpp new file mode 100644 index 0000000..409ccff --- /dev/null +++ b/Components/Watchdog/Watchdog.hpp @@ -0,0 +1,47 @@ +// ====================================================================== +// \title Watchdog.hpp +// \author nate +// \brief hpp file for Watchdog component implementation class +// ====================================================================== + +#ifndef Components_Watchdog_HPP +#define Components_Watchdog_HPP + +#include "Components/Watchdog/WatchdogComponentAc.hpp" +#include + +namespace Components { + +class Watchdog : public WatchdogComponentBase { + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Watchdog object + Watchdog(const char* const compName //!< The component name + ); + + //! Destroy Watchdog object + ~Watchdog(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Handler implementations for user-defined typed input ports + // ---------------------------------------------------------------------- + + //! Handler implementation for run + //! + //! Port receiving calls from the rate group + void run_handler(NATIVE_INT_TYPE portNum, //!< The port number + NATIVE_UINT_TYPE context //!< The call order + ) override; + + PRIVATE: + U64 pet_count = 0; + U64 cycle_count = 0; +}; + +} // namespace Components + +#endif