RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
bsps
arm
include
bsp
imx-gpio.h
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
3
/*
4
* Copyright (C) 2020 embedded brains GmbH & Co. KG
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
8
* are met:
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
* POSSIBILITY OF SUCH DAMAGE.
26
*/
27
28
#ifndef BSP_IMX_GPIO_H
29
#define BSP_IMX_GPIO_H
30
31
#include <
rtems.h
>
32
#include <stdint.h>
33
34
#ifdef __cplusplus
35
extern
"C"
{
36
#endif
/* __cplusplus */
37
39
struct
imx_gpio
;
40
42
enum
imx_gpio_mode {
43
IMX_GPIO_MODE_OUTPUT,
44
IMX_GPIO_MODE_INPUT,
45
IMX_GPIO_MODE_INTERRUPT_LOW,
46
IMX_GPIO_MODE_INTERRUPT_HIGH,
47
IMX_GPIO_MODE_INTERRUPT_RISING,
48
IMX_GPIO_MODE_INTERRUPT_FALLING,
49
IMX_GPIO_MODE_INTERRUPT_ANY_EDGE,
50
};
51
59
struct
imx_gpio_pin
{
61
volatile
struct
imx_gpio
*
gpio
;
66
uint32_t
mask
;
68
unsigned
int
shift
;
70
enum
imx_gpio_mode
mode
;
75
bool
is_active_low
;
76
};
77
82
void
imx_gpio_init (
struct
imx_gpio_pin
*pin);
83
104
rtems_status_code
imx_gpio_init_from_fdt_property_pointer(
105
struct
imx_gpio_pin
*pin,
106
const
uint32_t *prop_pointer,
107
enum
imx_gpio_mode mode,
108
const
uint32_t **next_prop_pointer);
109
128
rtems_status_code
imx_gpio_init_from_fdt_property(
129
struct
imx_gpio_pin
*pin,
130
int
node_offset,
131
const
char
*property,
132
enum
imx_gpio_mode mode,
133
size_t
index);
134
151
rtems_vector_number
imx_gpio_get_irq_of_node(
152
const
void
*fdt,
153
int
node,
154
size_t
index);
155
161
struct
imx_gpio
*imx_gpio_get_by_index(
unsigned
idx);
162
166
struct
imx_gpio
*imx_gpio_get_by_register(
void
*regs);
167
171
const
char
*imx_gpio_get_name(
struct
imx_gpio
*
imx_gpio
);
172
177
void
imx_gpio_set_output(
struct
imx_gpio_pin
*pin, uint32_t set);
178
182
void
imx_gpio_toggle_output(
struct
imx_gpio_pin
*pin);
183
188
uint32_t imx_gpio_get_input(
struct
imx_gpio_pin
*pin);
189
193
void
imx_gpio_int_disable(
struct
imx_gpio_pin
*pin);
194
198
void
imx_gpio_int_enable(
struct
imx_gpio_pin
*pin);
199
203
uint32_t imx_gpio_get_isr(
struct
imx_gpio_pin
*pin);
204
208
void
imx_gpio_clear_isr(
struct
imx_gpio_pin
*pin, uint32_t clr);
209
214
static
inline
uint32_t imx_gpio_get_active_level(
struct
imx_gpio_pin
*pin)
215
{
216
return
(pin->
is_active_low
) ? 0 : 0xFFFFFFFFU;
217
}
218
223
static
inline
uint32_t imx_gpio_get_inactive_level(
struct
imx_gpio_pin
*pin)
224
{
225
return
~imx_gpio_get_active_level(pin);
226
}
227
233
#define IMX_GPIO1 (imx_gpio_get_by_index(0))
234
#define IMX_GPIO2 (imx_gpio_get_by_index(1))
235
#define IMX_GPIO3 (imx_gpio_get_by_index(2))
236
#define IMX_GPIO4 (imx_gpio_get_by_index(3))
237
#define IMX_GPIO5 (imx_gpio_get_by_index(4))
238
#define IMX_GPIO6 (imx_gpio_get_by_index(5))
239
#define IMX_GPIO7 (imx_gpio_get_by_index(6))
241
242
#ifdef __cplusplus
243
}
244
#endif
/* __cplusplus */
245
246
#endif
/* BSP_IMX_GPIO_H */
rtems_vector_number
ISR_Vector_number rtems_vector_number
This integer type represents interrupt vector numbers.
Definition
intr.h:102
rtems_status_code
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition
status.h:85
rtems.h
This header file defines the RTEMS Classic API.
imx_gpio_pin
Definition
imx-gpio.h:59
imx_gpio_pin::mode
enum imx_gpio_mode mode
Definition
imx-gpio.h:70
imx_gpio_pin::is_active_low
bool is_active_low
Definition
imx-gpio.h:75
imx_gpio_pin::shift
unsigned int shift
Definition
imx-gpio.h:68
imx_gpio_pin::gpio
volatile struct imx_gpio * gpio
Definition
imx-gpio.h:61
imx_gpio_pin::mask
uint32_t mask
Definition
imx-gpio.h:66
imx_gpio
Definition
imx-gpio.c:69
Generated by
1.18.0