SatNOGS-COMMS
4.1.0
A COMMS subsystem for CubeSats
Toggle main menu visibility
Loading...
Searching...
No Matches
antenna_gpio.hpp
Go to the documentation of this file.
1
/*
2
* SatNOGS-COMMS control library
3
*
4
* Copyright (C) 2025, 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 <initializer_list>
25
#include <
satnogs-comms-lib/antenna.hpp
>
26
#include <
satnogs-comms-lib/bsp/gpio.hpp
>
27
28
namespace
satnogs::comms::lib
29
{
30
44
template
<u
int
32_t N>
class
antenna_gpio
:
public
antenna
45
{
46
public
:
51
class
elem_io
52
{
53
public
:
54
bsp::gpio
&
deploy
;
55
bsp::gpio
&
sense
;
56
};
57
64
antenna_gpio
(
const
char
*
name
,
const
elem_io
(&&
io
)[N])
65
:
antenna
(
name
, N), m_elems(std::move(
io
))
66
{
67
static_assert
(N > 0,
"At least one IO configuration should be set"
);
68
}
69
70
bool
71
detect
(uint32_t idx)
override
72
{
73
if
(idx > N - 1) {
74
throw
inval_arg_exception
(__FILE__, __LINE__);
75
}
76
return
m_elems[idx].sense.get();
77
}
78
79
void
80
deploy
(uint32_t idx,
bool
en)
override
81
{
82
if
(idx > N - 1) {
83
throw
inval_arg_exception
(__FILE__, __LINE__);
84
}
85
m_elems[idx].deploy.set(en);
86
}
87
88
private
:
89
const
elem_io m_elems[N];
90
};
91
93
}
// namespace satnogs::comms::lib
antenna.hpp
satnogs::comms::io
Definition
io.hpp:47
satnogs::comms::lib::antenna_gpio::elem_io
Specifies the deploy and the sensing GPIO.
Definition
antenna_gpio.hpp:52
satnogs::comms::lib::antenna_gpio::elem_io::deploy
bsp::gpio & deploy
Definition
antenna_gpio.hpp:54
satnogs::comms::lib::antenna_gpio::elem_io::sense
bsp::gpio & sense
Definition
antenna_gpio.hpp:55
satnogs::comms::lib::antenna_gpio::detect
bool detect(uint32_t idx) override
Returns antenna deployment status.
Definition
antenna_gpio.hpp:71
satnogs::comms::lib::antenna_gpio::deploy
void deploy(uint32_t idx, bool en) override
Deploy the antenna.
Definition
antenna_gpio.hpp:80
satnogs::comms::lib::antenna_gpio::antenna_gpio
antenna_gpio(const char *name, const elem_io(&&io)[N])
Construct a new antenna_gpio object.
Definition
antenna_gpio.hpp:64
satnogs::comms::lib::antenna::antenna
antenna(const char *name, uint32_t nelems)
Construct a new generic antenna object.
Definition
antenna.cpp:34
satnogs::comms::lib::antenna::name
const char * name() const
Retrieves the name of the antenna.
Definition
antenna.cpp:89
satnogs::comms::lib::bsp::gpio
GPIO device abstraction.
Definition
gpio.hpp:38
satnogs::comms::lib::inval_arg_exception
Generic exception indicating an invalid argument.
Definition
exception.hpp:180
gpio.hpp
satnogs::comms::lib
Definition
ad8318.hpp:30
libsatnogs-comms
include
satnogs-comms-lib
antenna_gpio.hpp
Generated by
1.17.0