RTEMS
5.1
bsps
include
grlib
gpiolib.h
1
/* GPIO Library interface
2
*
3
* COPYRIGHT (c) 2009.
4
* Cobham Gaisler AB.
5
*
6
* The license and distribution terms for this file may be
7
* found in the file LICENSE in this distribution or at
8
* http://www.rtems.org/license/LICENSE.
9
*/
10
11
#ifndef __GPIOLIB_H__
12
#define __GPIOLIB_H__
13
14
#ifdef __cplusplus
15
extern
"C"
{
16
#endif
17
18
/* GPIO Config of one GPIO port */
19
struct
gpiolib_config
{
20
char
mask;
/* 0=Masked/1=Unmasked IRQ */
21
char
irq_level;
/* Edge or Level triggered IRQ */
22
char
irq_polarity;
/* Polarity of IRQ */
23
};
24
25
#define GPIOLIB_IRQ_EDGE 0
26
#define GPIOLIB_IRQ_LEVEL 1
27
28
#define GPIOLIB_IRQ_POL_LOW 0
29
#define GPIOLIB_IRQ_POL_HIGH 1
30
31
/* Libarary initialize function must be called befor any other */
32
extern
int
gpiolib_initialize(
void
);
33
34
/*** User Interface ***/
35
36
extern
void
*gpiolib_open(
int
port);
37
extern
void
*gpiolib_open_by_name(
char
*devName);
38
extern
void
gpiolib_close(
void
*handle);
39
40
/* Show the current status one or all GPIO ports in the system.
41
* Int port is port nunber, if port = -1 selects all ports.
42
*
43
* If port != -1, handle is used to get port.
44
* If port != -1, handle == NULL, then port is used as port number
45
*/
46
extern
void
gpiolib_show(
int
port,
void
*handle);
47
48
extern
int
gpiolib_set_config(
void
*handle,
struct
gpiolib_config
*cfg);
49
extern
int
gpiolib_set(
void
*handle,
int
dir,
int
val);
50
extern
int
gpiolib_get(
void
*handle,
int
*inval);
51
extern
int
gpiolib_irq_clear(
void
*handle);
52
extern
int
gpiolib_irq_enable(
void
*handle);
53
extern
int
gpiolib_irq_disable(
void
*handle);
54
extern
int
gpiolib_irq_mask(
void
*handle);
55
extern
int
gpiolib_irq_unmask(
void
*handle);
56
extern
int
gpiolib_irq_force(
void
*handle);
57
extern
int
gpiolib_irq_register(
void
*handle,
void
*func,
void
*arg);
58
59
/*** Driver Interface ***/
60
61
struct
gpiolib_info
{
62
char
devName[64];
63
};
64
65
struct
gpiolib_drv_ops
{
66
int (*
config
)(
void
*handle,
struct
gpiolib_config
*cfg);
67
int (*get)(
void
*handle,
int
*val);
68
int (*irq_opts)(
void
*handle,
unsigned
int
options);
69
int (*irq_register)(
void
*handle,
void
*func,
void
*arg);
70
int (*
open
)(
void
*handle);
71
int (*set)(
void
*handle,
int
dir,
int
outval);
72
int (*show)(
void
*handle);
73
int (*get_info)(
void
*handle,
struct
gpiolib_info
*pinfo);
74
};
75
76
#define GPIOLIB_IRQ_ENABLE 0x01
77
#define GPIOLIB_IRQ_DISABLE 0x02
78
#define GPIOLIB_IRQ_CLEAR 0x04
79
#define GPIOLIB_IRQ_FORCE 0x08
80
#define GPIOLIB_IRQ_MASK 0x10
81
#define GPIOLIB_IRQ_UNMASK 0x20
82
83
struct
gpiolib_drv
{
84
struct
gpiolib_drv_ops
*ops;
85
};
86
87
/* Register a GPIO port */
88
extern
int
gpiolib_drv_register(
struct
gpiolib_drv
*drv,
void
*handle);
89
90
#ifdef __cplusplus
91
}
92
#endif
93
94
#endif
config_s
Definition:
deflate.c:115
gpiolib_drv
Definition:
gpiolib.h:83
gpiolib_drv_ops
Definition:
gpiolib.h:65
gpiolib_config
Definition:
gpiolib.h:19
open
int open(const char *path, int oflag,...)
Definition:
open.c:149
gpiolib_info
Definition:
gpiolib.h:61
Generated by
1.8.15