SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
Loading...
Searching...
No Matches
board.hpp
Go to the documentation of this file.
1/*
2 * SatNOGS-COMMS control library
3 *
4 * Copyright (C) 2024, 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
24#include <type_traits>
25
39#include <satnogs-comms-lib/version.hpp>
40
41namespace satnogs::comms::lib
42{
73class board
74{
75public:
107
122
123 static void
124 init(const io_conf &io, const params &p);
125
126 /* Singleton */
127 static board &
128 get_instance();
129
130 static bool
131 is_init();
132
133 board(board const &) = delete;
134
135 void
136 operator=(board const &) = delete;
137
139 radio();
140
142 emmc();
143
145 power();
146
148 fpga();
149
151 leds();
152
155
156 bool
157 alert(temperature_sensor s) const;
158
159 float
161
162protected:
163 board(const io_conf &io, const params &p);
164
165private:
166 bool m_init;
167 /*
168 * power subsystem should be first, because many of the other subsystems
169 * depends on it
170 */
171 comms::lib::power m_power;
172 comms::lib::radio m_radio;
173 comms::lib::fpga m_fpga;
174 comms::lib::emmc m_emmc;
175 comms::lib::antenna &m_uhf_antenna;
176 comms::lib::antenna &m_sband_antenna;
177 comms::lib::leds m_leds;
179};
180
182
189{
190public:
191 uninitialization_exception(string_type file_name, numeric_type line)
192 : exception(
193 exception::severity::CATASTROPHIC, file_name, line,
194 error_msg{"Singleton class not initialized (init() not called)",
195 "noinit", EUNINIT})
196 {
197 }
198};
199
206{
207public:
208 initialization_exception(string_type file_name, numeric_type line)
209 : exception(
210 exception::severity::CRITICAL, file_name, line,
211 error_msg{"Singleton class already initialized", "init", EINIT})
212 {
213 }
214};
215
216} // namespace satnogs::comms::lib
Generic antenna definition.
Definition antenna.hpp:46
IO peripherals required for the control of the various subsystems of the board.
Definition board.hpp:83
bsp::gpio & emmc_en
GPIO for the eMMC enable.
Definition board.hpp:85
comms::lib::antenna & sband_antenna
S-Band antenna interface.
Definition board.hpp:105
bsp::chrono & chrono
Chrono device for measuring time and introducing delay.
Definition board.hpp:99
bsp::gpio & fpga_boot_sel_1
second GPIO for selecting fpga boot mode
Definition board.hpp:102
bsp::gpio & led0
GPIO of the LED0.
Definition board.hpp:89
bsp::gpio & emmc_rst
GPIO for the reset signal of the eMMC.
Definition board.hpp:87
bsp::gpio & fpga_boot_sel_0
first GPIO for selecting fpga boot mode
Definition board.hpp:103
bsp::gpio & fpga_done
GPIO indicating successful firmware load on the FPGA.
Definition board.hpp:101
bsp::gpio & emmc_sel
GPIO for the eMMC direction selections.
Definition board.hpp:86
comms::lib::antenna & uhf_antenna
UHF antenna interface.
Definition board.hpp:104
bsp::gpio & led1
GPIO of the LED1.
Definition board.hpp:90
radio::io_conf & radio_io
IO configuration of the radio subsystem.
Definition board.hpp:97
power::io_conf & pwr_io
IO configuration of the power subsystem.
Definition board.hpp:91
bsp::spi & fpga_spi
SPI peripheral for communication with the FPGA.
Definition board.hpp:88
bsp::gpio & alert_t_pa_sband
Temperature alert GPIO for the S-Band PA.
Definition board.hpp:96
bsp::gpio & alert_t_pa_uhf
Temperature alert GPIO for the UHF PA.
Definition board.hpp:95
Board initialization parameters.
Definition board.hpp:114
radio::params radio_params
radio subsystem initialization parameters
Definition board.hpp:116
bsp::imsgq< radio::rx_msg > & rx_msgq
Definition board.hpp:119
fpga::hw fpga_hw
FPGA type currently attached on the board.
Definition board.hpp:117
comms::lib::power & power()
Returns a reference to the power subsystem.
Definition board.cpp:102
comms::lib::emmc & emmc()
Returns a reference to the eMMC subsystem.
Definition board.cpp:91
static void init(const io_conf &io, const params &p)
Initializes the board and creates a single instance.
Definition board.cpp:36
static bool is_init()
Checks if the init() has already called by the user.
Definition board.cpp:54
comms::lib::leds & leds()
Returns a reference to the LEDs subsystem.
Definition board.cpp:124
comms::lib::radio & radio()
Returns a reference to the radio subsystem.
Definition board.cpp:80
comms::lib::fpga & fpga()
Returns a reference to the FPGA subsystem.
Definition board.cpp:113
static board & get_instance()
Gets a reference to the single instance of the Board interface class.
Definition board.cpp:66
void operator=(board const &)=delete
float temperature(temperature_sensor s) const
Gets the temperature from a specific sensor.
Definition board.cpp:162
bool alert(temperature_sensor s) const
Checks if there is an alert from a specific sensor.
Definition board.cpp:150
board(board const &)=delete
comms::lib::antenna & antenna(radio::interface iface)
Definition board.cpp:130
Chrono device abstraction.
Definition chrono.hpp:41
GPIO device abstraction.
Definition gpio.hpp:38
I2C device abstraction.
Definition i2c.hpp:40
Message queue device abstraction.
Definition msgq.hpp:42
SPI device abstraction.
Definition spi.hpp:41
A class representing error messages in the SatNOGS-COMMS system.
Definition exception.hpp:83
severity
Severity levels of exceptions.
Definition exception.hpp:71
@ CATASTROPHIC
Failure causing loss of mission.
Definition exception.hpp:72
@ CRITICAL
Failure causing mission degradation or significant damage.
Definition exception.hpp:73
exception(severity sev, const char *file, int lineno, const error_msg &err_msg)
Constructor for the exception class.
initialization_exception(string_type file_name, numeric_type line)
Definition board.hpp:208
LED control library for the SatNOGS-COMMS board.
Definition leds.hpp:39
Represents the I/O configuration for the power management system.
Definition power.hpp:143
Manages power supplies and monitors subsystem status.
Definition power.hpp:43
IO configuration that is necessary for the radio to operate.
Definition radio.hpp:207
Initialization parameters of the radio class.
Definition radio.hpp:240
Radio subsystem providing TX/RX functionality on UHF and S-Band.
Definition radio.hpp:127
interface
Radio interface identifier.
Definition radio.hpp:177
Manages multiple temperature sensors for monitoring and alerting.
uninitialization_exception(string_type file_name, numeric_type line)
Definition board.hpp:191
#define EINIT
Singleton already initialized.
#define EUNINIT
Singleton not initialized (init() not called).
temperature_sensor
Source of temperature readings.