GPIO Helper Library.
More...
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <ctype.h>
#include <errno.h>
#include "libfile/file.h"
#include "gpio.h"
GPIO Helper Library.
- Author
- Mark Greer mgree.nosp@m.r@an.nosp@m.imalc.nosp@m.reek.nosp@m..com
Set of routines to provide easy-to-use ways to perform common Linux(tm) GPIO operations.
int gpio_destroy |
( |
void * |
gpio_handle | ) |
|
Destroy resource allocated by gpio_init()
- Parameters
-
- Returns
- 0 on success, negative errno on failure
int gpio_get_fd |
( |
void * |
gpio_handle, |
|
|
int * |
fdp |
|
) |
| |
Get file descriptor associated with GPIO.
- Parameters
-
[in] | gpio_handle | Handle returned by gpio_init() |
[out] | fdp | Pointer to area where file descriptor is placed |
- Returns
- 0 on success, negative errno on failure
int gpio_init |
( |
char * |
gpio_num, |
|
|
void ** |
gpio_handlep |
|
) |
| |
Initialize a handle that provides access to specified GPIO.
- Parameters
-
[in] | gpio_num | Number of GPIO |
[out] | gpio_handlep | Pointer to handle to use for GPIO operations |
- Returns
- 0 on success, negative errno on failure
int gpio_read |
( |
void * |
gpio_handle, |
|
|
char * |
cp |
|
) |
| |
Get value of GPIO.
- Parameters
-
[in] | gpio_handle | Handle returned by gpio_init() |
[out] | cp | Pointer to where value is placed |
- Returns
- 0 on success, negative errno on failure
int gpio_set_direction |
( |
void * |
gpio_handle, |
|
|
enum gpio_direction |
dir |
|
) |
| |
Set GPIO direction.
- Parameters
-
[in] | gpio_handle | Handle returned by gpio_init() |
[in] | dir | Direction to set GPIO to |
- Returns
- 0 on success, negative errno on failure
int gpio_set_edge |
( |
void * |
gpio_handle, |
|
|
enum gpio_edge |
edge |
|
) |
| |
Set GPIO edge.
- Parameters
-
[in] | gpio_handle | Handle returned by gpio_init() |
[in] | edge | Edge to set GPIO to |
- Returns
- 0 on success, negative errno on failure
int gpio_set_polarity |
( |
void * |
gpio_handle, |
|
|
enum gpio_polarity |
polarity |
|
) |
| |
Set GPIO polarity.
- Parameters
-
[in] | gpio_handle | Handle returned by gpio_init() |
[in] | polarity | Polarity to set GPIO to |
- Returns
- 0 on success, negative errno on failure
int gpio_write |
( |
void * |
gpio_handle, |
|
|
char |
c |
|
) |
| |
Set value of GPIO.
- Parameters
-
[in] | gpio_handle | Handle returned by gpio_init() |
[in] | c | Value to set GPIO to |
- Returns
- 0 on success, negative errno on failure