SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
Loading...
Searching...
No Matches
power.hpp
Go to the documentation of this file.
1/*
2 * SatNOGS-COMMS control library
3 *
4 * Copyright (C) 2023, Libre Space Foundation <http://libre.space>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * SPDX-License-Identifier: GNU General Public License v3.0 or later
20 */
21
22#pragma once
23
30#include <satnogs-comms-lib/version.hpp>
31
32namespace satnogs::comms::lib
33{
42class power
43{
44public:
49 enum class subsys : uint8_t
50 {
51 CAN1 = 0,
52 CAN2 = 1,
53 RF_5V = 2,
54 FPGA_5V = 3,
57 UHF = 6,
58 SBAND = 7
59 };
60
65 enum class sensor : uint8_t
66 {
67 EFUSES = 0,
68 EMC1702 = 1,
70 };
71
76 enum class channel : uint8_t
77 {
78 FPGA = 1,
79 RF_5V = 2,
80 DIG_3V3 = 3,
81 VIN = 4,
82 V_BAT = 5
83 };
84
89 enum class pgood_tp : uint8_t
90 {
91 RAIL_5V = 0,
95 };
96
103 class r_lim
104 {
105 public:
106 r_lim() = delete;
107
118 r_lim(uint16_t dig_3v3, uint16_t rf_5v, uint16_t fpga_5v)
120 {
121 }
122
123 /*
124 * Only the power class should have access on the protected members of this
125 * class
126 */
127 friend power;
128
129 protected:
130 uint16_t dig_3v3;
131 uint16_t rf_5v;
132 uint16_t fpga_5v;
133 };
134
165
166 void
167 enable(subsys sys, bool en = true);
168
169 bool
170 enabled(subsys sys) const;
171
172 bool
173 pgood(pgood_tp tp) const;
174
175 float
176 voltage(channel sys) const;
177
178 float
179 current(channel sys) const;
180
181 float
182 get_power(sensor src) const;
183
184 power(const io_conf &io);
185
186private:
187 bsp::gpio &m_rf_5v_en;
188 bsp::gpio &m_fpga_5v_en;
189 bsp::gpio &m_can1_en;
190 bsp::gpio &m_can1_low_pwr;
191 bsp::gpio &m_can2_en;
192 bsp::gpio &m_can2_low_pwr;
193 bsp::gpio &m_pgood_5v;
194 bsp::gpio &m_pgood_fpga;
195 emc1702 m_monitor;
196 bsp::gpio &m_uhf_en;
197 bsp::gpio &m_uhf_pgood;
198 bsp::gpio &m_sband_en;
199 bsp::gpio &m_sband_pgood;
200 bsp::adc &m_imon_5v_rf;
201 bsp::adc &m_imon_3v3;
202 bsp::adc &m_imon_fpga;
203 bsp::sensor &m_v_mon;
204 r_lim m_r_lim;
205 uint16_t m_efuse_adc_current_gain;
206};
207
208
209} // namespace satnogs::comms::lib
ADC device abstraction.
Definition adc.hpp:39
GPIO device abstraction.
Definition gpio.hpp:38
I2C device abstraction.
Definition i2c.hpp:40
Sensor device abstraction.
Definition sensor.hpp:41
Interface for the EMC1702 High-Side Current-Sense and Dual Temperature Monitor.
Definition emc1702.hpp:64
Represents the I/O configuration for the power management system.
Definition power.hpp:143
Current limit resistor configuration.
Definition power.hpp:104
r_lim(uint16_t dig_3v3, uint16_t rf_5v, uint16_t fpga_5v)
Construct a new r lim object.
Definition power.hpp:118
float voltage(channel sys) const
Retrieves the voltage of a specified channel.
Definition power.cpp:146
float current(channel sys) const
Retrieves the current of a specified channel.
Definition power.cpp:174
power(const io_conf &io)
Definition power.cpp:233
bool pgood(pgood_tp tp) const
Gets the power good indication from various power supplies.
Definition power.cpp:117
sensor
Identifies power measurement sources.
Definition power.hpp:66
@ AVERAGE
Average power from all available sources.
Definition power.hpp:69
@ EFUSES
Power measured by eFuses.
Definition power.hpp:67
@ EMC1702
Power measured by the EMC1702 sensor.
Definition power.hpp:68
pgood_tp
Power good indicator.
Definition power.hpp:90
float get_power(sensor src) const
Calculates the power consumption for a specified sensor source.
Definition power.cpp:209
subsys
Identifies subsystems managed by the power class.
Definition power.hpp:50
@ CAN2_LPWR
Low-power mode for CAN Bus 2.
Definition power.hpp:56
@ CAN1_LPWR
Low-power mode for CAN Bus 1.
Definition power.hpp:55
channel
Identifies voltage and current measurement channels.
Definition power.hpp:77
@ V_BAT
Battery voltage channel.
Definition power.hpp:82
@ FPGA
FPGA voltage/current channel.
Definition power.hpp:78
@ DIG_3V3
Digital 3.3V voltage/current channel.
Definition power.hpp:80
@ VIN
Input voltage channel.
Definition power.hpp:81
void enable(subsys sys, bool en=true)
Enable/disable the power of subsystems.
Definition power.cpp:35
bool enabled(subsys sys) const
Checks the if the subsystem is enabled.
Definition power.cpp:86