SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
Loading...
Searching...
No Matches
board.cpp
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
23
24namespace satnogs::comms::lib
25{
26static board *m_instance = nullptr;
27
35void
36board::init(const io_conf &io, const params &p)
37{
38 if ((m_instance != nullptr) && m_instance->m_init) {
39 throw initialization_exception(__FILE__, __LINE__);
40 }
41 static board inst(io, p);
42 m_instance = &inst;
43 m_instance->m_init = true;
44}
45
53bool
55{
56 return (m_instance != nullptr) && m_instance->m_init;
57}
58
65board &
67{
68 if ((m_instance == nullptr) || !m_instance->m_init) {
69 throw uninitialization_exception(__FILE__, __LINE__);
70 }
71 return *m_instance;
72}
73
81{
82 return m_radio;
83}
84
92{
93 return m_emmc;
94}
95
103{
104 return m_power;
105}
106
114{
115 return m_fpga;
116}
117
125{
126 return m_leds;
127}
128
129antenna &
131{
132 switch (iface) {
134 return m_uhf_antenna;
136 return m_sband_antenna;
137 default:
138 throw inval_arg_exception(__FILE__, __LINE__);
139 }
140}
141
149bool
151{
152 return m_temperature.alert(s);
153}
154
161float
163{
164 return m_temperature.get(s);
165}
166
167board::board(const io_conf &io, const params &p)
168 : m_init(false),
169 m_power(io.pwr_io),
170 m_radio(p.radio_params, io.radio_io, m_power, p.rx_msgq),
171 m_fpga(p.fpga_hw, io.fpga_spi, m_power, io.fpga_done, io.fpga_boot_sel_1,
172 io.fpga_boot_sel_0),
173 m_emmc(io.emmc_en, io.emmc_sel, io.emmc_rst),
174 m_uhf_antenna(io.uhf_antenna),
175 m_sband_antenna(io.sband_antenna),
176 m_leds(io.led0, io.led1),
177 m_temperature(io.sensors_i2c, io.alert_t_pa_uhf, io.alert_t_pa_sband,
178 m_radio.uhf(), m_radio.sband())
179{
180}
181
182} // 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
Board initialization parameters.
Definition board.hpp:114
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
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
Raised if the init() is called more than once.
Definition board.hpp:206
Generic exception indicating an invalid argument.
LED control library for the SatNOGS-COMMS board.
Definition leds.hpp:39
Manages power supplies and monitors subsystem status.
Definition power.hpp:43
Radio subsystem providing TX/RX functionality on UHF and S-Band.
Definition radio.hpp:127
interface
Radio interface identifier.
Definition radio.hpp:177
Raised if the get_instance() is called before the init().
Definition board.hpp:189
temperature_sensor
Source of temperature readings.
const struct gpio_dt_spec emmc_en
Definition startup.cpp:116
const struct gpio_dt_spec fpga_done
Definition startup.cpp:46
const struct gpio_dt_spec emmc_rst
Definition startup.cpp:120
spi_bsp fpga_spi(fpga_spi_dev, fpga_spi_cfg)
const struct gpio_dt_spec led1
Definition startup.cpp:21
const struct gpio_dt_spec led0
Definition startup.cpp:20
i2c_bsp sensors_i2c(sens_i2c)
const struct gpio_dt_spec emmc_sel
Definition startup.cpp:118