Skip to content

Commit 6b300c4

Browse files
committed
Merge branch 'main' of github.com:Open-Source-Space-Foundation/proves-core-reference into load-switch
2 parents 6d010cb + 497f48a commit 6b300c4

32 files changed

+862
-102
lines changed

FprimeZephyrReference/Components/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Include project-wide components here
22

3-
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
3+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/AntennaDeployer/")
4+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")
5+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/")
46
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ComDelay/")
7+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
58
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
9+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FsSpace/")
610
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ImuManager/")
711
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/NullPrmDb/")
12+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PowerMonitor/")
813
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
914
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Burnwire/")
1015
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")

FprimeZephyrReference/Components/Drv/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Helpers/")
1+
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ina219Manager/")
22
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lis2mdlManager/")
33
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Lsm6dsoManager/")
44
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/RtcManager")

FprimeZephyrReference/Components/Drv/Helpers/Helpers.cpp

Lines changed: 0 additions & 16 deletions
This file was deleted.

FprimeZephyrReference/Components/Drv/Helpers/Helpers.hpp

Lines changed: 0 additions & 19 deletions
This file was deleted.
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}/Ina219Manager.fpp"
20+
SOURCES
21+
"${CMAKE_CURRENT_LIST_DIR}/Ina219Manager.cpp"
22+
# DEPENDS
23+
# MyPackage_MyOtherModule
24+
)
25+
26+
### Unit Tests ###
27+
# register_fprime_ut(
28+
# AUTOCODER_INPUTS
29+
# "${CMAKE_CURRENT_LIST_DIR}/Ina219Manager.fpp"
30+
# SOURCES
31+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Ina219ManagerTestMain.cpp"
32+
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/Ina219ManagerTester.cpp"
33+
# DEPENDS
34+
# STest # For rules-based testing
35+
# UT_AUTO_HELPERS
36+
# )
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// ======================================================================
2+
// \title Ina219Manager.cpp
3+
// \brief cpp file for Ina219Manager component implementation class
4+
// ======================================================================
5+
6+
#include "FprimeZephyrReference/Components/Drv/Ina219Manager/Ina219Manager.hpp"
7+
#include <Fw/Types/Assert.hpp>
8+
9+
namespace Drv {
10+
11+
// ----------------------------------------------------------------------
12+
// Component construction and destruction
13+
// ----------------------------------------------------------------------
14+
15+
Ina219Manager ::Ina219Manager(const char* const compName) : Ina219ManagerComponentBase(compName) {}
16+
17+
Ina219Manager ::~Ina219Manager() {}
18+
19+
// ----------------------------------------------------------------------
20+
// Helper methods
21+
// ----------------------------------------------------------------------
22+
23+
void Ina219Manager::configure(const struct device* dev) {
24+
this->m_dev = dev;
25+
}
26+
27+
// ----------------------------------------------------------------------
28+
// Handler implementations for typed input ports
29+
// ----------------------------------------------------------------------
30+
31+
F64 Ina219Manager ::currentGet_handler(FwIndexType portNum) {
32+
if (!device_is_ready(this->m_dev)) {
33+
this->log_WARNING_HI_DeviceNotReady();
34+
return 0;
35+
}
36+
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();
37+
38+
struct sensor_value current;
39+
40+
sensor_sample_fetch_chan(this->m_dev, SENSOR_CHAN_CURRENT);
41+
42+
sensor_channel_get(this->m_dev, SENSOR_CHAN_CURRENT, &current);
43+
44+
this->tlmWrite_Current(sensor_value_to_double(&current));
45+
46+
return sensor_value_to_double(&current);
47+
}
48+
49+
F64 Ina219Manager ::powerGet_handler(FwIndexType portNum) {
50+
if (!device_is_ready(this->m_dev)) {
51+
this->log_WARNING_HI_DeviceNotReady();
52+
return 0;
53+
}
54+
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();
55+
56+
struct sensor_value power;
57+
58+
sensor_sample_fetch_chan(this->m_dev, SENSOR_CHAN_POWER);
59+
60+
sensor_channel_get(this->m_dev, SENSOR_CHAN_POWER, &power);
61+
62+
this->tlmWrite_Power(sensor_value_to_double(&power));
63+
64+
return sensor_value_to_double(&power);
65+
}
66+
67+
F64 Ina219Manager ::voltageGet_handler(FwIndexType portNum) {
68+
if (!device_is_ready(this->m_dev)) {
69+
this->log_WARNING_HI_DeviceNotReady();
70+
return 0;
71+
}
72+
this->log_WARNING_HI_DeviceNotReady_ThrottleClear();
73+
74+
struct sensor_value voltage;
75+
76+
sensor_sample_fetch_chan(this->m_dev, SENSOR_CHAN_VOLTAGE);
77+
78+
sensor_channel_get(this->m_dev, SENSOR_CHAN_VOLTAGE, &voltage);
79+
80+
this->tlmWrite_Voltage(sensor_value_to_double(&voltage));
81+
82+
return sensor_value_to_double(&voltage);
83+
}
84+
85+
} // namespace Drv
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module Drv {
2+
port VoltageGet -> F64
3+
port CurrentGet -> F64
4+
port PowerGet -> F64
5+
}
6+
7+
module Drv {
8+
@ Manager for Ina219 device
9+
passive component Ina219Manager {
10+
# Ports
11+
@ Port to read the voltage in volts
12+
sync input port voltageGet: VoltageGet
13+
14+
@ Port to read the current in amps
15+
sync input port currentGet: CurrentGet
16+
17+
@ Port to read the power in watts
18+
sync input port powerGet: PowerGet
19+
20+
# Telemetry channels
21+
22+
@ Telemetry channel for voltage in volts
23+
telemetry Voltage: F64
24+
25+
@ Telemetry channel for current in amps
26+
telemetry Current: F64
27+
28+
@ Telemetry channel for power in watts
29+
telemetry Power: F64
30+
31+
@ Event for reporting INA219 not ready error
32+
event DeviceNotReady() severity warning high format "INA219 device not ready" throttle 5
33+
34+
###############################################################################
35+
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
36+
###############################################################################
37+
@ Port for requesting the current time
38+
time get port timeCaller
39+
40+
@ Port for sending textual representation of events
41+
text event port logTextOut
42+
43+
@ Port for sending events to downlink
44+
event port logOut
45+
46+
@ Port for sending telemetry channels to downlink
47+
telemetry port tlmOut
48+
49+
}
50+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// ======================================================================
2+
// \title Ina219Manager.hpp
3+
// \brief hpp file for Ina219Manager component implementation class
4+
// ======================================================================
5+
6+
#ifndef Drv_Ina219Manager_HPP
7+
#define Drv_Ina219Manager_HPP
8+
9+
#include "FprimeZephyrReference/Components/Drv/Ina219Manager/Ina219ManagerComponentAc.hpp"
10+
11+
#include <zephyr/device.h>
12+
#include <zephyr/drivers/sensor.h>
13+
#include <zephyr/kernel.h>
14+
namespace Drv {
15+
16+
class Ina219Manager final : public Ina219ManagerComponentBase {
17+
public:
18+
// ----------------------------------------------------------------------
19+
// Component construction and destruction
20+
// ----------------------------------------------------------------------
21+
22+
//! Construct Ina219Manager object
23+
Ina219Manager(const char* const compName //!< The component name
24+
);
25+
26+
//! Destroy Ina219Manager object
27+
~Ina219Manager();
28+
29+
public:
30+
// ----------------------------------------------------------------------
31+
// Helper methods
32+
// ----------------------------------------------------------------------
33+
34+
//! Configure the INA219 device
35+
void configure(const struct device* dev);
36+
37+
private:
38+
// ----------------------------------------------------------------------
39+
// Handler implementations for typed input ports
40+
// ----------------------------------------------------------------------
41+
42+
//! Handler implementation for currentGet
43+
//!
44+
//! Port to read the current in amps
45+
F64 currentGet_handler(FwIndexType portNum //!< The port number
46+
) override;
47+
48+
//! Handler implementation for powerGet
49+
//!
50+
//! Port to read the power in watts
51+
F64 powerGet_handler(FwIndexType portNum //!< The port number
52+
) override;
53+
54+
//! Handler implementation for voltageGet
55+
//!
56+
//! Port to read the voltage in volts
57+
F64 voltageGet_handler(FwIndexType portNum //!< The port number
58+
) override;
59+
60+
// ----------------------------------------------------------------------
61+
// Member variables
62+
// ----------------------------------------------------------------------
63+
64+
//! Zephyr device stores the initialized LIS2MDL sensor
65+
const struct device* m_dev;
66+
};
67+
68+
} // namespace Drv
69+
70+
#endif

0 commit comments

Comments
 (0)