stm32f30x_gpio.h
Go to the documentation of this file.
1 
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F30x_GPIO_H
31 #define __STM32F30x_GPIO_H
32 
33 #ifdef __cplusplus
34  extern "C" {
35 #endif
36 
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f30x.h"
39 
48 /* Exported types ------------------------------------------------------------*/
49 
50 #define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \
51  ((PERIPH) == GPIOB) || \
52  ((PERIPH) == GPIOC) || \
53  ((PERIPH) == GPIOD) || \
54  ((PERIPH) == GPIOE) || \
55  ((PERIPH) == GPIOF))
56 
57 #define IS_GPIO_LIST_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \
58  ((PERIPH) == GPIOB) || \
59  ((PERIPH) == GPIOD))
60 
63 typedef enum
64 {
65  GPIO_Mode_IN = 0x00,
66  GPIO_Mode_OUT = 0x01,
67  GPIO_Mode_AF = 0x02,
68  GPIO_Mode_AN = 0x03
70 
71 #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN)|| ((MODE) == GPIO_Mode_OUT) || \
72  ((MODE) == GPIO_Mode_AF)|| ((MODE) == GPIO_Mode_AN))
73 
80 typedef enum
81 {
82  GPIO_OType_PP = 0x00,
85 
86 #define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD))
87 
95 typedef enum
96 {
101 
102 #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_Level_1) || ((SPEED) == GPIO_Speed_Level_2) || \
103  ((SPEED) == GPIO_Speed_Level_3))
104 
111 typedef enum
112 {
114  GPIO_PuPd_UP = 0x01,
117 
118 #define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \
119  ((PUPD) == GPIO_PuPd_DOWN))
120 
127 typedef enum
128 {
131 }BitAction;
132 
133 #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET))
134 
141 typedef struct
142 {
143  uint32_t GPIO_Pin;
152  GPIOOType_TypeDef GPIO_OType;
155  GPIOPuPd_TypeDef GPIO_PuPd;
158 
159 /* Exported constants --------------------------------------------------------*/
160 
168 #define GPIO_Pin_0 ((uint16_t)0x0001)
169 #define GPIO_Pin_1 ((uint16_t)0x0002)
170 #define GPIO_Pin_2 ((uint16_t)0x0004)
171 #define GPIO_Pin_3 ((uint16_t)0x0008)
172 #define GPIO_Pin_4 ((uint16_t)0x0010)
173 #define GPIO_Pin_5 ((uint16_t)0x0020)
174 #define GPIO_Pin_6 ((uint16_t)0x0040)
175 #define GPIO_Pin_7 ((uint16_t)0x0080)
176 #define GPIO_Pin_8 ((uint16_t)0x0100)
177 #define GPIO_Pin_9 ((uint16_t)0x0200)
178 #define GPIO_Pin_10 ((uint16_t)0x0400)
179 #define GPIO_Pin_11 ((uint16_t)0x0800)
180 #define GPIO_Pin_12 ((uint16_t)0x1000)
181 #define GPIO_Pin_13 ((uint16_t)0x2000)
182 #define GPIO_Pin_14 ((uint16_t)0x4000)
183 #define GPIO_Pin_15 ((uint16_t)0x8000)
184 #define GPIO_Pin_All ((uint16_t)0xFFFF)
186 #define IS_GPIO_PIN(PIN) ((PIN) != (uint16_t)0x00)
187 
188 #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \
189  ((PIN) == GPIO_Pin_1) || \
190  ((PIN) == GPIO_Pin_2) || \
191  ((PIN) == GPIO_Pin_3) || \
192  ((PIN) == GPIO_Pin_4) || \
193  ((PIN) == GPIO_Pin_5) || \
194  ((PIN) == GPIO_Pin_6) || \
195  ((PIN) == GPIO_Pin_7) || \
196  ((PIN) == GPIO_Pin_8) || \
197  ((PIN) == GPIO_Pin_9) || \
198  ((PIN) == GPIO_Pin_10) || \
199  ((PIN) == GPIO_Pin_11) || \
200  ((PIN) == GPIO_Pin_12) || \
201  ((PIN) == GPIO_Pin_13) || \
202  ((PIN) == GPIO_Pin_14) || \
203  ((PIN) == GPIO_Pin_15))
204 
212 #define GPIO_PinSource0 ((uint8_t)0x00)
213 #define GPIO_PinSource1 ((uint8_t)0x01)
214 #define GPIO_PinSource2 ((uint8_t)0x02)
215 #define GPIO_PinSource3 ((uint8_t)0x03)
216 #define GPIO_PinSource4 ((uint8_t)0x04)
217 #define GPIO_PinSource5 ((uint8_t)0x05)
218 #define GPIO_PinSource6 ((uint8_t)0x06)
219 #define GPIO_PinSource7 ((uint8_t)0x07)
220 #define GPIO_PinSource8 ((uint8_t)0x08)
221 #define GPIO_PinSource9 ((uint8_t)0x09)
222 #define GPIO_PinSource10 ((uint8_t)0x0A)
223 #define GPIO_PinSource11 ((uint8_t)0x0B)
224 #define GPIO_PinSource12 ((uint8_t)0x0C)
225 #define GPIO_PinSource13 ((uint8_t)0x0D)
226 #define GPIO_PinSource14 ((uint8_t)0x0E)
227 #define GPIO_PinSource15 ((uint8_t)0x0F)
228 
229 #define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \
230  ((PINSOURCE) == GPIO_PinSource1) || \
231  ((PINSOURCE) == GPIO_PinSource2) || \
232  ((PINSOURCE) == GPIO_PinSource3) || \
233  ((PINSOURCE) == GPIO_PinSource4) || \
234  ((PINSOURCE) == GPIO_PinSource5) || \
235  ((PINSOURCE) == GPIO_PinSource6) || \
236  ((PINSOURCE) == GPIO_PinSource7) || \
237  ((PINSOURCE) == GPIO_PinSource8) || \
238  ((PINSOURCE) == GPIO_PinSource9) || \
239  ((PINSOURCE) == GPIO_PinSource10) || \
240  ((PINSOURCE) == GPIO_PinSource11) || \
241  ((PINSOURCE) == GPIO_PinSource12) || \
242  ((PINSOURCE) == GPIO_PinSource13) || \
243  ((PINSOURCE) == GPIO_PinSource14) || \
244  ((PINSOURCE) == GPIO_PinSource15))
245 
256 #define GPIO_AF_0 ((uint8_t)0x00) /* JTCK-SWCLK, JTDI, JTDO/TRACESW0, JTMS-SWDAT,
257  MCO, NJTRST, TRACED, TRACECK */
258 
261 #define GPIO_AF_1 ((uint8_t)0x01) /* OUT, TIM2, TIM15, TIM16, TIM17 */
262 
266 #define GPIO_AF_2 ((uint8_t)0x02) /* COMP1_OUT, TIM1, TIM2, TIM3, TIM4, TIM8, TIM15, TIM16 */
267 
271 #define GPIO_AF_3 ((uint8_t)0x03) /* COMP7_OUT, TIM8, TIM15, Touch, HRTIM1 */
272 
276 #define GPIO_AF_4 ((uint8_t)0x04) /* I2C1, I2C2, TIM1, TIM8, TIM16, TIM17 */
277 
281 #define GPIO_AF_5 ((uint8_t)0x05) /* IR_OUT, I2S2, I2S3, SPI1, SPI2, TIM8, USART4, USART5 */
282 
286 #define GPIO_AF_6 ((uint8_t)0x06) /* IR_OUT, I2S2, I2S3, SPI2, SPI3, TIM1, TIM8 */
287 
291 #define GPIO_AF_7 ((uint8_t)0x07) /* AOP2_OUT, CAN, COMP3_OUT, COMP5_OUT, COMP6_OUT,
292  USART1, USART2, USART3 */
293 
297 #define GPIO_AF_8 ((uint8_t)0x08) /* COMP1_OUT, COMP2_OUT, COMP3_OUT, COMP4_OUT,
298  COMP5_OUT, COMP6_OUT */
299 
303 #define GPIO_AF_9 ((uint8_t)0x09) /* AOP4_OUT, CAN, TIM1, TIM8, TIM15 */
304 
308 #define GPIO_AF_10 ((uint8_t)0x0A) /* AOP1_OUT, AOP3_OUT, TIM2, TIM3, TIM4, TIM8, TIM17 */
309 
313 #define GPIO_AF_11 ((uint8_t)0x0B) /* TIM1, TIM8 */
314 
318 #define GPIO_AF_12 ((uint8_t)0x0C) /* TIM1, HRTIM1 */
319 
323 #define GPIO_AF_13 ((uint8_t)0x0D) /* HRTIM1, AOP2_OUT */
324 
328 #define GPIO_AF_14 ((uint8_t)0x0E) /* USBDM, USBDP */
329 
333 #define GPIO_AF_15 ((uint8_t)0x0F) /* OUT */
334 
335 #define IS_GPIO_AF(AF) (((AF) == GPIO_AF_0)||((AF) == GPIO_AF_1)||\
336  ((AF) == GPIO_AF_2)||((AF) == GPIO_AF_3)||\
337  ((AF) == GPIO_AF_4)||((AF) == GPIO_AF_5)||\
338  ((AF) == GPIO_AF_6)||((AF) == GPIO_AF_7)||\
339  ((AF) == GPIO_AF_8)||((AF) == GPIO_AF_9)||\
340  ((AF) == GPIO_AF_10)||((AF) == GPIO_AF_11)||\
341  ((AF) == GPIO_AF_12)||((AF) == GPIO_AF_13)||\
342  ((AF) == GPIO_AF_14)||((AF) == GPIO_AF_15))
343 
352 #define GPIO_Speed_10MHz GPIO_Speed_Level_1
353 #define GPIO_Speed_2MHz GPIO_Speed_Level_2
354 #define GPIO_Speed_50MHz GPIO_Speed_Level_3
364 /* Exported macro ------------------------------------------------------------*/
365 /* Exported functions ------------------------------------------------------- */
366 /* Function used to set the GPIO configuration to the default reset state *****/
367 void GPIO_DeInit(GPIO_TypeDef* GPIOx);
368 
369 /* Initialization and Configuration functions *********************************/
370 void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
371 void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
372 void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
373 
374 /* GPIO Read and Write functions **********************************************/
375 uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
376 uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
377 uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
378 uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
379 void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
380 void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
381 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);
382 void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);
383 
384 /* GPIO Alternate functions configuration functions ***************************/
385 void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF);
386 
387 #ifdef __cplusplus
388 }
389 #endif
390 
391 #endif /* __STM32F30x_GPIO_H */
392 
400 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
GPIOSpeed_TypeDef
void GPIO_PinAFConfig(GPIO_TypeDef *GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
Changes the mapping of the specified pin.
GPIOPuPd_TypeDef
GPIO Configuration PullUp PullDown enumeration.
GPIOSpeed_TypeDef
GPIO Output Maximum frequency enumeration.
GPIOMode_TypeDef
GPIO Configuration Mode enumeration.
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Reads the specified input port pin.
void GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_InitStruct)
Initializes the GPIOx peripheral according to the specified parameters in the GPIO_InitStruct.
BitAction
void GPIO_StructInit(GPIO_InitTypeDef *GPIO_InitStruct)
Fills each GPIO_InitStruct member with its default value.
void GPIO_Write(GPIO_TypeDef *GPIOx, uint16_t PortVal)
Writes data to the specified GPIO data port.
General Purpose I/O.
Definition: stm32f4xx.h:1281
GPIOOType_TypeDef
GPIO_Pin
Definition: drv_gpio.h:41
void GPIO_WriteBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
Sets or clears the selected data port bit.
GPIOMode_TypeDef
GPIO_Speed
Definition: drv_gpio.h:35
GPIO_Mode
Definition: drv_gpio.h:24
GPIOPuPd_TypeDef
void GPIO_PinLockConfig(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Locks GPIO Pins configuration registers.
GPIOOType_TypeDef
GPIO Output type enumeration.
uint16_t GPIO_ReadInputData(GPIO_TypeDef *GPIOx)
Reads the specified GPIO input data port.
void GPIO_DeInit(GPIO_TypeDef *GPIOx)
De-initializes the GPIOx peripheral registers to their default reset values.
uint16_t GPIO_ReadOutputData(GPIO_TypeDef *GPIOx)
Reads the specified GPIO output data port.
void GPIO_ResetBits(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Clears the selected data port bits.
void GPIO_SetBits(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Sets the selected data port bits.
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Reads the specified output data port bit.


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:48