> For the complete documentation index, see [llms.txt](https://sandbox-docs.verifone.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/gpio_8h_source.md).

# gpio.h

[Go to the documentation of this file.](/adk-5.0-programmers-guide/readme/files/dir_078666aaafc812ef0db017f3778c7af8/dir_1de2fc103c37f88e22147e598fb72856/dir_89bef91478a81057cacdced47a78082e/gpio_8h.md)

```cpp
 1 #ifndef GPIO_H_20230622
 2 #define GPIO_H_20230622
 3 
 4 #if defined _WIN32 && defined VFI_GPIO_EXPORT
 5 # define DllSpec __declspec(dllexport)
 6 #elif defined __GNUC__ && defined VFI_GPIO_EXPORT
 7 # define DllSpec __attribute__((visibility ("default")))
 8 #else
 9 # define DllSpec
 10 #endif
 11 
 12 namespace vfigpio {
 13 
 15 enum GPIO_Error {
 16  GPIOE_OK =0x00,
 17  GPIOE_NOT_CONNECTED =0x01,
 18  GPIOE_IO_ERROR =0x02,
 19  GPIOE_PROTOCOL =0x03,
 20  GPIOE_INVALID_TLV =0x04,
 21  GPIOE_RESET =0x05,
 23  GPIOE_ERROR =0x10,
 24  GPIOE_MESSAGE_TOO_LARGE=0x11,
 25  GPIOE_INVALID_COMMAND =0x12,
 26  GPIOE_INVALID_PARAM =0x13,
 27  GPIOE_CANCELLED =0x14,
 28  GPIOE_NO_RESOURCE =0x15,
 29  GPIOE_BUSY =0x1A,
 30  GPIOE_INVALID_SEQUENCE =0x1C,
 31  GPIOE_TIMEOUT =0x1D,
 32  GPIOE_NOT_FOUND =0x1F,
 34  GPIOE_EVENT_GPIO_1 =0x8005,
 35  GPIOE_EVENT_GPIO_2 =0x8006,
 36  GPIOE_EVENT_GPIO_3 =0x8007,
 37  GPIOE_EVENT_GPIO_4 =0x8008,
 38 };
 39 
 41 enum GPIO_Config {
 42  GPIO_OUTPUT=1,
 43  GPIO_DEBOUNCE=2,
 44 };
 45 
 47 enum GPIO_EventMask {
 48  GPIO_EVENT_GPIO_1 =0x0010,
 49  GPIO_EVENT_GPIO_2 =0x0020,
 50  GPIO_EVENT_GPIO_3 =0x0040,
 51  GPIO_EVENT_GPIO_4 =0x0080,
 52 };
 53 
 54 
 55 class DllSpec GPIO {
 56  public:
 57  class GPIOPrivate;
 58  private:
 59  GPIOPrivate *d; // PIMPL data pointer
 60 
 61  // prevent copying objects
 62  GPIO(const GPIO &o);
 63  void operator=(const GPIO &o);
 64 
 65  public:
 66 
 70  static GPIO &DefaultLink();
 71 
 73  GPIO();
 74 
 76  virtual ~GPIO();
 77 
 82  GPIO_Error connect(const char *name);
 83 
 86  void disconnect();
 87 
 88  enum TraceType { SEND_HEADER,SEND_DATA,RECEIVE_HEADER,RECEIVE_DATA };
 89  typedef void (*TraceFunc)(void *data, TraceType dir, const void *buffer, unsigned size);
 90 
 95  void setTrace(TraceFunc t, void *data);
 96 
 97  /*******************************************************/
 98  /************************ GPIO *************************/
 99  /*******************************************************/
 100 
 110  GPIO_Error setConfig(int pin, unsigned config, bool initval=false);
 111 
 116  GPIO_Error getConfig(int pin, unsigned &config);
 117 
 123  GPIO_Error read(int pin, bool &value);
 124 
 130  GPIO_Error write(int pin, bool value);
 131 
 136  static bool isFinalResult(int r) { return r<0x8000; }
 137 
 152  GPIO_Error startAsyncRead(void *&handle,
 153  unsigned mask,
 154  void (*cb)(void *data, int result, int value),
 155  void *data);
 156 
 161  GPIO_Error stopAsyncRead(void *handle);
 162 
 167  GPIO_Error setExtPrtPower(bool on);
 168 
 173  GPIO_Error getExtPrtPower(bool &on);
 174 
 175 };
 176 
 177 
 178 } // namespace
 179 
 180 #undef DllSpec
 181 
 182 #endif
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/gpio_8h_source.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
