RTEMS 7.0-rc1
Loading...
Searching...
No Matches
gpio-defs.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
11/*
12 * Copyright (c) 2014 Taller Technologies.
13 *
14 * @author Boretto Martin (martin.boretto@tallertechnologies.com)
15 * @author Diaz Marcos (marcos.diaz@tallertechnologies.com)
16 * @author Lenarduzzi Federico (federico.lenarduzzi@tallertechnologies.com)
17 * @author Daniel Chicco (daniel.chicco@tallertechnologies.com)
18 *
19 * The license and distribution terms for this file may be
20 * found in the file LICENSE in this distribution or at
21 * http://www.rtems.org/license/LICENSE.
22 */
23
24#ifndef LIBBSP_ARM_LPC176X_GPIO_DEFS_H
25#define LIBBSP_ARM_LPC176X_GPIO_DEFS_H
26
27#include <bsp/common-types.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif /* __cplusplus */
32
33/* General Purpose Input/Output (GPIO) */
34#define LPC176X_GPIO_BASE_ADDR 0x40028000U
35#define LPC176X_GPIO_INTERRUPT_STATUS 0x40028080U
36
37#define LPC176X_IOPIN0 ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR + \
38 0x00U ) )
39#define LPC176X_IOSET0 ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR + \
40 0x04U ) )
41#define LPC176X_IODIR0 ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR + \
42 0x08U ) )
43#define LPC176X_IOCLR0 ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR + \
44 0x0CU ) )
45#define LPC176X_IOPIN1 ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR + \
46 0x10U ) )
47#define LPC176X_IOSET1 ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR + \
48 0x14U ) )
49#define LPC176X_IODIR1 ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR + \
50 0x18U ) )
51#define LPC176X_IOCLR1 ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR + \
52 0x1CU ) )
53
54/* GPIO Interrupt Registers */
55#define LPC176X_IO0_INT_EN_R ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR \
56 + 0x90U ) )
57#define LPC176X_IO0_INT_EN_F ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR \
58 + 0x94U ) )
59#define LPC176X_IO0_INT_STAT_R ( *(volatile uint32_t *) ( \
60 LPC176X_GPIO_BASE_ADDR \
61 + 0x84U ) )
62#define LPC176X_IO0_INT_STAT_F ( *(volatile uint32_t *) ( \
63 LPC176X_GPIO_BASE_ADDR \
64 + 0x88U ) )
65#define LPC176X_IO0_INT_CLR ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR \
66 + 0x8CU ) )
67#define LPC176X_IO2_INT_EN_R ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR \
68 + 0xB0U ) )
69#define LPC176X_IO2_INT_EN_F ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR \
70 + 0xB4U ) )
71#define LPC176X_IO2_INT_STAT_R ( *(volatile uint32_t *) ( \
72 LPC176X_GPIO_BASE_ADDR \
73 + 0xA4U ) )
74#define LPC176X_IO2_INT_STAT_F ( *(volatile uint32_t *) ( \
75 LPC176X_GPIO_BASE_ADDR \
76 + 0xA8U ) )
77#define LPC176X_IO2_INT_CLR ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR \
78 + 0xACU ) )
79#define LPC176X_IO_INT_STAT ( *(volatile uint32_t *) ( LPC176X_GPIO_BASE_ADDR \
80 + 0x80U ) )
81
82#define LPC176X_RESERVED_ISR_FUNCT_SIZE 2U
83#define LPC176X_RESERVED_ISR_FUNCT_MAX_SIZE 5U
84
85#define LPC176X_MAX_PORT_NUMBER 160U
86#define LPC176X_SET_BIT( reg, pin, value ) \
87 reg = ( reg & ~( 1U << pin ) ) | ( ( value & 1U ) << pin )
88
89#define LPC176X_INT_STATUS ( *(volatile uint32_t *) \
90 ( LPC176X_GPIO_INTERRUPT_STATUS ) )
91#define LPC176X_INT_STATUS_P0 1U
92#define LPC176X_INT_STATUS_P2 ( 1U << 2U )
93#define LPC176X_INT_ENABLE 1U
94#define LPC176X_INT_DISABLE 0U
95
96#define LPC176X_IRQ_EINT_3 21U
97
98#define LPC176X_PIN_BIT( pin ) ( 1U << pin )
99
105typedef enum {
106 LPC176X_GPIO_FUNCTION_INPUT,
107 LPC176X_GPIO_FUNCTION_OUTPUT,
108 LPC176X_GPIO_FUNCTION_COUNT
109}
111
117typedef enum {
118 LPC176X_GPIO_INTERRUPT_DISABLE,
119 LPC176X_GPIO_INTERRUPT_RISING,
120 LPC176X_GPIO_INTERRUPT_FALLING,
121 LPC176X_GPIO_INTERRUPT_BOTH,
122 LPC176X_GPIO_INTERRUPT_COUNT
124
130typedef enum {
131 LPC176X_GPIO_PORT_0,
132 LPC176X_GPIO_PORT_1,
133 LPC176X_GPIO_PORT_2,
134 LPC176X_GPIO_PORT_3,
135 LPC176X_GPIO_PORT_4,
136 LPC176X_GPIO_PORTS_COUNT
138
145typedef enum {
146 LPC176X_FIO0_BASE_ADDRESS = 0x2009C000U,
147 LPC176X_FIO1_BASE_ADDRESS = 0x2009C020U,
148 LPC176X_FIO2_BASE_ADDRESS = 0x2009C040U,
149 LPC176X_FIO3_BASE_ADDRESS = 0x2009C060U,
150 LPC176X_FIO4_BASE_ADDRESS = 0x2009C080U,
152
159typedef enum {
160 LPC176X_IO0_INT_BASE_ADDRESS = 0x40028084U,
161 LPC176X_IO2_INT_BASE_ADDRESS = 0x400280A4U,
163
167typedef struct {
171 volatile uint32_t StatR;
175 volatile uint32_t StatF;
179 volatile uint32_t Clr;
183 volatile uint32_t EnR;
187 volatile uint32_t EnF;
189
198 const lpc176x_pin_number pin,
199 const lpc176x_gpio_interrupt edge
200);
201
205typedef struct {
215
216#ifdef __cplusplus
217}
218#endif /* __cplusplus */
219
220#endif /* LIBBSP_ARM_LPC176X_GPIO_DEFS_H */
Definitions types used by some devices in common.
uint32_t lpc176x_pin_number
A pin of the board.
Definition: common-types.h:34
lpc176x_gpio_direction
The direction of the GPIO port (input or output).
Definition: gpio-defs.h:105
lpc176x_gpio_ports
The ports for a GPIO.
Definition: gpio-defs.h:130
lpc176x_interrupt_address
Addresses for the two interrupts.
Definition: gpio-defs.h:159
lpc176x_gpio_address
Addresses for a GPIO.
Definition: gpio-defs.h:145
void(* lpc176x_gpio_interrupt_function)(const lpc176x_pin_number pin, const lpc176x_gpio_interrupt edge)
A function that attends an interrupt for GPIO.
Definition: gpio-defs.h:197
lpc176x_gpio_interrupt
The interrupt sources edge for a GPIO.
Definition: gpio-defs.h:117
GPIO Interrupt register map.
Definition: gpio-defs.h:167
volatile uint32_t EnF
Interrupt Enable for Falling edge.
Definition: gpio-defs.h:187
volatile uint32_t EnR
Interrupt Enable for Rising edge.
Definition: gpio-defs.h:183
volatile uint32_t Clr
Interrupt Clear.
Definition: gpio-defs.h:179
volatile uint32_t StatF
Interrupt Enable for Falling edge.
Definition: gpio-defs.h:175
volatile uint32_t StatR
Interrupt Enable for Rising edge.
Definition: gpio-defs.h:171
A registered interrupt function for the pin 'pin'.
Definition: gpio-defs.h:205
lpc176x_pin_number pin
Pin board.
Definition: gpio-defs.h:209
lpc176x_gpio_interrupt_function function
A function that attends an interrupt for 'pin'.
Definition: gpio-defs.h:213