diff --git a/FprimeZephyrReference/Components/Burnwire/Burnwire.cpp b/FprimeZephyrReference/Components/Burnwire/Burnwire.cpp new file mode 100644 index 00000000..b88b1c22 --- /dev/null +++ b/FprimeZephyrReference/Components/Burnwire/Burnwire.cpp @@ -0,0 +1,89 @@ +// ====================================================================== +// \title Burnwire.cpp +// \author aldjia +// \brief cpp file for Burnwire component implementation class +// ====================================================================== + +#include "FprimeZephyrReference/Components/Burnwire/Burnwire.hpp" + +namespace Components { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Burnwire ::Burnwire(const char* const compName) : BurnwireComponentBase(compName) { + this->m_safetyCounter = 0; + this->m_state = Fw::On::OFF; +} + +Burnwire ::~Burnwire() {} + +// ---------------------------------------------------------------------- +// Handler implementations for typed input ports +// ---------------------------------------------------------------------- +void Burnwire ::burnStart_handler(FwIndexType portNum) { + this->startBurn(); +} + +void Burnwire ::burnStop_handler(FwIndexType portNum) { + this->stopBurn(); +} + +// void Burnwire ::stop_handler(FwIndexType portNum) { +// //TODO +// } + +void Burnwire::startBurn() { + this->m_safetyCounter = 0; + this->m_state = Fw::On::ON; + this->log_ACTIVITY_HI_SetBurnwireState(Fw::On::ON); + + Fw::ParamValid valid; + U32 timeout = this->paramGet_SAFETY_TIMER(valid); + this->log_ACTIVITY_HI_SafetyTimerState(timeout); +} + +void Burnwire::stopBurn() { + this->m_state = Fw::On::OFF; + this->log_ACTIVITY_HI_SetBurnwireState(Fw::On::OFF); + this->gpioSet_out(0, Fw::Logic::LOW); + this->gpioSet_out(1, Fw::Logic::LOW); +} + +void Burnwire ::schedIn_handler(FwIndexType portNum, U32 context) { + if (this->m_state == Fw::On::ON) { + this->m_safetyCounter++; + if (this->m_safetyCounter == 1) { + this->gpioSet_out(0, Fw::Logic::HIGH); + this->gpioSet_out(1, Fw::Logic::HIGH); + this->log_ACTIVITY_HI_SafetyTimerStatus(Fw::On::ON); + } + + if (this->m_safetyCounter >= this->m_safetyMaxCount) { + // 30 seconds reached → turn OFF + this->gpioSet_out(0, Fw::Logic::LOW); + this->gpioSet_out(1, Fw::Logic::LOW); + + this->m_state = Fw::On::OFF; + this->log_ACTIVITY_HI_SetBurnwireState(Fw::On::OFF); + this->log_ACTIVITY_HI_SafetyTimerStatus(Fw::On::OFF); + } + } +} + +// ---------------------------------------------------------------------- +// Handler implementations for commands +// ---------------------------------------------------------------------- + +void Burnwire ::START_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { + this->startBurn(); + this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); +} + +void Burnwire ::STOP_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { + this->stopBurn(); + this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); +} + +} // namespace Components diff --git a/FprimeZephyrReference/Components/Burnwire/Burnwire.fpp b/FprimeZephyrReference/Components/Burnwire/Burnwire.fpp new file mode 100644 index 00000000..8070e1fe --- /dev/null +++ b/FprimeZephyrReference/Components/Burnwire/Burnwire.fpp @@ -0,0 +1,88 @@ +module Components { + @ Turns Burnwire on and off + passive component Burnwire { + + ############################################################################## + #### Uncomment the following examples to start customizing your component #### + ############################################################################## + + # @ Examplesync command + sync command START_BURNWIRE( + ) + + + + sync command STOP_BURNWIRE( + ) + + + # @ Example telemetry counter + # telemetry ExampleCounter: U64 + + # @ Example event + # event ExampleStateEvent(example_state: Fw.On) severity activity high id 0 format "State set to {}" + event SetBurnwireState(burnwire_state: Fw.On) \ + severity activity high \ + format "Burnwire State: {}" + + event SafetyTimerStatus(burnwire_state: Fw.On) \ + severity activity high\ + format "Safety Timer State: {} " + + + event SafetyTimerState(burnwire_status: U32) \ + severity activity high\ + format "Safety Timer State: {} " + + + # @ Example port: receiving calls from the rate group + # sync input port run: Svc.Sched + + @ Port getting start signal + sync input port burnStart: Fw.Signal + + @ Port getting stop signal + sync input port burnStop: Fw.Signal + + @ Input Port to get the rate group + sync input port schedIn: Svc.Sched + + @ Port sending calls to the GPIO driver to stop and start the burnwire + output port gpioSet: [2] Drv.GpioWrite + + # @ Example parameter + # param PARAMETER_NAME: U32 + param SAFETY_TIMER: U32 default 10 + + ############################################################################### + # Standard AC Ports: Required for Channels, Events, Commands, and Parameters # + ############################################################################### + @ Port for requesting the current time + time get port timeCaller + + @ Port for sending command registrations + command reg port cmdRegOut + + @ Port for receiving commands + command recv port cmdIn + + @ Port for sending command responses + command resp port cmdResponseOut + + @ 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 + + @ Port to return the value of a parameter + param get port prmGetOut + + @Port to set the value of a parameter + param set port prmSetOut + + } +} diff --git a/FprimeZephyrReference/Components/Burnwire/Burnwire.hpp b/FprimeZephyrReference/Components/Burnwire/Burnwire.hpp new file mode 100644 index 00000000..56438929 --- /dev/null +++ b/FprimeZephyrReference/Components/Burnwire/Burnwire.hpp @@ -0,0 +1,77 @@ +// ====================================================================== +// \title Burnwire.hpp +// \author aldjia +// \brief hpp file for Burnwire component implementation class +// ====================================================================== + +#ifndef Components_Burnwire_HPP +#define Components_Burnwire_HPP + +#include +#include "FprimeZephyrReference/Components/Burnwire/BurnwireComponentAc.hpp" + +namespace Components { + +class Burnwire final : public BurnwireComponentBase { + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Burnwire object + Burnwire(const char* const compName //!< The component name + ); + + //! Destroy Burnwire object + ~Burnwire(); + + private: + // ---------------------------------------------------------------------- + // Handler implementations for typed input ports + // ---------------------------------------------------------------------- + + //! Handler implementation for stop + //! + //! Port to start and stop the burnwire + + //! Handler implementation for burnStart + //! + //! Port getting start signal + void burnStart_handler(FwIndexType portNum //!< The port number + ) override; + + //! Handler implementation for burnStop + //! + //! Port getting stop signal + void burnStop_handler(FwIndexType portNum //!< The port number + ) override; + + void schedIn_handler(FwIndexType portNum, //!< The port number + U32 context //!< The call order + ) override; + + // helper functions + void startBurn(); + + void stopBurn(); + + private: + // ---------------------------------------------------------------------- + // Handler implementations for commands + // ---------------------------------------------------------------------- + + //! Handler implementation for command START_BURNWIRE + void START_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) override; + + //! Handler implementation for command STOP_BURNWIRE + void STOP_BURNWIRE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) override; + + Fw::On m_state = Fw::On::OFF; // keeps track if burnwire is on or off + std::atomic m_safetyCounter; // makes this an atomic variable (so its set only in one command), + // you read and write half the value bc a corrupted read could be dangerouts + U32 m_safetyMaxCount = 3; // max count for safety timer - 3 seconds for now, change to be very large before flight +}; + +} // namespace Components + +#endif diff --git a/FprimeZephyrReference/Components/Burnwire/CMakeLists.txt b/FprimeZephyrReference/Components/Burnwire/CMakeLists.txt new file mode 100644 index 00000000..5e68dc91 --- /dev/null +++ b/FprimeZephyrReference/Components/Burnwire/CMakeLists.txt @@ -0,0 +1,36 @@ +#### +# F Prime CMakeLists.txt: +# +# SOURCES: list of source files (to be compiled) +# AUTOCODER_INPUTS: list of files to be passed to the autocoders +# DEPENDS: list of libraries that this module depends on +# +# More information in the F´ CMake API documentation: +# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/ +# +#### + +# Module names are derived from the path from the nearest project/library/framework +# root when not specifically overridden by the developer. i.e. The module defined by +# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`. + +register_fprime_library( + AUTOCODER_INPUTS + "${CMAKE_CURRENT_LIST_DIR}/Burnwire.fpp" + SOURCES + "${CMAKE_CURRENT_LIST_DIR}/Burnwire.cpp" +# DEPENDS +# MyPackage_MyOtherModule +) + +### Unit Tests ### +# register_fprime_ut( +# AUTOCODER_INPUTS +# "${CMAKE_CURRENT_LIST_DIR}/Burnwire.fpp" +# SOURCES +# "${CMAKE_CURRENT_LIST_DIR}/test/ut/BurnwireTestMain.cpp" +# "${CMAKE_CURRENT_LIST_DIR}/test/ut/BurnwireTester.cpp" +# DEPENDS +# STest # For rules-based testing +# UT_AUTO_HELPERS +# ) diff --git a/FprimeZephyrReference/Components/Burnwire/docs/sdd.md b/FprimeZephyrReference/Components/Burnwire/docs/sdd.md new file mode 100644 index 00000000..d49b7a9f --- /dev/null +++ b/FprimeZephyrReference/Components/Burnwire/docs/sdd.md @@ -0,0 +1,61 @@ +# Components::Burnwire + +Driving the Burnwire on and off. This component activates the two pins that are required to heat the burnwire resisitor. The burnwire deployment will be handled by the Antenna Deployment, that will call the ports in the burnwire deployment. For testing, the commands to directly call the burnwire have been left in. + +Burnwire is agnostic to the ideal safety count, it simply sets it to be whatever the port or command passes onto + +## Sequence Diagrams +Add sequence diagrams here + +## Requirements +Add requirements in the chart below +| Name | Description | Validation | +| ---- | ----------- | ------ | +|BW-001|The burnwire shall turn on and off in response to a port calls (TBR for antenna deployer component) |Hardware Test| +|BW-002|The burnwire shall turn on and off in response to commands (TBR for testing for now) |Hardware Test| +|BW-003|The burnwire component shall provide an event when it is turned on and off |Integration Test| +|BW-004|The burnwire component shall activate by turning both the GPIO pins that activate the burnwire | Hardware Test| +|BW-005|The burnwire component shall be controlled by a safety timeout attached to a 1Hz rate group |Integration Test| +|BW-006|The safety timeout shall emit an event when it is changes | Integration test| +|BW-007|The burnwire safety time shall emit an event when it starts and stops |Integration Test| + +## Port Descriptions +Name | Type | Description | +|----|---|---| +|burnStop|`Fw::Signal`|Receive stop signal to stop the burnwire| +|burnStart|`Fw::Signal`|Receive start signal to start burnwire| +|gpioSet|`Drv::GpioWrite`|Control GPIO state to driver| +|schedIn|[`Svc::Sched`]| run | Input | Synchronous | Receive periodic calls from rate group + + +## Commands +| Name | Description | +| ---- | ----------- | +|START_BURNWIRE|Starts the Burn. Takes a argument max_duration which sets the parameter safetyMaxCount to timeout the burnwire| +|STOP_BURNWIRE|Stops the Burn| + +## Events +| Name | Description | +|---|---| +|SetBurnwireState| Emits burnwire state when the burnwire turns on or off| +|SafetyTimerStatus| Emits safety timer state when the Safety Time has stopped or started| +|SafetyTimerState| Emits the amount of time the safety time will run for when it starts| + + +## Component States +Add component states in the chart below +| Name | Description | +|----|---| +|m_state|Keeps track if the burnwire is on or off| + +## Unit Tests +Add unit test descriptions in the chart below +| Name | Description | Output | Coverage | +|TestSafety|Tests Burnwire turns off after X seconds|---|---| +|TestOn|Tests right GPIO pins turn on |---|---| +|TestOn|Tests right GPIO pins turn off, same as |---|---| + + +## Parameter +| Name | Description | +| SAFETY_TIMER | By Default set in fpp (currently 10) is the max time the burnwire should ever run| diff --git a/FprimeZephyrReference/Components/CMakeLists.txt b/FprimeZephyrReference/Components/CMakeLists.txt index 08ac562c..df7757f4 100644 --- a/FprimeZephyrReference/Components/CMakeLists.txt +++ b/FprimeZephyrReference/Components/CMakeLists.txt @@ -5,3 +5,4 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ImuManager/") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/") diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp b/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp index 4e3bb311..d06583fa 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp @@ -14,6 +14,8 @@ #include static const struct gpio_dt_spec ledGpio = GPIO_DT_SPEC_GET(DT_NODELABEL(led0), gpios); +static const struct gpio_dt_spec burnwire0Gpio = GPIO_DT_SPEC_GET(DT_NODELABEL(burnwire0), gpios); +static const struct gpio_dt_spec burnwire1Gpio = GPIO_DT_SPEC_GET(DT_NODELABEL(burnwire1), gpios); // Allows easy reference to objects in FPP/autocoder required namespaces using namespace ReferenceDeployment; @@ -55,6 +57,8 @@ void configureTopology() { rateGroup1Hz.configure(rateGroup1HzContext, FW_NUM_ARRAY_ELEMENTS(rateGroup1HzContext)); gpioDriver.open(ledGpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT); + gpioBurnwire0.open(burnwire0Gpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT); + gpioBurnwire1.open(burnwire1Gpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT); } // Public functions for use in main program are namespaced with deployment name ReferenceDeployment diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp b/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp index 1dff4a28..d3e41826 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp @@ -59,6 +59,10 @@ module ReferenceDeployment { instance gpioDriver: Zephyr.ZephyrGpioDriver base id 0x10014000 + instance gpioBurnwire0: Zephyr.ZephyrGpioDriver base id 0x10021100 + + instance gpioBurnwire1: Zephyr.ZephyrGpioDriver base id 0x10021200 + instance watchdog: Components.Watchdog base id 0x10015000 instance rtcManager: Drv.RtcManager base id 0x10016000 @@ -70,4 +74,6 @@ module ReferenceDeployment { instance lsm6dsoManager: Drv.Lsm6dsoManager base id 0x10019000 instance bootloaderTrigger: Components.BootloaderTrigger base id 0x10020000 + + instance burnwire: Components.Burnwire base id 0x10021000 } diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp b/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp index 4f42fd3b..5318672f 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp @@ -33,6 +33,9 @@ module ReferenceDeployment { instance lis2mdlManager instance lsm6dsoManager instance bootloaderTrigger + instance gpioBurnwire0 + instance gpioBurnwire1 + instance burnwire # ---------------------------------------------------------------------- # Pattern graph specifiers # ---------------------------------------------------------------------- @@ -96,12 +99,18 @@ module ReferenceDeployment { rateGroup1Hz.RateGroupMemberOut[3] -> CdhCore.tlmSend.Run rateGroup1Hz.RateGroupMemberOut[4] -> watchdog.run rateGroup1Hz.RateGroupMemberOut[5] -> imuManager.run + rateGroup1Hz.RateGroupMemberOut[6] -> burnwire.schedIn } connections Watchdog { watchdog.gpioSet -> gpioDriver.gpioWrite } + connections BurnwireGpio { + burnwire.gpioSet[0] -> gpioBurnwire0.gpioWrite + burnwire.gpioSet[1] -> gpioBurnwire1.gpioWrite + } + connections imuManager { imuManager.accelerationGet -> lsm6dsoManager.accelerationGet imuManager.angularVelocityGet -> lsm6dsoManager.angularVelocityGet diff --git a/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi b/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi index e93b7426..397708c7 100644 --- a/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi +++ b/boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi @@ -24,6 +24,14 @@ gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>; label = "Watchdog LED"; }; + burnwire0: burnwire0{ + gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>; + label = "burnwire 0"; + }; + burnwire1: burnwire1{ + gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>; + label = "burnwire 1"; + }; }; }; diff --git a/settings.ini b/settings.ini index d27e929f..dde51b9e 100644 --- a/settings.ini +++ b/settings.ini @@ -7,4 +7,4 @@ default_toolchain: zephyr default_cmake_options: FPRIME_ENABLE_FRAMEWORK_UTS=OFF FPRIME_ENABLE_AUTOCODER_UTS=OFF BOARD_ROOT=. - BOARD=proves_flight_control_board_v5c/rp2350a/m33 + BOARD=proves_flight_control_board_v5d/rp2350a/m33