DHCOM_HAL
Hardware-abstraction library (HAL) for multiple targets, including DHCOM modules
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
GPIO.h
Go to the documentation of this file.
1 /*
2  * GPIO.h
3  *
4  * Created on: Dec 17, 2012
5  * Author: Peter Kishalov (PK), DH electronics GmbH
6  */
7 
8 
9 #ifndef GPIO_H_
10 #define GPIO_H_
11 
12 
13 #include <DHCOM_HAL.h>
14 #include <hal/Types.h>
15 #include <stddef.h>
16 
17 
18 namespace dhcom
19 {
20 
21 
22 class System;
23 class GPIOImpl;
24 
25 
27 {
28 public:
30  enum PORT
31  {
32  PORT_GPIO_A = 0,
33  PORT_GPIO_B, PORT_GPIO_C, PORT_GPIO_D,
34  PORT_GPIO_E, PORT_GPIO_F, PORT_GPIO_G, PORT_GPIO_H,
35  PORT_GPIO_I, PORT_GPIO_J, PORT_GPIO_K, PORT_GPIO_L,
36  PORT_GPIO_M, PORT_GPIO_N, PORT_GPIO_O, PORT_GPIO_P,
37  PORT_GPIO_Q, PORT_GPIO_R, PORT_GPIO_S, PORT_GPIO_T,
38  PORT_GPIO_U, PORT_GPIO_V, PORT_GPIO_W,
39  };
40 
42  enum DIRECTION
43  {
46  };
47 
48  enum EDGE
49  {
50  EDGE_NONE = 0,
51  EDGE_RISING = 1,
52  EDGE_FALLING = 2,
53  EDGE_BOTH = 3,
54  };
55 
56  GPIO(const System &sys, PORT port);
57  GPIO(uint16_t pinInternal);
58  ~GPIO();
59 
60  STATUS open();
61  STATUS close();
62  bool isOpen() const;
63 
64  STATUS setDirection(DIRECTION dir);
65  STATUS set(bool value);
66  bool get(STATUS *status = NULL) const;
67  int16_t pin() const;
68 
69  STATUS edgeDetect(EDGE edge);
70  int fileDescriptor() const;
71 
72 private:
73  GPIOImpl * const impl_;
74 };
75 
76 
155 }
156 
157 
158 #endif /* GPIO_H_ */