-
Notifications
You must be signed in to change notification settings - Fork 13
Add Pico Temperature Manager #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5197cb4
Add Pico Temperature Manager
JamesDCowley 4ec8065
Fix topology errors
JamesDCowley a29da49
Fix build casing on telemetry, fix error logging
JamesDCowley 2a81965
Fix errors, now builds
JamesDCowley fec7532
Add die_temp to device tree
JamesDCowley bb07517
add deinit function
JamesDCowley ab94d00
fix lint errors
JamesDCowley 6a0ed55
Office hours debugging
nateinaction 6dd4c2a
idk
nateinaction 8067d8e
add integration test
JamesDCowley be28276
typo
JamesDCowley 4ec2d40
try adding io-channel
JamesDCowley d71cb50
Working
nateinaction 999bd6d
fix integration test
JamesDCowley 7aabe10
fix int test pt2
JamesDCowley f6dab6c
Change command string
nateinaction b65ead5
Add documentation
JamesDCowley 1886786
Merge branch 'main' into pico-temp-manager
JamesDCowley e2e1fad
Integrate Pico die temperature sensor into ThermalManager and update …
JamesDCowley 1fe1f35
Remove unused events and functions
JamesDCowley 4f4c76f
Merge branch 'main' into pico-temp-manager
JamesDCowley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
PROVESFlightControllerReference/Components/Drv/PicoTempManager/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| # `MyProj/Some/Path/CMakeLists.txt` will be named `MyProj_Some_Path`. | ||
|
|
||
| register_fprime_library( | ||
| AUTOCODER_INPUTS | ||
| "${CMAKE_CURRENT_LIST_DIR}/PicoTempManager.fpp" | ||
| SOURCES | ||
| "${CMAKE_CURRENT_LIST_DIR}/PicoTempManager.cpp" | ||
| # DEPENDS | ||
| # MyPackage_MyOtherModule | ||
| ) | ||
|
|
||
| ### Unit Tests ### | ||
| # register_fprime_ut( | ||
| # AUTOCODER_INPUTS | ||
| # "${CMAKE_CURRENT_LIST_DIR}/PicoTempManager.fpp" | ||
| # SOURCES | ||
| # "${CMAKE_CURRENT_LIST_DIR}/test/ut/PicoTempManagerTestMain.cpp" | ||
| # "${CMAKE_CURRENT_LIST_DIR}/test/ut/PicoTempManagerTester.cpp" | ||
| # DEPENDS | ||
| # STest # For rules-based testing | ||
| # UT_AUTO_HELPERS | ||
| # ) |
84 changes: 84 additions & 0 deletions
84
PROVESFlightControllerReference/Components/Drv/PicoTempManager/PicoTempManager.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // ====================================================================== | ||
| // \title PicoTempManager.cpp | ||
| // \brief cpp file for PicoTempManager component implementation class | ||
| // ====================================================================== | ||
|
|
||
| #include "PROVESFlightControllerReference/Components/Drv/PicoTempManager/PicoTempManager.hpp" | ||
|
|
||
| namespace Drv { | ||
|
|
||
| // ---------------------------------------------------------------------- | ||
| // Component construction and destruction | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| PicoTempManager ::PicoTempManager(const char* const compName) : PicoTempManagerComponentBase(compName) {} | ||
|
|
||
| PicoTempManager ::~PicoTempManager() {} | ||
|
|
||
| // ---------------------------------------------------------------------- | ||
| // Public helper methods | ||
| // ---------------------------------------------------------------------- | ||
| void PicoTempManager::configure(const struct device* dev) { | ||
| this->m_dev = dev; | ||
| } | ||
|
|
||
| // ---------------------------------------------------------------------- | ||
| // Handler implementations for typed input ports | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| F64 PicoTempManager ::picoTemperatureGet_handler(FwIndexType portNum, Fw::Success& condition) { | ||
| condition = Fw::Success::FAILURE; | ||
| F64 temperature = this->getPicoTemperature(condition); | ||
| if (condition != Fw::Success::SUCCESS) { | ||
| return 0; | ||
| } | ||
| this->tlmWrite_PicoTemperature(temperature); | ||
| return temperature; | ||
| } | ||
|
|
||
| // ---------------------------------------------------------------------- | ||
| // Handler implementations for commands | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| void PicoTempManager ::GetPicoTemperature_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { | ||
| Fw::Success condition = Fw::Success::FAILURE; | ||
| F64 temperature = this->getPicoTemperature(condition); | ||
| if (condition != Fw::Success::SUCCESS) { | ||
| this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR); | ||
| return; | ||
| } | ||
|
nateinaction marked this conversation as resolved.
|
||
| this->log_ACTIVITY_HI_PicoTemperature(temperature); | ||
| this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); | ||
| } | ||
|
|
||
| // ---------------------------------------------------------------------- | ||
| // Private helper methods | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| F64 PicoTempManager ::getPicoTemperature(Fw::Success& condition) { | ||
| if (!device_is_ready(this->m_dev)) { | ||
| this->log_WARNING_LO_DeviceNotReady(); | ||
| return 0; | ||
| } | ||
| this->log_WARNING_LO_DeviceNotReady_ThrottleClear(); | ||
|
nateinaction marked this conversation as resolved.
|
||
|
|
||
| int rc = sensor_sample_fetch(this->m_dev); | ||
| if (rc != 0) { | ||
| this->log_WARNING_LO_SensorSampleFetchFailed(rc); | ||
| return 0; | ||
| } | ||
| this->log_WARNING_LO_SensorSampleFetchFailed_ThrottleClear(); | ||
|
|
||
| struct sensor_value temp_val; | ||
| rc = sensor_channel_get(this->m_dev, SENSOR_CHAN_DIE_TEMP, &temp_val); | ||
| if (rc != 0) { | ||
| this->log_WARNING_LO_SensorChannelGetFailed(rc); | ||
| return 0.0; | ||
| } | ||
| this->log_WARNING_LO_SensorChannelGetFailed_ThrottleClear(); | ||
| F64 temp = sensor_value_to_double(&temp_val); | ||
| condition = Fw::Success::SUCCESS; | ||
| return temp; | ||
| } | ||
|
|
||
| } // namespace Drv | ||
59 changes: 59 additions & 0 deletions
59
PROVESFlightControllerReference/Components/Drv/PicoTempManager/PicoTempManager.fpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| module Drv { | ||
| port picoTemperatureGet(ref condition: Fw.Success) -> F64 | ||
| } | ||
|
|
||
| module Drv { | ||
| @ Manager for the RP2350's built in temperature sensor | ||
| passive component PicoTempManager { | ||
|
|
||
| #### Ports #### | ||
| @ Port to read the die temperature in degrees Celsius | ||
| sync input port picoTemperatureGet: picoTemperatureGet | ||
|
|
||
| #### Commands #### | ||
| @ Command to get the temperature in degrees Celsius | ||
| sync command GetPicoTemperature() | ||
|
|
||
| #### Telemetry #### | ||
| @ Telemetry channel for temperature in degrees Celsius | ||
| telemetry PicoTemperature: F64 | ||
|
|
||
| @ Event for reporting not ready error | ||
| event DeviceNotReady() severity warning low format "Device not ready" throttle 5 | ||
|
|
||
| @ Event for reporting sensor fetch failure | ||
| event SensorSampleFetchFailed(ret: I32) severity warning low format "Sensor fetch failed with return code: {}" throttle 5 | ||
|
|
||
| @ Event for reporting sensor channel get failure | ||
| event SensorChannelGetFailed(ret: I32) severity warning low format "Sensor channel get failed with return code: {}" throttle 5 | ||
|
|
||
| @ Event for reporting temperature | ||
| event PicoTemperature(temperature: F64) severity activity high format "Pico Temperature: {}°C" | ||
|
|
||
| ############################################################################### | ||
| # 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 | ||
|
|
||
|
|
||
| } | ||
| } |
79 changes: 79 additions & 0 deletions
79
PROVESFlightControllerReference/Components/Drv/PicoTempManager/PicoTempManager.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // ====================================================================== | ||
| // \title PicoTempManager.hpp | ||
| // \brief hpp file for PicoTempManager component implementation class | ||
| // ====================================================================== | ||
|
|
||
| #ifndef Drv_PicoTempManager_HPP | ||
| #define Drv_PicoTempManager_HPP | ||
|
|
||
| #include "Fw/Types/SuccessEnumAc.hpp" | ||
| #include "PROVESFlightControllerReference/Components/Drv/PicoTempManager/PicoTempManagerComponentAc.hpp" | ||
| #include <zephyr/device.h> | ||
| #include <zephyr/drivers/sensor.h> | ||
| #include <zephyr/kernel.h> | ||
|
|
||
| namespace Drv { | ||
|
|
||
| class PicoTempManager final : public PicoTempManagerComponentBase { | ||
| public: | ||
| // ---------------------------------------------------------------------- | ||
| // Component construction and destruction | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| //! Construct PicoTempManager object | ||
| PicoTempManager(const char* const compName //!< The component name | ||
| ); | ||
|
|
||
| //! Destroy PicoTempManager object | ||
| ~PicoTempManager(); | ||
|
|
||
| public: | ||
| // ---------------------------------------------------------------------- | ||
| // Public helper methods | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| //! Configure the die_temp device | ||
| void configure(const struct device* dev); | ||
|
|
||
| private: | ||
| // ---------------------------------------------------------------------- | ||
| // Handler implementations for typed input ports | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| //! Port handler for getting the die temperature in degrees Celsius | ||
| F64 picoTemperatureGet_handler(FwIndexType portNum, //!< The port number | ||
| Fw::Success& condition //!< The call order | ||
| ) override; | ||
|
|
||
| private: | ||
| // ---------------------------------------------------------------------- | ||
| // Handler implementations for commands | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| //! Handler implementation for command GetTemperature | ||
| //! | ||
| //! Command to get the temperature in degrees Celsius | ||
| void GetPicoTemperature_cmdHandler(FwOpcodeType opCode, //!< The opcode | ||
| U32 cmdSeq //!< The command sequence number | ||
| ) override; | ||
|
|
||
| private: | ||
| // ---------------------------------------------------------------------- | ||
| // Private helper methods | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| //! Get the temperature in degrees Celsius from the die_temp device | ||
| F64 getPicoTemperature(Fw::Success& condition); | ||
|
|
||
| private: | ||
| // ---------------------------------------------------------------------- | ||
| // Private member variables | ||
| // ---------------------------------------------------------------------- | ||
|
|
||
| //! Zephyr device stores the initialized die_temp sensor | ||
| const struct device* m_dev; | ||
| }; | ||
|
|
||
| } // namespace Drv | ||
|
|
||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.