Skip to content

Commit bdb101e

Browse files
committed
add helper function for power monitor device configure and add solar power monitor to topology
1 parent 84d8e66 commit bdb101e

File tree

9 files changed

+57
-15
lines changed

9 files changed

+57
-15
lines changed

FprimeZephyrReference/Components/Drv/Ina219Manager/Ina219Manager.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ namespace Drv {
1515
// ----------------------------------------------------------------------
1616

1717
Ina219Manager ::Ina219Manager(const char* const compName) : Ina219ManagerComponentBase(compName) {
18-
dev = device_get_binding("INA219");
18+
this->m_dev = device_get_binding("INA219");
1919
}
2020

2121
Ina219Manager ::~Ina219Manager() {}
2222

23+
void Ina219Manager::configure(const struct device *dev) {
24+
this->m_dev = dev;
25+
}
26+
2327
// ----------------------------------------------------------------------
2428
// Handler implementations for typed input ports
2529
// ----------------------------------------------------------------------

FprimeZephyrReference/Components/Drv/Ina219Manager/Ina219Manager.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Ina219Manager final : public Ina219ManagerComponentBase {
2727
//! Destroy Ina219Manager object
2828
~Ina219Manager();
2929

30+
void configure(const struct device *dev); // helper function to configure device for the class
31+
3032
private:
3133
// ----------------------------------------------------------------------
3234
// Handler implementations for typed input ports
@@ -49,12 +51,14 @@ class Ina219Manager final : public Ina219ManagerComponentBase {
4951
//! Port to read the voltage in volts
5052
F64 voltageGet_handler(FwIndexType portNum //!< The port number
5153
) override;
54+
55+
5256
// ----------------------------------------------------------------------
5357
// Member variables
5458
// ----------------------------------------------------------------------
5559

5660
//! Zephyr device stores the initialized LIS2MDL sensor
57-
const struct device* dev;
61+
const struct device* m_dev;
5862
};
5963

6064
} // namespace Drv

FprimeZephyrReference/ReferenceDeployment/Main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
#include <zephyr/kernel.h>
1111
#include <zephyr/sys/printk.h>
1212

13+
const struct device* ina219Sys = DEVICE_DT_GET(DT_NODELABEL(ina219Sys));
14+
const struct device* ina219Sol = DEVICE_DT_GET(DT_NODELABEL(ina219Sol));
1315
const struct device* serial = DEVICE_DT_GET(DT_NODELABEL(cdc_acm_uart0));
1416
const struct device* lora = DEVICE_DT_GET(DT_NODELABEL(lora0));
1517

18+
1619
int main(int argc, char* argv[]) {
1720
// ** DO NOT REMOVE **//
1821
//
@@ -22,9 +25,13 @@ int main(int argc, char* argv[]) {
2225
Os::init();
2326
// Object for communicating state to the topology
2427
ReferenceDeployment::TopologyState inputs;
28+
inputs.ina219SysDevice = ina219Sys;
29+
inputs.ina219SolDevice = ina219Sol;
2530
inputs.loraDevice = lora;
2631
inputs.uartDevice = serial;
2732
inputs.baudRate = 115200;
33+
34+
2835

2936
// Setup, cycle, and teardown topology
3037
ReferenceDeployment::setupTopology(inputs);

FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,16 @@ telemetry packets ReferenceDeploymentPackets {
6161
ReferenceDeployment.antennaDeployer.LastDistance
6262
}
6363

64-
packet PowerMonitor id 9 group 4 {
65-
ReferenceDeployment.ina219Manager.Voltage
66-
ReferenceDeployment.ina219Manager.Current
67-
ReferenceDeployment.ina219Manager.Power
64+
packet sysPowerMonitor id 9 group 4 {
65+
ReferenceDeployment.ina219SysManager.Voltage
66+
ReferenceDeployment.ina219SysManager.Current
67+
ReferenceDeployment.ina219SysManager.Power
68+
}
69+
70+
packet solPowerMonitor id 10 group 4 {
71+
ReferenceDeployment.ina219SolManager.Voltage
72+
ReferenceDeployment.ina219SolManager.Current
73+
ReferenceDeployment.ina219SolManager.Power
6874
}
6975

7076
} omit {

FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void setupTopology(const TopologyState& state) {
8787
// for over-the-air communications.
8888
lora.start(state.loraDevice, Zephyr::TransmitState::DISABLED);
8989
comDriver.configure(state.uartDevice, state.baudRate);
90+
ina219Manager.configure(state.ina219SysDevice);
9091
}
9192

9293
void startRateGroups() {

FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopologyDefs.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ namespace ReferenceDeployment {
6969
* autocoder. The contents are entirely up to the definition of the project. This deployment uses subtopologies.
7070
*/
7171
struct TopologyState {
72+
const device* ina219SysDevice; //!< device path for battery board ina219
73+
const device* ina219SolDevice; //!< device path for solar panel ina219
7274
const device* uartDevice; //!< UART device path for communication
7375
const device* loraDevice; //!< LoRa device path for communication
7476
U32 baudRate; //!< Baud rate for UART communication

FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ module ReferenceDeployment {
9090

9191
instance fsSpace: Components.FsSpace base id 0x10030000
9292

93-
instance powerMonitor: Components.PowerMonitor base id 0x10031000
93+
instance sysPowerMonitor: Components.PowerMonitor base id 0x10031000
9494

95-
instance ina219Manager: Drv.Ina219Manager base id 0x10032000
95+
instance solPowerMonitor: Components.PowerMonitor base id 0x10032000
96+
97+
instance ina219SysManager: Drv.Ina219Manager base id 0x10033000
98+
99+
instance ina219SolManager: Drv.Ina219Manager base id 0x10034000
96100
}

FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ module ReferenceDeployment {
139139
rateGroup1Hz.RateGroupMemberOut[7] -> burnwire.schedIn
140140
rateGroup1Hz.RateGroupMemberOut[8] -> antennaDeployer.schedIn
141141
rateGroup1Hz.RateGroupMemberOut[9] -> fsSpace.run
142-
rateGroup1Hz.RateGroupMemberOut[10] -> powerMonitor.run
142+
rateGroup1Hz.RateGroupMemberOut[10] -> sysPowerMonitor.run
143+
rateGroup1Hz.RateGroupMemberOut[11] -> solPowerMonitor.run
143144

144145
}
145146

@@ -165,10 +166,16 @@ module ReferenceDeployment {
165166
imuManager.temperatureGet -> lsm6dsoManager.temperatureGet
166167
}
167168

168-
connections powerMonitor {
169-
powerMonitor.voltageGet -> ina219Manager.voltageGet
170-
powerMonitor.currentGet -> ina219Manager.currentGet
171-
powerMonitor.powerGet -> ina219Manager.powerGet
169+
connections sysPowerMonitor {
170+
sysPowerMonitor.voltageGet -> ina219SysManager.voltageGet
171+
sysPowerMonitor.currentGet -> ina219SysManager.currentGet
172+
sysPowerMonitor.powerGet -> ina219SysManager.powerGet
173+
}
174+
175+
connections solPowerMonitor {
176+
solPowerMonitor.voltageGet -> ina219SolManager.voltageGet
177+
solPowerMonitor.currentGet -> ina219SolManager.currentGet
178+
solPowerMonitor.powerGet -> ina219SolManager.powerGet
172179
}
173180
}
174181
}

boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,18 @@ zephyr_udc0: &usbd {
159159
backup-switch-mode = "direct";
160160
label = "RV3028";
161161
};
162-
ina219: ina219@40 {
162+
ina219Sys: ina219@40 {
163163
compatible = "ti,ina219";
164164
reg = <0x40>;
165165
shunt-milliohm = <2>;
166166
lsb-microamp = <100>;
167-
label = "INA219";
167+
label = "INA219 sys";
168+
};
169+
ina219Sol: ina219@41 {
170+
compatible = "ti,ina219";
171+
reg = <0x41>;
172+
shunt-milliohm = <2>;
173+
lsb-microamp = <100>;
174+
label = "INA219 sol";
168175
};
169176
};

0 commit comments

Comments
 (0)