RTEMS 7.0-rc1
Loading...
Searching...
No Matches
io.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
11/*
12 * Copyright (c) 2013 Eugeniy Meshcheryakov <eugen@debian.org>
13 *
14 * The license and distribution terms for this file may be
15 * found in the file LICENSE in this distribution or at
16 * http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef LIBBSP_ARM_LM3S69XX_IO_H
20#define LIBBSP_ARM_LM3S69XX_IO_H
21#include <bspopts.h>
22#include <stdbool.h>
23
32typedef enum {
33 LM3S69XX_GPIO_DIRECTION_INPUT,
34 LM3S69XX_GPIO_DIRECTION_OUTPUT
35} lm3s69xx_gpio_direction;
36
37typedef enum {
38 LM3S69XX_GPIO_OTYPE_PUSH_PULL,
39 LM3S69XX_GPIO_OTYPE_OPEN_DRAIN
40} lm3s69xx_gpio_otype;
41
42typedef enum {
43 LM3S69XX_GPIO_DRIVE_2MA,
44 LM3S69XX_GPIO_DRIVE_4MA,
45 LM3S69XX_GPIO_DRIVE_8MA
46} lm3s69xx_gpio_drive;
47
48typedef enum {
49 LM3S69XX_GPIO_NO_PULL,
50 LM3S69XX_GPIO_PULL_UP,
51 LM3S69XX_GPIO_PULL_DOWN
52} lm3s69xx_gpio_pull;
53
54typedef enum {
55 LM3S69XX_GPIO_DIGITAL_DISABLE,
56 LM3S69XX_GPIO_DIGITAL_ENABLE,
57} lm3s69xx_gpio_digital;
58
59typedef enum {
60 LM3S69XX_GPIO_AF_DISABLE,
61 LM3S69XX_GPIO_AF_ENABLE
62} lm3s69xx_gpio_af;
63
64typedef enum {
65 LM3S69XX_GPIO_ANALOG_DISABLE,
66 LM3S69XX_GPIO_ANALOG_ENABLE
67} lm3s69xx_gpio_analog;
68
69typedef enum {
70 LM3S69XX_GPIO_NO_SLEW_RATE_CONTROL,
71 LM3S69XX_GPIO_SLEW_RATE_CONTROL
72} lm3s69xx_gpio_slew_rate_control;
73
74typedef struct {
75 unsigned int pin_first : 8;
76 unsigned int pin_last : 8;
77 unsigned int digital : 1;
78 unsigned int alternate : 1;
79 unsigned int analog : 1;
80 unsigned int dir : 1;
81 unsigned int otype : 1;
82 unsigned int drive : 2;
83 unsigned int pull : 2;
84 unsigned int slr : 1;
86
87typedef enum {
88 LM3S69XX_PORT_A,
89 LM3S69XX_PORT_B,
90 LM3S69XX_PORT_C,
91 LM3S69XX_PORT_D,
92 LM3S69XX_PORT_E,
93 LM3S69XX_PORT_F,
94 LM3S69XX_PORT_G,
95#if LM3S69XX_NUM_GPIO_BLOCKS > 7
96 LM3S69XX_PORT_H
97#endif
98} lm3s69xx_gpio_port;
99
100#define LM3S69XX_GPIO_PIN(port, idx) (((port) << 3) | (idx))
101#define LM3S69XX_GPIO_PORT_OF_PIN(pin) (((pin) >> 3) & 0xf)
102#define LM3S69XX_GPIO_INDEX_OF_PIN(pin) ((pin) & 0x7)
103
104#define LM3S69XX_PIN_UART_TX(port, idx) \
105 { \
106 .pin_first = LM3S69XX_GPIO_PIN(port, idx), \
107 .pin_last = LM3S69XX_GPIO_PIN(port, idx), \
108 .digital = LM3S69XX_GPIO_DIGITAL_ENABLE, \
109 .alternate = LM3S69XX_GPIO_AF_ENABLE, \
110 .analog = LM3S69XX_GPIO_ANALOG_DISABLE, \
111 .dir = LM3S69XX_GPIO_DIRECTION_OUTPUT, \
112 .otype = LM3S69XX_GPIO_OTYPE_PUSH_PULL, \
113 .drive = LM3S69XX_GPIO_DRIVE_2MA, \
114 .pull = LM3S69XX_GPIO_NO_PULL, \
115 .slr = LM3S69XX_GPIO_NO_SLEW_RATE_CONTROL \
116 }
117
118#define LM3S69XX_PIN_UART_RX(port, idx) \
119 { \
120 .pin_first = LM3S69XX_GPIO_PIN(port, idx), \
121 .pin_last = LM3S69XX_GPIO_PIN(port, idx), \
122 .digital = LM3S69XX_GPIO_DIGITAL_ENABLE, \
123 .alternate = LM3S69XX_GPIO_AF_ENABLE, \
124 .analog = LM3S69XX_GPIO_ANALOG_DISABLE, \
125 .dir = LM3S69XX_GPIO_DIRECTION_INPUT, \
126 .otype = LM3S69XX_GPIO_OTYPE_PUSH_PULL, \
127 .drive = LM3S69XX_GPIO_DRIVE_2MA, \
128 .pull = LM3S69XX_GPIO_PULL_UP, \
129 .slr = LM3S69XX_GPIO_NO_SLEW_RATE_CONTROL \
130 }
131
132#define LM3S69XX_PIN_UART_RTS(port, idx) \
133 { \
134 .pin_first = LM3S69XX_GPIO_PIN(port, idx), \
135 .pin_last = LM3S69XX_GPIO_PIN(port, idx), \
136 .digital = LM3S69XX_GPIO_DIGITAL_ENABLE, \
137 .alternate = LM3S69XX_GPIO_AF_ENABLE, \
138 .analog = LM3S69XX_GPIO_ANALOG_DISABLE, \
139 .dir = LM3S69XX_GPIO_DIRECTION_OUTPUT, \
140 .otype = LM3S69XX_GPIO_OTYPE_PUSH_PULL, \
141 .drive = LM3S69XX_GPIO_DRIVE_2MA, \
142 .pull = LM3S69XX_GPIO_NO_PULL, \
143 .slr = LM3S69XX_GPIO_NO_SLEW_RATE_CONTROL \
144 }
145
146#define LM3S69XX_PIN_UART_CTS(port, idx) \
147 { \
148 .pin_first = LM3S69XX_GPIO_PIN(port, idx), \
149 .pin_last = LM3S69XX_GPIO_PIN(port, idx), \
150 .digital = LM3S69XX_GPIO_DIGITAL_ENABLE, \
151 .alternate = LM3S69XX_GPIO_AF_ENABLE, \
152 .analog = LM3S69XX_GPIO_ANALOG_DISABLE, \
153 .dir = LM3S69XX_GPIO_DIRECTION_INPUT, \
154 .otype = LM3S69XX_GPIO_OTYPE_PUSH_PULL, \
155 .drive = LM3S69XX_GPIO_DRIVE_2MA, \
156 .pull = LM3S69XX_GPIO_PULL_UP, \
157 .slr = LM3S69XX_GPIO_NO_SLEW_RATE_CONTROL \
158 }
159
160#define LM3S69XX_PIN_LED(port, idx) \
161 { \
162 .pin_first = LM3S69XX_GPIO_PIN(port, idx), \
163 .pin_last = LM3S69XX_GPIO_PIN(port, idx), \
164 .digital = LM3S69XX_GPIO_DIGITAL_ENABLE, \
165 .alternate = LM3S69XX_GPIO_AF_DISABLE, \
166 .analog = LM3S69XX_GPIO_ANALOG_DISABLE, \
167 .dir = LM3S69XX_GPIO_DIRECTION_OUTPUT, \
168 .otype = LM3S69XX_GPIO_OTYPE_PUSH_PULL, \
169 .drive = LM3S69XX_GPIO_DRIVE_8MA, \
170 .pull = LM3S69XX_GPIO_NO_PULL, \
171 .slr = LM3S69XX_GPIO_SLEW_RATE_CONTROL \
172 }
173
174#define LM3S69XX_PIN_SSI_TX(port, idx) LM3S69XX_PIN_UART_TX(port, idx)
175#define LM3S69XX_PIN_SSI_RX(port, idx) LM3S69XX_PIN_UART_RX(port, idx)
176
177#ifdef __cplusplus
178extern "C" {
179#endif
180
181void lm3s69xx_gpio_set_config(const lm3s69xx_gpio_config *config);
182void lm3s69xx_gpio_set_config_array(const lm3s69xx_gpio_config *configs, unsigned int count);
183void lm3s69xx_gpio_digital_enable(unsigned int pin, bool enable);
184void lm3s69xx_gpio_analog_mode_select(unsigned int pin, bool enable);
185
186void lm3s69xx_gpio_set_pin(unsigned int pin, bool set);
187bool lm3s69xx_gpio_get_pin(unsigned int pin);
188
189#ifdef __cplusplus
190}
191#endif
192
193#endif /* LIBBSP_ARM_LM3S69XX_IO_H */
void lm3s69xx_gpio_analog_mode_select(unsigned int pin, bool enable)
Definition: io.c:116
void lm3s69xx_gpio_digital_enable(unsigned int pin, bool enable)
Definition: io.c:101
Definition: io.h:74