Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions FprimeZephyrReference/Components/Burnwire/Burnwire.cpp
Original file line number Diff line number Diff line change
@@ -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
88 changes: 88 additions & 0 deletions FprimeZephyrReference/Components/Burnwire/Burnwire.fpp
Original file line number Diff line number Diff line change
@@ -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

}
}
77 changes: 77 additions & 0 deletions FprimeZephyrReference/Components/Burnwire/Burnwire.hpp
Original file line number Diff line number Diff line change
@@ -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 <atomic>
#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<U32> 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
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/Burnwire/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
# )
61 changes: 61 additions & 0 deletions FprimeZephyrReference/Components/Burnwire/docs/sdd.md
Original file line number Diff line number Diff line change
@@ -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|
1 change: 1 addition & 0 deletions FprimeZephyrReference/Components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <zephyr/drivers/gpio.h>

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;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Loading