NASA Astrobee Robot Software
0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
GPIO.h
Go to the documentation of this file.
1
/* Copyright (c) 2017, United States Government, as represented by the
2
* Administrator of the National Aeronautics and Space Administration.
3
*
4
* All rights reserved.
5
*
6
* The Astrobee platform is licensed under the Apache License, Version 2.0
7
* (the "License"); you may not use this file except in compliance with the
8
* License. You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
* License for the specific language governing permissions and limitations
16
* under the License.
17
*/
18
19
#ifndef EPSON_IMU_GPIO_H_
20
#define EPSON_IMU_GPIO_H_
21
22
#include <sys/time.h>
23
#include <sys/types.h>
24
25
#include <iostream>
26
#include <string>
27
28
namespace
gpio
{
29
30
enum
Direction
{
31
IN
= 0,
32
OUT
= 1
33
};
34
35
enum
Edge
{
36
NONE
= 0,
37
RISING
= 1,
38
FALLING
= 2,
39
BOTH
= 3
40
};
41
42
enum
Value
{
43
UNDEFINED
= -1,
44
LOW
= 0,
45
HIGH
= 1
46
};
47
48
enum
Interrupt
{
49
FAILED
= -1,
50
TIMEOUT
= 0,
51
SUCCESS
= 1
52
};
53
54
class
GPIO
{
55
public
:
56
explicit
GPIO
(
int
gpio
);
57
~GPIO
(
void
);
58
59
bool
IsExported
(
void
);
60
bool
Export
(
void
);
61
bool
Unexport
(
void
);
62
bool
SetDirection
(
Direction
direction);
63
bool
SetEdge
(
Edge
edge);
64
Value
GetValue
(
void
);
65
bool
SetValue
(
Value
value);
66
Interrupt
WaitInterrupt
(
const
struct
timespec *timeout);
67
68
private
:
69
int
gpio_;
70
int
fd_value_;
71
std::string sysfs_gpio_path_;
72
73
private
:
74
bool
OpenValue(
int
oflags);
75
void
CloseValue(
void
);
76
};
77
78
}
// namespace gpio
79
80
#endif // EPSON_IMU_GPIO_H_
gpio::GPIO::GPIO
GPIO(int gpio)
Definition:
GPIO.cc:38
gpio::FALLING
@ FALLING
Definition:
GPIO.h:38
gpio::GPIO::Unexport
bool Unexport(void)
Definition:
GPIO.cc:100
gpio::GPIO::SetEdge
bool SetEdge(Edge edge)
Definition:
GPIO.cc:150
gpio::GPIO::WaitInterrupt
Interrupt WaitInterrupt(const struct timespec *timeout)
Definition:
GPIO.cc:210
gpio::GPIO::GetValue
Value GetValue(void)
Definition:
GPIO.cc:179
gpio::Interrupt
Interrupt
Definition:
GPIO.h:48
gpio::BOTH
@ BOTH
Definition:
GPIO.h:39
gpio::GPIO::IsExported
bool IsExported(void)
Definition:
GPIO.cc:48
gpio::Edge
Edge
Definition:
GPIO.h:35
gpio::RISING
@ RISING
Definition:
GPIO.h:37
gpio::GPIO::~GPIO
~GPIO(void)
Definition:
GPIO.cc:44
gpio::Value
Value
Definition:
GPIO.h:42
gpio::OUT
@ OUT
Definition:
GPIO.h:32
gpio::IN
@ IN
Definition:
GPIO.h:31
gpio::GPIO
Definition:
GPIO.h:54
gpio::GPIO::SetDirection
bool SetDirection(Direction direction)
Definition:
GPIO.cc:119
gpio::FAILED
@ FAILED
Definition:
GPIO.h:49
gpio::GPIO::Export
bool Export(void)
Definition:
GPIO.cc:54
gpio::SUCCESS
@ SUCCESS
Definition:
GPIO.h:51
gpio::UNDEFINED
@ UNDEFINED
Definition:
GPIO.h:43
gpio::LOW
@ LOW
Definition:
GPIO.h:44
gpio::HIGH
@ HIGH
Definition:
GPIO.h:45
gpio::NONE
@ NONE
Definition:
GPIO.h:36
gpio
Definition:
GPIO.h:28
gpio::GPIO::SetValue
bool SetValue(Value value)
Definition:
GPIO.cc:190
gpio::Direction
Direction
Definition:
GPIO.h:30
gpio::TIMEOUT
@ TIMEOUT
Definition:
GPIO.h:50