stm32f10x_gpio.h
Go to the documentation of this file.
1 
23 /* Define to prevent recursive inclusion -------------------------------------*/
24 #ifndef __STM32F10x_GPIO_H
25 #define __STM32F10x_GPIO_H
26 
27 #ifdef __cplusplus
28  extern "C" {
29 #endif
30 
31 /* Includes ------------------------------------------------------------------*/
32 #include "stm32f10x.h"
33 
46 #define IS_GPIO_ALL_PERIPH(PERIPH) (((PERIPH) == GPIOA) || \
47  ((PERIPH) == GPIOB) || \
48  ((PERIPH) == GPIOC) || \
49  ((PERIPH) == GPIOD) || \
50  ((PERIPH) == GPIOE) || \
51  ((PERIPH) == GPIOF) || \
52  ((PERIPH) == GPIOG))
53 
58 typedef enum
59 {
64 #define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_Speed_10MHz) || ((SPEED) == GPIO_Speed_2MHz) || \
65  ((SPEED) == GPIO_Speed_50MHz))
66 
71 typedef enum
72 { GPIO_Mode_AIN = 0x0,
74  GPIO_Mode_IPD = 0x28,
75  GPIO_Mode_IPU = 0x48,
81 
82 #define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_AIN) || ((MODE) == GPIO_Mode_IN_FLOATING) || \
83  ((MODE) == GPIO_Mode_IPD) || ((MODE) == GPIO_Mode_IPU) || \
84  ((MODE) == GPIO_Mode_Out_OD) || ((MODE) == GPIO_Mode_Out_PP) || \
85  ((MODE) == GPIO_Mode_AF_OD) || ((MODE) == GPIO_Mode_AF_PP))
86 
91 typedef struct
92 {
93  uint16_t GPIO_Pin;
96  GPIOSpeed_TypeDef GPIO_Speed;
102 
103 
108 typedef enum
109 { Bit_RESET = 0,
111 }BitAction;
112 
113 #define IS_GPIO_BIT_ACTION(ACTION) (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET))
114 
127 #define GPIO_Pin_0 ((uint16_t)0x0001)
128 #define GPIO_Pin_1 ((uint16_t)0x0002)
129 #define GPIO_Pin_2 ((uint16_t)0x0004)
130 #define GPIO_Pin_3 ((uint16_t)0x0008)
131 #define GPIO_Pin_4 ((uint16_t)0x0010)
132 #define GPIO_Pin_5 ((uint16_t)0x0020)
133 #define GPIO_Pin_6 ((uint16_t)0x0040)
134 #define GPIO_Pin_7 ((uint16_t)0x0080)
135 #define GPIO_Pin_8 ((uint16_t)0x0100)
136 #define GPIO_Pin_9 ((uint16_t)0x0200)
137 #define GPIO_Pin_10 ((uint16_t)0x0400)
138 #define GPIO_Pin_11 ((uint16_t)0x0800)
139 #define GPIO_Pin_12 ((uint16_t)0x1000)
140 #define GPIO_Pin_13 ((uint16_t)0x2000)
141 #define GPIO_Pin_14 ((uint16_t)0x4000)
142 #define GPIO_Pin_15 ((uint16_t)0x8000)
143 #define GPIO_Pin_All ((uint16_t)0xFFFF)
145 #define IS_GPIO_PIN(PIN) ((((PIN) & (uint16_t)0x00) == 0x00) && ((PIN) != (uint16_t)0x00))
146 
147 #define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \
148  ((PIN) == GPIO_Pin_1) || \
149  ((PIN) == GPIO_Pin_2) || \
150  ((PIN) == GPIO_Pin_3) || \
151  ((PIN) == GPIO_Pin_4) || \
152  ((PIN) == GPIO_Pin_5) || \
153  ((PIN) == GPIO_Pin_6) || \
154  ((PIN) == GPIO_Pin_7) || \
155  ((PIN) == GPIO_Pin_8) || \
156  ((PIN) == GPIO_Pin_9) || \
157  ((PIN) == GPIO_Pin_10) || \
158  ((PIN) == GPIO_Pin_11) || \
159  ((PIN) == GPIO_Pin_12) || \
160  ((PIN) == GPIO_Pin_13) || \
161  ((PIN) == GPIO_Pin_14) || \
162  ((PIN) == GPIO_Pin_15))
163 
172 #define GPIO_Remap_SPI1 ((uint32_t)0x00000001)
173 #define GPIO_Remap_I2C1 ((uint32_t)0x00000002)
174 #define GPIO_Remap_USART1 ((uint32_t)0x00000004)
175 #define GPIO_Remap_USART2 ((uint32_t)0x00000008)
176 #define GPIO_PartialRemap_USART3 ((uint32_t)0x00140010)
177 #define GPIO_FullRemap_USART3 ((uint32_t)0x00140030)
178 #define GPIO_PartialRemap_TIM1 ((uint32_t)0x00160040)
179 #define GPIO_FullRemap_TIM1 ((uint32_t)0x001600C0)
180 #define GPIO_PartialRemap1_TIM2 ((uint32_t)0x00180100)
181 #define GPIO_PartialRemap2_TIM2 ((uint32_t)0x00180200)
182 #define GPIO_FullRemap_TIM2 ((uint32_t)0x00180300)
183 #define GPIO_PartialRemap_TIM3 ((uint32_t)0x001A0800)
184 #define GPIO_FullRemap_TIM3 ((uint32_t)0x001A0C00)
185 #define GPIO_Remap_TIM4 ((uint32_t)0x00001000)
186 #define GPIO_Remap1_CAN1 ((uint32_t)0x001D4000)
187 #define GPIO_Remap2_CAN1 ((uint32_t)0x001D6000)
188 #define GPIO_Remap_PD01 ((uint32_t)0x00008000)
189 #define GPIO_Remap_TIM5CH4_LSI ((uint32_t)0x00200001)
190 #define GPIO_Remap_ADC1_ETRGINJ ((uint32_t)0x00200002)
191 #define GPIO_Remap_ADC1_ETRGREG ((uint32_t)0x00200004)
192 #define GPIO_Remap_ADC2_ETRGINJ ((uint32_t)0x00200008)
193 #define GPIO_Remap_ADC2_ETRGREG ((uint32_t)0x00200010)
194 #define GPIO_Remap_ETH ((uint32_t)0x00200020)
195 #define GPIO_Remap_CAN2 ((uint32_t)0x00200040)
196 #define GPIO_Remap_SWJ_NoJTRST ((uint32_t)0x00300100)
197 #define GPIO_Remap_SWJ_JTAGDisable ((uint32_t)0x00300200)
198 #define GPIO_Remap_SWJ_Disable ((uint32_t)0x00300400)
199 #define GPIO_Remap_SPI3 ((uint32_t)0x00201100)
200 #define GPIO_Remap_TIM2ITR1_PTP_SOF ((uint32_t)0x00202000)
203 #define GPIO_Remap_PTP_PPS ((uint32_t)0x00204000)
205 #define GPIO_Remap_TIM15 ((uint32_t)0x80000001)
206 #define GPIO_Remap_TIM16 ((uint32_t)0x80000002)
207 #define GPIO_Remap_TIM17 ((uint32_t)0x80000004)
208 #define GPIO_Remap_CEC ((uint32_t)0x80000008)
209 #define GPIO_Remap_TIM1_DMA ((uint32_t)0x80000010)
211 #define GPIO_Remap_TIM9 ((uint32_t)0x80000020)
212 #define GPIO_Remap_TIM10 ((uint32_t)0x80000040)
213 #define GPIO_Remap_TIM11 ((uint32_t)0x80000080)
214 #define GPIO_Remap_TIM13 ((uint32_t)0x80000100)
215 #define GPIO_Remap_TIM14 ((uint32_t)0x80000200)
216 #define GPIO_Remap_FSMC_NADV ((uint32_t)0x80000400)
218 #define GPIO_Remap_TIM67_DAC_DMA ((uint32_t)0x80000800)
219 #define GPIO_Remap_TIM12 ((uint32_t)0x80001000)
220 #define GPIO_Remap_MISC ((uint32_t)0x80002000)
223 #define IS_GPIO_REMAP(REMAP) (((REMAP) == GPIO_Remap_SPI1) || ((REMAP) == GPIO_Remap_I2C1) || \
224  ((REMAP) == GPIO_Remap_USART1) || ((REMAP) == GPIO_Remap_USART2) || \
225  ((REMAP) == GPIO_PartialRemap_USART3) || ((REMAP) == GPIO_FullRemap_USART3) || \
226  ((REMAP) == GPIO_PartialRemap_TIM1) || ((REMAP) == GPIO_FullRemap_TIM1) || \
227  ((REMAP) == GPIO_PartialRemap1_TIM2) || ((REMAP) == GPIO_PartialRemap2_TIM2) || \
228  ((REMAP) == GPIO_FullRemap_TIM2) || ((REMAP) == GPIO_PartialRemap_TIM3) || \
229  ((REMAP) == GPIO_FullRemap_TIM3) || ((REMAP) == GPIO_Remap_TIM4) || \
230  ((REMAP) == GPIO_Remap1_CAN1) || ((REMAP) == GPIO_Remap2_CAN1) || \
231  ((REMAP) == GPIO_Remap_PD01) || ((REMAP) == GPIO_Remap_TIM5CH4_LSI) || \
232  ((REMAP) == GPIO_Remap_ADC1_ETRGINJ) ||((REMAP) == GPIO_Remap_ADC1_ETRGREG) || \
233  ((REMAP) == GPIO_Remap_ADC2_ETRGINJ) ||((REMAP) == GPIO_Remap_ADC2_ETRGREG) || \
234  ((REMAP) == GPIO_Remap_ETH) ||((REMAP) == GPIO_Remap_CAN2) || \
235  ((REMAP) == GPIO_Remap_SWJ_NoJTRST) || ((REMAP) == GPIO_Remap_SWJ_JTAGDisable) || \
236  ((REMAP) == GPIO_Remap_SWJ_Disable)|| ((REMAP) == GPIO_Remap_SPI3) || \
237  ((REMAP) == GPIO_Remap_TIM2ITR1_PTP_SOF) || ((REMAP) == GPIO_Remap_PTP_PPS) || \
238  ((REMAP) == GPIO_Remap_TIM15) || ((REMAP) == GPIO_Remap_TIM16) || \
239  ((REMAP) == GPIO_Remap_TIM17) || ((REMAP) == GPIO_Remap_CEC) || \
240  ((REMAP) == GPIO_Remap_TIM1_DMA) || ((REMAP) == GPIO_Remap_TIM9) || \
241  ((REMAP) == GPIO_Remap_TIM10) || ((REMAP) == GPIO_Remap_TIM11) || \
242  ((REMAP) == GPIO_Remap_TIM13) || ((REMAP) == GPIO_Remap_TIM14) || \
243  ((REMAP) == GPIO_Remap_FSMC_NADV) || ((REMAP) == GPIO_Remap_TIM67_DAC_DMA) || \
244  ((REMAP) == GPIO_Remap_TIM12) || ((REMAP) == GPIO_Remap_MISC))
245 
254 #define GPIO_PortSourceGPIOA ((uint8_t)0x00)
255 #define GPIO_PortSourceGPIOB ((uint8_t)0x01)
256 #define GPIO_PortSourceGPIOC ((uint8_t)0x02)
257 #define GPIO_PortSourceGPIOD ((uint8_t)0x03)
258 #define GPIO_PortSourceGPIOE ((uint8_t)0x04)
259 #define GPIO_PortSourceGPIOF ((uint8_t)0x05)
260 #define GPIO_PortSourceGPIOG ((uint8_t)0x06)
261 #define IS_GPIO_EVENTOUT_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == GPIO_PortSourceGPIOA) || \
262  ((PORTSOURCE) == GPIO_PortSourceGPIOB) || \
263  ((PORTSOURCE) == GPIO_PortSourceGPIOC) || \
264  ((PORTSOURCE) == GPIO_PortSourceGPIOD) || \
265  ((PORTSOURCE) == GPIO_PortSourceGPIOE))
266 
267 #define IS_GPIO_EXTI_PORT_SOURCE(PORTSOURCE) (((PORTSOURCE) == GPIO_PortSourceGPIOA) || \
268  ((PORTSOURCE) == GPIO_PortSourceGPIOB) || \
269  ((PORTSOURCE) == GPIO_PortSourceGPIOC) || \
270  ((PORTSOURCE) == GPIO_PortSourceGPIOD) || \
271  ((PORTSOURCE) == GPIO_PortSourceGPIOE) || \
272  ((PORTSOURCE) == GPIO_PortSourceGPIOF) || \
273  ((PORTSOURCE) == GPIO_PortSourceGPIOG))
274 
283 #define GPIO_PinSource0 ((uint8_t)0x00)
284 #define GPIO_PinSource1 ((uint8_t)0x01)
285 #define GPIO_PinSource2 ((uint8_t)0x02)
286 #define GPIO_PinSource3 ((uint8_t)0x03)
287 #define GPIO_PinSource4 ((uint8_t)0x04)
288 #define GPIO_PinSource5 ((uint8_t)0x05)
289 #define GPIO_PinSource6 ((uint8_t)0x06)
290 #define GPIO_PinSource7 ((uint8_t)0x07)
291 #define GPIO_PinSource8 ((uint8_t)0x08)
292 #define GPIO_PinSource9 ((uint8_t)0x09)
293 #define GPIO_PinSource10 ((uint8_t)0x0A)
294 #define GPIO_PinSource11 ((uint8_t)0x0B)
295 #define GPIO_PinSource12 ((uint8_t)0x0C)
296 #define GPIO_PinSource13 ((uint8_t)0x0D)
297 #define GPIO_PinSource14 ((uint8_t)0x0E)
298 #define GPIO_PinSource15 ((uint8_t)0x0F)
300 #define IS_GPIO_PIN_SOURCE(PINSOURCE) (((PINSOURCE) == GPIO_PinSource0) || \
301  ((PINSOURCE) == GPIO_PinSource1) || \
302  ((PINSOURCE) == GPIO_PinSource2) || \
303  ((PINSOURCE) == GPIO_PinSource3) || \
304  ((PINSOURCE) == GPIO_PinSource4) || \
305  ((PINSOURCE) == GPIO_PinSource5) || \
306  ((PINSOURCE) == GPIO_PinSource6) || \
307  ((PINSOURCE) == GPIO_PinSource7) || \
308  ((PINSOURCE) == GPIO_PinSource8) || \
309  ((PINSOURCE) == GPIO_PinSource9) || \
310  ((PINSOURCE) == GPIO_PinSource10) || \
311  ((PINSOURCE) == GPIO_PinSource11) || \
312  ((PINSOURCE) == GPIO_PinSource12) || \
313  ((PINSOURCE) == GPIO_PinSource13) || \
314  ((PINSOURCE) == GPIO_PinSource14) || \
315  ((PINSOURCE) == GPIO_PinSource15))
316 
324 #define GPIO_ETH_MediaInterface_MII ((u32)0x00000000)
325 #define GPIO_ETH_MediaInterface_RMII ((u32)0x00000001)
326 
327 #define IS_GPIO_ETH_MEDIA_INTERFACE(INTERFACE) (((INTERFACE) == GPIO_ETH_MediaInterface_MII) || \
328  ((INTERFACE) == GPIO_ETH_MediaInterface_RMII))
329 
349 void GPIO_DeInit(GPIO_TypeDef* GPIOx);
350 void GPIO_AFIODeInit(void);
351 void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
352 void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
353 uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
354 uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
355 uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
356 uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
357 void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
358 void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
359 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);
360 void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);
361 void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
362 void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource);
363 void GPIO_EventOutputCmd(FunctionalState NewState);
364 void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState);
365 void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource);
366 void GPIO_ETH_MediaInterfaceConfig(uint32_t GPIO_ETH_MediaInterface);
367 
368 #ifdef __cplusplus
369 }
370 #endif
371 
372 #endif /* __STM32F10x_GPIO_H */
373 
385 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
void GPIO_SetBits(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Sets the selected data port bits.
void GPIO_StructInit(GPIO_InitTypeDef *GPIO_InitStruct)
Fills each GPIO_InitStruct member with its default value.
GPIOMode_TypeDef
Configuration Mode enumeration.
void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource)
Selects the GPIO pin used as Event output.
FunctionalState
Definition: stm32f4xx.h:708
GPIOMode_TypeDef
GPIO Configuration Mode enumeration.
void GPIO_EventOutputCmd(FunctionalState NewState)
Enables or disables the Event Output.
void GPIO_DeInit(GPIO_TypeDef *GPIOx)
De-initializes the GPIOx peripheral registers to their default reset values.
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Reads the specified output data port bit.
void GPIO_WriteBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
Sets or clears the selected data port bit.
void GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_InitStruct)
Initializes the GPIOx peripheral according to the specified parameters in the GPIO_InitStruct.
void GPIO_ResetBits(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Clears the selected data port bits.
void GPIO_PinLockConfig(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Locks GPIO Pins configuration registers.
void GPIO_AFIODeInit(void)
Deinitializes the Alternate Functions (remap, event control and EXTI configuration) registers to thei...
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
void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource)
Selects the GPIO pin used as EXTI Line.
GPIO_Pin
Definition: drv_gpio.h:41
GPIO_Speed
Definition: drv_gpio.h:35
GPIO_Mode
Definition: drv_gpio.h:24
void GPIO_ETH_MediaInterfaceConfig(uint32_t GPIO_ETH_MediaInterface)
Selects the Ethernet media interface.
void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState)
Changes the mapping of the specified pin.
BitAction
Bit_SET and Bit_RESET enumeration.
uint16_t GPIO_ReadInputData(GPIO_TypeDef *GPIOx)
Reads the specified GPIO input data port.
uint16_t GPIO_ReadOutputData(GPIO_TypeDef *GPIOx)
Reads the specified GPIO output data port.
CMSIS Cortex-M3 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
Reads the specified input port pin.
GPIOSpeed_TypeDef
Output Maximum frequency selection.


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