Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
firmware
boards
breezy
breezystm32
drv_gpio.h
Go to the documentation of this file.
1
/*
2
drv_gpio.c : GPIO support for STM32F103CB
3
4
Adapted from https://github.com/multiwii/baseflight/blob/master/src/drv_gpio.c
5
6
This file is part of BreezySTM32.
7
8
BreezySTM32 is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
12
13
BreezySTM32 is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with BreezySTM32. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#pragma once
23
24
typedef
enum
{
25
Mode_AIN
= 0x0,
26
Mode_IN_FLOATING
= 0x04,
27
Mode_IPD
= 0x28,
28
Mode_IPU
= 0x48,
29
Mode_Out_OD
= 0x14,
30
Mode_Out_PP
= 0x10,
31
Mode_AF_OD
= 0x1C,
32
Mode_AF_PP
= 0x18
33
}
GPIO_Mode
;
34
35
typedef
enum
{
36
Speed_10MHz
= 1,
37
Speed_2MHz
,
38
Speed_50MHz
39
}
GPIO_Speed
;
40
41
typedef
enum
{
42
Pin_0
= 0x0001,
43
Pin_1
= 0x0002,
44
Pin_2
= 0x0004,
45
Pin_3
= 0x0008,
46
Pin_4
= 0x0010,
47
Pin_5
= 0x0020,
48
Pin_6
= 0x0040,
49
Pin_7
= 0x0080,
50
Pin_8
= 0x0100,
51
Pin_9
= 0x0200,
52
Pin_10
= 0x0400,
53
Pin_11
= 0x0800,
54
Pin_12
= 0x1000,
55
Pin_13
= 0x2000,
56
Pin_14
= 0x4000,
57
Pin_15
= 0x8000,
58
Pin_All
= 0xFFFF
59
}
GPIO_Pin
;
60
61
typedef
struct
{
62
uint16_t
pin
;
63
GPIO_Mode
mode
;
64
GPIO_Speed
speed
;
65
}
gpio_config_t
;
66
67
#define digitalHi(p, i) { p->BSRR = i; }
68
#define digitalLo(p, i) { p->BRR = i; }
69
#define digitalToggle(p, i) { p->ODR ^= i; }
70
#define digitalIn(p, i) (p->IDR & i)
71
72
void
gpioInit
(
GPIO_TypeDef
*gpio,
gpio_config_t
*config);
73
void
gpioExtiLineConfig
(uint8_t portsrc, uint8_t pinsrc);
74
void
gpioPinRemapConfig
(uint32_t remap,
bool
enable);
Pin_2
Definition:
drv_gpio.h:44
Pin_8
Definition:
drv_gpio.h:50
Mode_IPD
Definition:
drv_gpio.h:27
gpio_config_t::mode
GPIO_Mode mode
Definition:
drv_gpio.h:63
gpio_config_t::speed
GPIO_Speed speed
Definition:
drv_gpio.h:64
Mode_Out_OD
Definition:
drv_gpio.h:29
gpioPinRemapConfig
void gpioPinRemapConfig(uint32_t remap, bool enable)
Definition:
drv_gpio.c:103
Pin_15
Definition:
drv_gpio.h:57
Pin_14
Definition:
drv_gpio.h:56
Speed_50MHz
Definition:
drv_gpio.h:38
Pin_13
Definition:
drv_gpio.h:55
Pin_6
Definition:
drv_gpio.h:48
Speed_10MHz
Definition:
drv_gpio.h:36
Pin_12
Definition:
drv_gpio.h:54
gpio_config_t::pin
uint16_t pin
Definition:
drv_gpio.h:62
gpio_config_t
Definition:
drv_gpio.h:61
GPIO_TypeDef
General Purpose I/O.
Definition:
stm32f4xx.h:1281
gpioExtiLineConfig
void gpioExtiLineConfig(uint8_t portsrc, uint8_t pinsrc)
Definition:
drv_gpio.c:88
gpioInit
void gpioInit(GPIO_TypeDef *gpio, gpio_config_t *config)
Definition:
drv_gpio.c:56
Mode_AF_OD
Definition:
drv_gpio.h:31
Pin_3
Definition:
drv_gpio.h:45
GPIO_Pin
GPIO_Pin
Definition:
drv_gpio.h:41
Speed_2MHz
Definition:
drv_gpio.h:37
GPIO_Speed
GPIO_Speed
Definition:
drv_gpio.h:35
Pin_9
Definition:
drv_gpio.h:51
Pin_4
Definition:
drv_gpio.h:46
GPIO_Mode
GPIO_Mode
Definition:
drv_gpio.h:24
Pin_10
Definition:
drv_gpio.h:52
Mode_IPU
Definition:
drv_gpio.h:28
Pin_1
Definition:
drv_gpio.h:43
Mode_Out_PP
Definition:
drv_gpio.h:30
Pin_5
Definition:
drv_gpio.h:47
Pin_All
Definition:
drv_gpio.h:58
Mode_AIN
Definition:
drv_gpio.h:25
Mode_IN_FLOATING
Definition:
drv_gpio.h:26
Pin_11
Definition:
drv_gpio.h:53
Pin_0
Definition:
drv_gpio.h:42
Pin_7
Definition:
drv_gpio.h:49
Mode_AF_PP
Definition:
drv_gpio.h:32
rosflight_firmware
Author(s): Daniel Koch
, James Jackson
autogenerated on Thu Apr 15 2021 05:07:46