BSPACM  20150113
Board Support Package for ARM Cortex-M Microcontrollers
gpio.h
Go to the documentation of this file.
1 /* Copyright 2014, Peter A. Bigot
2  *
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the software nor the names of its contributors may be
16  * used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
110 #ifndef BSPACM_DEVICE_TM4C_PERIPH_GPIO_H
111 #define BSPACM_DEVICE_TM4C_PERIPH_GPIO_H
112 
113 /* Standard port tag/shift map:
114  *
115  * PA 0 PB 1 PC 2 PD 3
116  * PE 4 PF 5 PG 6 PH 7
117  * *PJ 8 PK 9 PL 10 PM 11
118  * PN 12 *PP 13 PQ 14 PR 15
119  * PS 16 PT 17
120  */
121 
122 #include <bspacm/core.h>
123 
129 typedef struct sBSPACMdeviceTM4Cpinmux {
133  GPIOCommon_Type * port;
134 
136  uint8_t pin;
137 
150  uint8_t pctl;
151 
154  uint8_t irqn;
156 
188  int enablep);
189 
200 static BSPACM_CORE_INLINE
201 int
203 {
204  int tag = 'A' + shift;
205  if (('O' - 2) < tag) {
206  tag += 2;
207  } else if (('I' - 1) < tag) {
208  tag += 1;
209  }
210  return tag;
211 }
212 
226 static BSPACM_CORE_INLINE
227 int
229 {
230 #if defined(GPIOA_BASE)
231  if (gpio == (void*)GPIOA_BASE) return 0;
232 #endif
233 #if defined(GPIOA_AHB_BASE)
234  if (gpio == (void*)GPIOA_AHB_BASE) return 0;
235 #endif
236 #if defined(GPIOB_BASE)
237  if (gpio == (void*)GPIOB_BASE) return 1;
238 #endif
239 #if defined(GPIOB_AHB_BASE)
240  if (gpio == (void*)GPIOB_AHB_BASE) return 1;
241 #endif
242 #if defined(GPIOC_BASE)
243  if (gpio == (void*)GPIOC_BASE) return 2;
244 #endif
245 #if defined(GPIOC_AHB_BASE)
246  if (gpio == (void*)GPIOC_AHB_BASE) return 2;
247 #endif
248 #if defined(GPIOD_BASE)
249  if (gpio == (void*)GPIOD_BASE) return 3;
250 #endif
251 #if defined(GPIOD_AHB_BASE)
252  if (gpio == (void*)GPIOD_AHB_BASE) return 3;
253 #endif
254 #if defined(GPIOE_BASE)
255  if (gpio == (void*)GPIOE_BASE) return 4;
256 #endif
257 #if defined(GPIOE_AHB_BASE)
258  if (gpio == (void*)GPIOE_AHB_BASE) return 4;
259 #endif
260 #if defined(GPIOF_BASE)
261  if (gpio == (void*)GPIOF_BASE) return 5;
262 #endif
263 #if defined(GPIOF_AHB_BASE)
264  if (gpio == (void*)GPIOF_AHB_BASE) return 5;
265 #endif
266 #if defined(GPIOG_BASE)
267  if (gpio == (void*)GPIOG_BASE) return 6;
268 #endif
269 #if defined(GPIOG_AHB_BASE)
270  if (gpio == (void*)GPIOG_AHB_BASE) return 6;
271 #endif
272 #if defined(GPIOH_BASE)
273  if (gpio == (void*)GPIOH_BASE) return 7;
274 #endif
275 #if defined(GPIOH_AHB_BASE)
276  if (gpio == (void*)GPIOH_AHB_BASE) return 7;
277 #endif
278  /* No GPIOI */
279 #if defined(GPIOJ_BASE)
280  if (gpio == (void*)GPIOJ_BASE) return 8;
281 #endif
282 #if defined(GPIOJ_AHB_BASE)
283  if (gpio == (void*)GPIOJ_AHB_BASE) return 8;
284 #endif
285 #if defined(GPIOK_BASE)
286  if (gpio == (void*)GPIOK_BASE) return 9;
287 #endif
288 #if defined(GPIOK_AHB_BASE)
289  if (gpio == (void*)GPIOK_AHB_BASE) return 9;
290 #endif
291 #if defined(GPIOL_BASE)
292  if (gpio == (void*)GPIOL_BASE) return 10;
293 #endif
294 #if defined(GPIOL_AHB_BASE)
295  if (gpio == (void*)GPIOL_AHB_BASE) return 10;
296 #endif
297 #if defined(GPIOM_BASE)
298  if (gpio == (void*)GPIOM_BASE) return 11;
299 #endif
300 #if defined(GPIOM_AHB_BASE)
301  if (gpio == (void*)GPIOM_AHB_BASE) return 11;
302 #endif
303 #if defined(GPION_BASE)
304  if (gpio == (void*)GPION_BASE) return 12;
305 #endif
306 #if defined(GPION_AHB_BASE)
307  if (gpio == (void*)GPION_AHB_BASE) return 12;
308 #endif
309  /* No GPIOO */
310 #if defined(GPIOP_BASE)
311  if (gpio == (void*)GPIOP_BASE) return 13;
312 #endif
313 #if defined(GPIOP_AHB_BASE)
314  if (gpio == (void*)GPIOP_AHB_BASE) return 13;
315 #endif
316 #if defined(GPIOQ_BASE)
317  if (gpio == (void*)GPIOQ_BASE) return 14;
318 #endif
319 #if defined(GPIOQ_AHB_BASE)
320  if (gpio == (void*)GPIOQ_AHB_BASE) return 14;
321 #endif
322 #if defined(GPIOR_BASE)
323  if (gpio == (void*)GPIOR_BASE) return 15;
324 #endif
325 #if defined(GPIOR_AHB_BASE)
326  if (gpio == (void*)GPIOR_AHB_BASE) return 15;
327 #endif
328 #if defined(GPIOS_BASE)
329  if (gpio == (void*)GPIOS_BASE) return 16;
330 #endif
331 #if defined(GPIOS_AHB_BASE)
332  if (gpio == (void*)GPIOS_AHB_BASE) return 16;
333 #endif
334 #if defined(GPIOT_BASE)
335  if (gpio == (void*)GPIOT_BASE) return 17;
336 #endif
337 #if defined(GPIOT_AHB_BASE)
338  if (gpio == (void*)GPIOT_AHB_BASE) return 17;
339 #endif
340  return -1;
341 }
342 
343 #endif /* BSPACM_DEVICE_TM4C_PERIPH_GPIO_H */
Common header included by all BSPACM leaf headers.
struct sBSPACMdeviceTM4Cpinmux sBSPACMdeviceTM4Cpinmux
uint8_t pctl
Definition: gpio.h:150
GPIOCommon_Type * port
Definition: gpio.h:133
#define BSPACM_CORE_INLINE
Definition: core.h:65
static BSPACM_CORE_INLINE int iBSPACMdeviceTM4CgpioPortShift(void *gpio)
Definition: gpio.h:228
void vBSPACMdeviceTM4CpinmuxConfigure(const sBSPACMdeviceTM4Cpinmux *cfgp, int enablep)
uint8_t pin
Definition: gpio.h:136
static BSPACM_CORE_INLINE int iBSPACMdeviceTM4CgpioPortTagFromShift(unsigned int shift)
Definition: gpio.h:202
Definition: gpio.h:129
uint8_t irqn
Definition: gpio.h:154