SatNOGS-COMMS
4.1.0
A COMMS subsystem for CubeSats
Toggle main menu visibility
Loading...
Searching...
No Matches
gpio.hpp
Go to the documentation of this file.
1
/*
2
* SatNOGS-COMMS control library
3
*
4
* Copyright (C) 2022-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
#pragma once
22
23
#include <cstdint>
24
namespace
satnogs::comms::lib::bsp
25
{
37
class
gpio
38
{
39
public
:
40
enum class
direction
: uint8_t
41
{
42
INPUT
= 0,
43
OUTPUT
= 1
44
};
45
52
gpio
(
direction
dir =
direction::INPUT
) {}
53
59
virtual
void
60
toggle
() = 0;
61
70
virtual
bool
71
get
() = 0;
72
80
virtual
bool
81
get_raw
() = 0;
82
92
virtual
void
93
set
(
bool
s) = 0;
94
102
virtual
void
103
set_raw
(
bool
s) = 0;
104
110
virtual
void
111
set_direction
(
direction
dir) = 0;
112
};
113
118
class
dummy_gpio
:
public
gpio
119
{
120
public
:
121
dummy_gpio
() : m_state(false) {};
122
123
void
124
toggle
()
125
{
126
m_state = !m_state;
127
}
128
129
bool
130
get
()
131
{
132
return
m_state;
133
}
134
135
bool
136
get_raw
()
137
{
138
return
m_state;
139
}
140
141
void
142
set
(
bool
s)
143
{
144
m_state = s;
145
}
146
147
void
148
set_raw
(
bool
s)
149
{
150
m_state = s;
151
}
152
153
void
154
set_direction
(
direction
dir)
155
{
156
}
157
158
private
:
159
bool
m_state;
160
};
161
162
}
// namespace satnogs::comms::lib::bsp
satnogs::comms::lib::bsp::dummy_gpio::set_direction
void set_direction(direction dir)
Set the direction of the GPIO.
Definition
gpio.hpp:154
satnogs::comms::lib::bsp::dummy_gpio::toggle
void toggle()
Toggles the GPIO pin if it is configured as output. Has no effect if it is conigured as input.
Definition
gpio.hpp:124
satnogs::comms::lib::bsp::dummy_gpio::set
void set(bool s)
Sets the logical output of the pin. For example, if the pin has been configured as active low,...
Definition
gpio.hpp:142
satnogs::comms::lib::bsp::dummy_gpio::set_raw
void set_raw(bool s)
Sets the physical output of the pin.
Definition
gpio.hpp:148
satnogs::comms::lib::bsp::dummy_gpio::get
bool get()
Gets the logical level of the GPIO pin. For example, if the pin has been configured as active low,...
Definition
gpio.hpp:130
satnogs::comms::lib::bsp::dummy_gpio::get_raw
bool get_raw()
Gets the physical level of the GPIO pin. For example, if the input level is 0V, this method will retu...
Definition
gpio.hpp:136
satnogs::comms::lib::bsp::dummy_gpio::dummy_gpio
dummy_gpio()
Definition
gpio.hpp:121
satnogs::comms::lib::bsp::gpio::toggle
virtual void toggle()=0
Toggles the GPIO pin if it is configured as output. Has no effect if it is conigured as input.
satnogs::comms::lib::bsp::gpio::set_raw
virtual void set_raw(bool s)=0
Sets the physical output of the pin.
satnogs::comms::lib::bsp::gpio::set
virtual void set(bool s)=0
Sets the logical output of the pin. For example, if the pin has been configured as active low,...
satnogs::comms::lib::bsp::gpio::get_raw
virtual bool get_raw()=0
Gets the physical level of the GPIO pin. For example, if the input level is 0V, this method will retu...
satnogs::comms::lib::bsp::gpio::get
virtual bool get()=0
Gets the logical level of the GPIO pin. For example, if the pin has been configured as active low,...
satnogs::comms::lib::bsp::gpio::gpio
gpio(direction dir=direction::INPUT)
Construct a new GPIO object.
Definition
gpio.hpp:52
satnogs::comms::lib::bsp::gpio::direction
direction
Definition
gpio.hpp:41
satnogs::comms::lib::bsp::gpio::direction::OUTPUT
@ OUTPUT
GPIO pin is configured as output.
Definition
gpio.hpp:43
satnogs::comms::lib::bsp::gpio::direction::INPUT
@ INPUT
GPIO pin is configured as input.
Definition
gpio.hpp:42
satnogs::comms::lib::bsp::gpio::set_direction
virtual void set_direction(direction dir)=0
Set the direction of the GPIO.
satnogs::comms::lib::bsp
Definition
adc.hpp:26
libsatnogs-comms
include
satnogs-comms-lib
bsp
gpio.hpp
Generated by
1.17.0