RTEMS
6.1-rc4
Loading...
Searching...
No Matches
bsps
include
grlib
gpiolib.h
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
3
/* GPIO Library interface
4
*
5
* COPYRIGHT (c) 2009.
6
* Cobham Gaisler AB.
7
*
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
10
* are met:
11
* 1. Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
* POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
#ifndef __GPIOLIB_H__
31
#define __GPIOLIB_H__
32
33
#ifdef __cplusplus
34
extern
"C"
{
35
#endif
36
37
/* GPIO Config of one GPIO port */
38
struct
gpiolib_config
{
39
char
mask;
/* 0=Masked/1=Unmasked IRQ */
40
char
irq_level;
/* Edge or Level triggered IRQ */
41
char
irq_polarity;
/* Polarity of IRQ */
42
};
43
44
#define GPIOLIB_IRQ_EDGE 0
45
#define GPIOLIB_IRQ_LEVEL 1
46
47
#define GPIOLIB_IRQ_POL_LOW 0
48
#define GPIOLIB_IRQ_POL_HIGH 1
49
50
/* Libarary initialize function must be called befor any other */
51
extern
int
gpiolib_initialize(
void
);
52
53
/*** User Interface ***/
54
55
extern
void
*gpiolib_open(
int
port);
56
extern
void
*gpiolib_open_by_name(
char
*devName);
57
extern
void
gpiolib_close(
void
*handle);
58
59
/* Show the current status one or all GPIO ports in the system.
60
* Int port is port nunber, if port = -1 selects all ports.
61
*
62
* If port != -1, handle is used to get port.
63
* If port != -1, handle == NULL, then port is used as port number
64
*/
65
extern
void
gpiolib_show(
int
port,
void
*handle);
66
67
extern
int
gpiolib_set_config(
void
*handle,
struct
gpiolib_config
*cfg);
68
extern
int
gpiolib_set(
void
*handle,
int
dir,
int
val);
69
extern
int
gpiolib_get(
void
*handle,
int
*inval);
70
extern
int
gpiolib_irq_clear(
void
*handle);
71
extern
int
gpiolib_irq_enable(
void
*handle);
72
extern
int
gpiolib_irq_disable(
void
*handle);
73
extern
int
gpiolib_irq_mask(
void
*handle);
74
extern
int
gpiolib_irq_unmask(
void
*handle);
75
extern
int
gpiolib_irq_force(
void
*handle);
76
extern
int
gpiolib_irq_register(
void
*handle,
void
*func,
void
*arg);
77
78
/*** Driver Interface ***/
79
80
struct
gpiolib_info
{
81
char
devName[80];
82
};
83
84
struct
gpiolib_drv_ops
{
85
int (*
config
)(
void
*handle,
struct
gpiolib_config
*cfg);
86
int (*get)(
void
*handle,
int
*val);
87
int (*irq_opts)(
void
*handle,
unsigned
int
options);
88
int (*irq_register)(
void
*handle,
void
*func,
void
*arg);
89
int (*
open
)(
void
*handle);
90
int (*set)(
void
*handle,
int
dir,
int
outval);
91
int (*show)(
void
*handle);
92
int (*get_info)(
void
*handle,
struct
gpiolib_info
*pinfo);
93
};
94
95
#define GPIOLIB_IRQ_ENABLE 0x01
96
#define GPIOLIB_IRQ_DISABLE 0x02
97
#define GPIOLIB_IRQ_CLEAR 0x04
98
#define GPIOLIB_IRQ_FORCE 0x08
99
#define GPIOLIB_IRQ_MASK 0x10
100
#define GPIOLIB_IRQ_UNMASK 0x20
101
102
struct
gpiolib_drv
{
103
struct
gpiolib_drv_ops
*ops;
104
};
105
106
/* Register a GPIO port */
107
extern
int
gpiolib_drv_register(
struct
gpiolib_drv
*drv,
void
*handle);
108
109
#ifdef __cplusplus
110
}
111
#endif
112
113
#endif
open
int open(const char *path, int oflag,...)
Definition:
open.c:181
config_s
Definition:
deflate.c:114
gpiolib_config
Definition:
gpiolib.h:38
gpiolib_drv_ops
Definition:
gpiolib.h:84
gpiolib_drv
Definition:
gpiolib.h:102
gpiolib_info
Definition:
gpiolib.h:80
Generated by
1.9.6