Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5cfb45d
Use custom board definition
nateinaction Sep 7, 2025
74bf7a6
Initial IMU component generation
hrfarmer Aug 28, 2025
b4203c9
Initial imu data pull
nateinaction Sep 7, 2025
f110ce2
Reading magnetic field data
nateinaction Sep 7, 2025
8e30497
Add new telemetry for accel and angvel
nateinaction Sep 8, 2025
f4c903f
Acceleration and AngularVelocity telemetry working
nateinaction Sep 8, 2025
4caa93c
Add temp
nateinaction Sep 8, 2025
55eeb0a
Improve documentation
nateinaction Sep 9, 2025
981de3e
Update FprimeZephyrReference/Components/Imu/docs/sdd.md
nateinaction Sep 9, 2025
e44fa63
Add LIS2MDL driver & implement in Imu component (#16)
hrfarmer Sep 18, 2025
8478ca1
Create lsm6dso driver component & implementation (#17)
asiemsen Sep 18, 2025
d064a09
Spit out common helpers and types from drivers, standardize port name…
nateinaction Sep 18, 2025
4e3cb5b
Merge branch 'main' of github.com:Open-Source-Space-Foundation/proves…
nateinaction Sep 18, 2025
c0424fb
Merge branch 'main' of github.com:Open-Source-Space-Foundation/proves…
nateinaction Sep 18, 2025
d66c949
Remove unnecessary board files
nateinaction Sep 18, 2025
4ad69fc
remove fpp helper file
asiemsen Sep 22, 2025
36d5278
finished renaming to build
asiemsen Sep 22, 2025
d8fce1f
add parentheses for clearer intentions
asiemsen Sep 22, 2025
516d730
remove FW_ASSERTs
asiemsen Sep 22, 2025
8e4e8d2
clear throttle after successful device ready check
asiemsen Sep 23, 2025
991b010
adding telemetry to lis2mdlManager
asiemsen Sep 23, 2025
b73dec0
Merge branch 'main' into imu2_PR_changes_saidi
hrfarmer Sep 26, 2025
cac1bfc
fix fprime files to match new names & telemetry structure
hrfarmer Sep 26, 2025
8a395c2
edit cpp implementation files to output telemetry
hrfarmer Sep 26, 2025
ac7fd7b
formatting
hrfarmer Sep 26, 2025
f1e5405
Merge pull request #27 from Open-Source-Space-Foundation/imu2_PR_chan…
nateinaction Sep 27, 2025
8fed4e3
clear throttle, configure lsm6 sensor, read->get
nateinaction Sep 27, 2025
adf6b8e
Add IMU tests
nateinaction Sep 27, 2025
19042fb
Add type hinting
nateinaction Sep 28, 2025
5b41b97
Comment fix
nateinaction Sep 28, 2025
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
2 changes: 2 additions & 0 deletions FprimeZephyrReference/Components/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Include project-wide components here

add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ImuManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
5 changes: 5 additions & 0 deletions FprimeZephyrReference/Components/Drv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Include project-wide components here
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Helpers/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lsm6dsoManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Types/")
34 changes: 34 additions & 0 deletions FprimeZephyrReference/Components/Drv/Helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
####
# 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(
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/Helpers.cpp"
DEPENDS
Fw_Types
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/Helpers.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/HelpersTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/HelpersTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
16 changes: 16 additions & 0 deletions FprimeZephyrReference/Components/Drv/Helpers/Helpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// ======================================================================
// \title Helpers.cpp
// \brief cpp file for Helpers component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/Drv/Helpers/Helpers.hpp"

#include <Fw/Types/Assert.hpp>

namespace Drv {

F64 sensor_value_to_f64(const struct sensor_value& val) {
return val.val1 + (val.val2 / 1000000.0f);
}

} // namespace Drv
19 changes: 19 additions & 0 deletions FprimeZephyrReference/Components/Drv/Helpers/Helpers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ======================================================================
// \title Helpers.hpp
// \brief hpp file for Helpers component implementation class
// ======================================================================

#ifndef Components_Helpers_HPP
#define Components_Helpers_HPP

#include <Fw/Types/BasicTypes.h>
#include <zephyr/drivers/sensor.h>

namespace Drv {

//! Convert a Zephyr sensor_value to an Fprime F64
F64 sensor_value_to_f64(const struct sensor_value& val);

} // namespace Drv

#endif
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/Drv/Lis2mdlManager/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}/Lis2mdlManager.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager.cpp"
DEPENDS
FprimeZephyrReference_Components_Drv_Helpers
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Lis2mdlManagerTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Lis2mdlManagerTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
Copy link
Collaborator Author

@nateinaction nateinaction Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to Lis2mdlManager but leave in Drv folder and namespace

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ======================================================================
// \title Lis2mdlManager.cpp
// \brief cpp file for Lis2mdlManager component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/Drv/Lis2mdlManager/Lis2mdlManager.hpp"

#include <Fw/Types/Assert.hpp>

namespace Drv {

// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

Lis2mdlManager ::Lis2mdlManager(const char* const compName) : Lis2mdlManagerComponentBase(compName) {
dev = device_get_binding("LIS2MDL");
}

Lis2mdlManager ::~Lis2mdlManager() {}

// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

Drv::MagneticField Lis2mdlManager ::magneticFieldGet_handler(FwIndexType portNum) {
if (!device_is_ready(dev)) {
this->log_WARNING_HI_DeviceNotReady();
return Drv::MagneticField(0.0, 0.0, 0.0);
}
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();

struct sensor_value x;
struct sensor_value y;
struct sensor_value z;

sensor_sample_fetch_chan(dev, SENSOR_CHAN_MAGN_XYZ);

sensor_channel_get(dev, SENSOR_CHAN_MAGN_X, &x);
sensor_channel_get(dev, SENSOR_CHAN_MAGN_Y, &y);
sensor_channel_get(dev, SENSOR_CHAN_MAGN_Z, &z);

Drv::MagneticField magnetic_readings =
Drv::MagneticField(Drv::sensor_value_to_f64(x), Drv::sensor_value_to_f64(y), Drv::sensor_value_to_f64(z));

this->tlmWrite_MagneticField(magnetic_readings);

return magnetic_readings;
}

} // namespace Drv
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Port definition
module Drv {
port MagneticFieldGet -> MagneticField
}

# Component definition
module Drv {
@ LIS2MDL Manager Component for F Prime FSW framework.
passive component Lis2mdlManager {
@ Port to read the current magnetic field in gauss.
sync input port magneticFieldGet: MagneticFieldGet

@ Event for reporting LSM6DSO not ready error
event DeviceNotReady() severity warning high format "LIS2MDL device not ready" throttle 5

@ Telemetry channel for magnetic field in gauss
telemetry MagneticField: MagneticField


###############################################################################
# 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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// ======================================================================
// \title Lis2mdlManager.hpp
// \brief hpp file for Lis2mdlManager component implementation class
// ======================================================================

#ifndef Components_Lis2mdlManager_HPP
#define Components_Lis2mdlManager_HPP

// clang-format off
// Keep the includes in this order
#include "FprimeZephyrReference/Components/Drv/Lis2mdlManager/Lis2mdlManagerComponentAc.hpp"
#include "FprimeZephyrReference/Components/Drv/Helpers/Helpers.hpp"
// clang-format on

#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/kernel.h>

namespace Drv {

class Lis2mdlManager final : public Lis2mdlManagerComponentBase {
public:
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

//! Construct Lis2mdlManager object
Lis2mdlManager(const char* const compName);

//! Destroy Lis2mdlManager object
~Lis2mdlManager();

private:
// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

//! Get the magnetic field reading from the LIS2MDL sensor
Drv::MagneticField magneticFieldGet_handler(const FwIndexType portNum //!< The port number
) override;

// ----------------------------------------------------------------------
// Member variables
// ----------------------------------------------------------------------

//! Zephyr device stores the initialized LIS2MDL sensor
const struct device* dev;
};

} // namespace Drv

#endif
69 changes: 69 additions & 0 deletions FprimeZephyrReference/Components/Drv/Lis2mdlManager/docs/sdd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Drv::Lis2mdlManager

The LIS2MDL Manager component interfaces with the LIS2MDL magnetometer to provide magnetic field measurements.

## Usage Examples

The LIS2MDL Manager component is designed to be called periodically to collect and return sensor data. It operates as a passive component that responds to manager calls.

### Typical Usage

1. The component is instantiated and initialized during system startup
2. A manager calls the `MagneticFieldGet` port
3. On each call, the component:
- Fetches fresh sensor samples from the sensor
- Converts sensor data to F Prime data structures
- Writes telemetry data
- Returns data in SI units

## Class Diagram

```mermaid
classDiagram
namespace Drv {
class Lis2mdlManagerComponentBase {
<<Auto-generated>>
}
class Lis2mdlManager {
- lis2mdl: const struct device*
+ Lis2mdlManager(const char* compName)
+ ~Lis2mdlManager()
- magneticFieldGet_handler(const FwIndexType portNum): Drv::MagneticField
}
}
Lis2mdlManagerComponentBase <|-- Lis2mdlManager : inherits
```

## Port Descriptions
| Name | Type | Description |
|---|---|---|
| MagneticFieldGet | sync input | Triggers magnetic field data collection and returns a MagneticField struct |

## Sequence Diagrams

```mermaid
sequenceDiagram
participant Manager
participant LIS2MDL Manager
participant Zephyr Sensor API
participant LIS2MDL Sensor

Manager-->>LIS2MDL Manager: Call MagneticFieldGet synchronous input port
LIS2MDL Manager->>Zephyr Sensor API: Fetch sensor data
Zephyr Sensor API->>LIS2MDL Sensor: Read sensor
LIS2MDL Sensor->>Zephyr Sensor API: Return sensor data
Zephyr Sensor API->>LIS2MDL Manager: Return x, y, z sensor_value structs
LIS2MDL Manager->>LIS2MDL Manager: Write telemetry
LIS2MDL Manager-->>Manager: Return MagneticField struct
```

## Requirements
Add requirements in the chart below
| Name | Description | Validation |
|---|---|---|
| MagneticFieldGet Port | The component shall provide access magnetic field sensor data and return in MagneticField struct, readings will be in gauss | Verify output matches expected values from sensor datasheet |

## Change Log
| Date | Description |
|---|---|
| 2025-9-15 | Initial LIS2MDL Manager component |
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/Drv/Lsm6dsoManager/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}/Lsm6dsoManager.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/Lsm6dsoManager.cpp"
DEPENDS
FprimeZephyrReference_Components_Drv_Helpers
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/Lsm6dsoManager.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Lsm6dsoManagerTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Lsm6dsoManagerTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
Loading