libgpio
Functions
gpio.c File Reference

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"
Include dependency graph for gpio.c:

Functions

int gpio_get_fd (void *gpio_handle, int *fdp)
 Get file descriptor associated with GPIO. More...
 
int gpio_set_polarity (void *gpio_handle, enum gpio_polarity polarity)
 Set GPIO polarity. More...
 
int gpio_set_edge (void *gpio_handle, enum gpio_edge edge)
 Set GPIO edge. More...
 
int gpio_set_direction (void *gpio_handle, enum gpio_direction dir)
 Set GPIO direction. More...
 
int gpio_read (void *gpio_handle, char *cp)
 Get value of GPIO. More...
 
int gpio_write (void *gpio_handle, char c)
 Set value of GPIO. More...
 
int gpio_init (char *gpio_num, void **gpio_handlep)
 Initialize a handle that provides access to specified GPIO. More...
 
int gpio_destroy (void *gpio_handle)
 Destroy resource allocated by gpio_init() More...
 

Detailed Description

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.

Function Documentation

int gpio_destroy ( void *  gpio_handle)

Destroy resource allocated by gpio_init()

Parameters
[in]gpio_handleHandle returned by gpio_init()
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_handleHandle returned by gpio_init()
[out]fdpPointer 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_numNumber of GPIO
[out]gpio_handlepPointer 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_handleHandle returned by gpio_init()
[out]cpPointer 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_handleHandle returned by gpio_init()
[in]dirDirection 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_handleHandle returned by gpio_init()
[in]edgeEdge 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_handleHandle returned by gpio_init()
[in]polarityPolarity 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_handleHandle returned by gpio_init()
[in]cValue to set GPIO to
Returns
0 on success, negative errno on failure