Skip to content

Commit 690abd6

Browse files
committed
Merge branch 'main' of github.com:Open-Source-Space-Foundation/proves-core-reference into rtc
2 parents ad4780f + b0fd33e commit 690abd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1269
-110
lines changed

.github/pull_request_template.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Pull Request Title (e.g., Feature: Add user authentication)
2+
3+
## Description
4+
5+
<!-- Provide a clear and concise description of the changes being introduced in this pull request. Explain the "why" behind the changes, not just the "what." -->
6+
7+
## Related Issues/Tickets
8+
9+
<!-- Link any relevant issues, tasks, or user stories (e.g., Closes #123, Fixes #456). -->
10+
11+
## How Has This Been Tested?
12+
13+
<!-- Describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. -->
14+
15+
- [ ] Unit tests
16+
- [ ] Integration tests
17+
- [ ] Z Tests
18+
- [ ] Manual testing (describe steps)
19+
20+
## Screenshots / Recordings (if applicable)
21+
22+
<!-- Provide screenshots or screen recordings that demonstrate the changes, especially for UI-related updates. -->
23+
24+
## Checklist
25+
26+
- [ ] Written detailed sdd with requirements, channels, ports, commands, telemetry defined and correctly formatted and spelled
27+
- [ ] Have written relevant integration tests and have documented them in the sdd
28+
- [ ] Have done a code review with
29+
- [ ] Have tested this PR on every supported board with correct board definitions
30+
31+
## Further Notes / Considerations

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ lib/zephyr-workspace/*
1818
.DS_Store
1919
*.gcov
2020
build
21+
settings.ini
2122

2223
**/__pycache__/
2324
**/*.egg-info/

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ repos:
2424
- id: cpplint
2525
args:
2626
- --config=cpplint.cfg
27+
28+
- repo: https://github.com/astral-sh/ruff-pre-commit
29+
rev: v0.13.2
30+
hooks:
31+
- id: ruff-check
32+
args: [--fix]
33+
- id: ruff-check
34+
args: [--fix, --select, I] # import sorting
35+
- id: ruff-format
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Include project-wide components here
22

3-
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv")
3+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
44
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
5+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ImuManager/")
56
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Helpers/")
2+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager/")
3+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lsm6dsoManager/")
14
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/RtcManager")
5+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Types/")
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
####
2+
# F Prime CMakeLists.txt:
3+
#
4+
# SOURCES: list of source files (to be compiled)
5+
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
6+
# DEPENDS: list of libraries that this module depends on
7+
#
8+
# More information in the F´ CMake API documentation:
9+
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
10+
#
11+
####
12+
13+
# Module names are derived from the path from the nearest project/library/framework
14+
# root when not specifically overridden by the developer. i.e. The module defined by
15+
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.
16+
17+
register_fprime_library(
18+
SOURCES
19+
"${CMAKE_CURRENT_LIST_DIR}/Helpers.cpp"
20+
DEPENDS
21+
Fw_Types
22+
)
23+
24+
### Unit Tests ###
25+
# register_fprime_ut(
26+
# AUTOCODER_INPUTS
27+
# "${CMAKE_CURRENT_LIST_DIR}/Helpers.fpp"
28+
# SOURCES
29+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/HelpersTestMain.cpp"
30+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/HelpersTester.cpp"
31+
# DEPENDS
32+
# STest # For rules-based testing
33+
# UT_AUTO_HELPERS
34+
# )
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// ======================================================================
2+
// \title Helpers.cpp
3+
// \brief cpp file for Helpers component implementation class
4+
// ======================================================================
5+
6+
#include "FprimeZephyrReference/Components/Drv/Helpers/Helpers.hpp"
7+
8+
#include <Fw/Types/Assert.hpp>
9+
10+
namespace Drv {
11+
12+
F64 sensor_value_to_f64(const struct sensor_value& val) {
13+
return val.val1 + (val.val2 / 1000000.0f);
14+
}
15+
16+
} // namespace Drv
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// ======================================================================
2+
// \title Helpers.hpp
3+
// \brief hpp file for Helpers component implementation class
4+
// ======================================================================
5+
6+
#ifndef Components_Helpers_HPP
7+
#define Components_Helpers_HPP
8+
9+
#include <Fw/Types/BasicTypes.h>
10+
#include <zephyr/drivers/sensor.h>
11+
12+
namespace Drv {
13+
14+
//! Convert a Zephyr sensor_value to an Fprime F64
15+
F64 sensor_value_to_f64(const struct sensor_value& val);
16+
17+
} // namespace Drv
18+
19+
#endif
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
####
2+
# F Prime CMakeLists.txt:
3+
#
4+
# SOURCES: list of source files (to be compiled)
5+
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
6+
# DEPENDS: list of libraries that this module depends on
7+
#
8+
# More information in the F´ CMake API documentation:
9+
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
10+
#
11+
####
12+
13+
# Module names are derived from the path from the nearest project/library/framework
14+
# root when not specifically overridden by the developer. i.e. The module defined by
15+
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.
16+
17+
register_fprime_library(
18+
AUTOCODER_INPUTS
19+
"${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager.fpp"
20+
SOURCES
21+
"${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager.cpp"
22+
DEPENDS
23+
FprimeZephyrReference_Components_Drv_Helpers
24+
)
25+
26+
### Unit Tests ###
27+
# register_fprime_ut(
28+
# AUTOCODER_INPUTS
29+
# "${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager.fpp"
30+
# SOURCES
31+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Lis2mdlManagerTestMain.cpp"
32+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Lis2mdlManagerTester.cpp"
33+
# DEPENDS
34+
# STest # For rules-based testing
35+
# UT_AUTO_HELPERS
36+
# )
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// ======================================================================
2+
// \title Lis2mdlManager.cpp
3+
// \brief cpp file for Lis2mdlManager component implementation class
4+
// ======================================================================
5+
6+
#include "FprimeZephyrReference/Components/Drv/Lis2mdlManager/Lis2mdlManager.hpp"
7+
8+
#include <Fw/Types/Assert.hpp>
9+
10+
namespace Drv {
11+
12+
// ----------------------------------------------------------------------
13+
// Component construction and destruction
14+
// ----------------------------------------------------------------------
15+
16+
Lis2mdlManager ::Lis2mdlManager(const char* const compName) : Lis2mdlManagerComponentBase(compName) {
17+
dev = device_get_binding("LIS2MDL");
18+
}
19+
20+
Lis2mdlManager ::~Lis2mdlManager() {}
21+
22+
// ----------------------------------------------------------------------
23+
// Handler implementations for typed input ports
24+
// ----------------------------------------------------------------------
25+
26+
Drv::MagneticField Lis2mdlManager ::magneticFieldGet_handler(FwIndexType portNum) {
27+
if (!device_is_ready(dev)) {
28+
this->log_WARNING_HI_DeviceNotReady();
29+
return Drv::MagneticField(0.0, 0.0, 0.0);
30+
}
31+
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();
32+
33+
struct sensor_value x;
34+
struct sensor_value y;
35+
struct sensor_value z;
36+
37+
sensor_sample_fetch_chan(dev, SENSOR_CHAN_MAGN_XYZ);
38+
39+
sensor_channel_get(dev, SENSOR_CHAN_MAGN_X, &x);
40+
sensor_channel_get(dev, SENSOR_CHAN_MAGN_Y, &y);
41+
sensor_channel_get(dev, SENSOR_CHAN_MAGN_Z, &z);
42+
43+
Drv::MagneticField magnetic_readings =
44+
Drv::MagneticField(Drv::sensor_value_to_f64(x), Drv::sensor_value_to_f64(y), Drv::sensor_value_to_f64(z));
45+
46+
this->tlmWrite_MagneticField(magnetic_readings);
47+
48+
return magnetic_readings;
49+
}
50+
51+
} // namespace Drv

0 commit comments

Comments
 (0)