forked from nasa/fprime
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLinuxGpioDriverComponentImpl.hpp
More file actions
114 lines (90 loc) · 3.27 KB
/
Copy pathLinuxGpioDriverComponentImpl.hpp
File metadata and controls
114 lines (90 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// ======================================================================
// \title LinuxGpioDriverImpl.hpp
// \author tcanham
// \brief hpp file for LinuxGpioDriver component implementation class
//
// \copyright
// Copyright 2009-2015, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged. Any commercial use must be negotiated with the Office
// of Technology Transfer at the California Institute of Technology.
//
// This software may be subject to U.S. export control laws and
// regulations. By accepting this document, the user agrees to comply
// with all U.S. export laws and regulations. User has the
// responsibility to obtain export licenses, or other export authority
// as may be required before exporting such information to foreign
// countries or providing access to foreign persons.
// ======================================================================
#ifndef LinuxGpioDriver_HPP
#define LinuxGpioDriver_HPP
#include "Drv/LinuxGpioDriver/LinuxGpioDriverComponentAc.hpp"
#include <Os/Task.hpp>
namespace Drv {
class LinuxGpioDriverComponentImpl :
public LinuxGpioDriverComponentBase
{
public:
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------
//! Construct object LinuxGpioDriver
//!
LinuxGpioDriverComponentImpl(
#if FW_OBJECT_NAMES == 1
const char *const compName /*!< The component name*/
#else
void
#endif
);
//! Initialize object LinuxGpioDriver
//!
void init(
const NATIVE_INT_TYPE instance = 0 /*!< The instance number*/
);
//! Destroy object LinuxGpioDriver
//!
~LinuxGpioDriverComponentImpl(void);
//! Start interrupt task
Os::Task::TaskStatus startIntTask(NATIVE_INT_TYPE priority, NATIVE_INT_TYPE cpuAffinity = -1);
//! configure GPIO
enum GpioDirection {
GPIO_IN, //!< input
GPIO_OUT, //!< output
GPIO_INT //!< interrupt
};
//! open GPIO
bool open(NATIVE_INT_TYPE gpio, GpioDirection direction);
//! exit thread
void exitThread(void);
PRIVATE:
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------
//! Handler implementation for gpioRead
//!
void gpioRead_handler(
const NATIVE_INT_TYPE portNum, /*!< The port number*/
bool &state
);
//! Handler implementation for gpioWrite
//!
void gpioWrite_handler(
const NATIVE_INT_TYPE portNum, /*!< The port number*/
bool state
);
//! keep GPIO ID
NATIVE_INT_TYPE m_gpio;
//! device direction
GpioDirection m_direction;
//! Entry point for task waiting for interrupt
static void intTaskEntry(void * ptr);
//! Task object for RTI task
Os::Task m_intTask;
//! file descriptor for GPIO
NATIVE_INT_TYPE m_fd;
//! flag to quit thread
bool m_quitThread;
};
} // end namespace Drv
#endif