Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
gpio_arch.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Felix Ruess <felix.ruess@gmail.com>
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
29#include "mcu_periph/gpio.h"
30
31#include <libopencm3/stm32/gpio.h>
32#include <libopencm3/stm32/rcc.h>
33
35{
36 switch (port) {
37 case GPIOA:
39 break;
40 case GPIOB:
42 break;
43 case GPIOC:
45 break;
46 case GPIOD:
48 break;
49#ifdef GPIOE
50 case GPIOE:
52 break;
53#endif
54#ifdef GPIOF
55 case GPIOF:
57 break;
58#endif
59#ifdef GPIOG
60 case GPIOG:
62 break;
63#endif
64#ifdef GPIOH
65 case GPIOH:
67 break;
68#endif
69#ifdef GPIOI
70 case GPIOI:
72 break;
73#endif
74 default:
75 break;
76 };
77}
78
79#ifdef STM32F1
81{
84}
85
87{
90}
91
93{
95 gpio_set(port, gpios);
97}
98
100{
101 gpio_enable_clock(port);
102 gpio_clear(port, gpios);
104}
105
107{
108 gpio_enable_clock(port);
109 /* remap alternate function if needed */
110 if (af) {
112 AFIO_MAPR |= af;
113 }
114 if (is_output) {
116 } else {
118 }
119}
120
122{
123 gpio_enable_clock(port);
125}
126
127#elif defined STM32F4
128
130{
131 gpio_enable_clock(port);
133}
134
136{
137 gpio_enable_clock(port);
139}
140
142{
143 gpio_enable_clock(port);
145}
146
148{
149 gpio_enable_clock(port);
151}
152
153void gpio_setup_pin_af(uint32_t port, uint16_t pin, uint8_t af, bool is_output __attribute__((unused)))
154{
155 gpio_enable_clock(port);
156 gpio_set_af(port, af, pin);
158}
159
161{
162 gpio_enable_clock(port);
164}
165
166#endif
167
void gpio_setup_input_pullup(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs with pull up resistor enabled.
Definition gpio_arch.c:47
void gpio_setup_input_pulldown(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs with pull down resistors enabled.
Definition gpio_arch.c:54
void gpio_setup_pin_af(ioportid_t port, uint16_t pin, uint8_t af, bool is_output)
Setup a gpio for input or output with alternate function.
Definition gpio_arch.c:65
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
Definition gpio_arch.c:33
void gpio_setup_input(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs.
Definition gpio_arch.c:40
void gpio_setup_pin_analog(ioportid_t port, uint16_t pin)
Setup a gpio for analog use.
Definition gpio_arch.c:90
Some architecture independent helper functions for GPIOs.
void gpio_set(uint32_t port, uint16_t pin)
Set a gpio output to high level.
Definition gpio_arch.c:35
void gpio_clear(uint32_t port, uint16_t pin)
Clear a gpio output to low level.
Definition gpio_arch.c:37
uint16_t foo
Definition main_demo5.c:58
#define GPIOG
Definition gpio_arch.h:40
#define GPIOC
Definition gpio_arch.h:36
#define GPIOF
Definition gpio_arch.h:39
#define GPIOB
Definition gpio_arch.h:35
#define GPIOD
Definition gpio_arch.h:37
#define GPIOA
Definition gpio_arch.h:34
#define GPIOH
Definition gpio_arch.h:41
#define GPIOE
Definition gpio_arch.h:38
void gpio_enable_clock(uint32_t port)
Enable the relevant clock.
Definition gpio_arch.c:34
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.