STM32F2 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F2 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups

GPIO driver modules. More...

Modules

 GPIO_Exported_Constants
 
 GPIO_Private_Functions
 

Data Structures

struct  GPIO_InitTypeDef
 GPIO Init structure definition. More...
 

Macros

#define IS_GPIO_ALL_PERIPH(PERIPH)
 
#define IS_GPIO_MODE(MODE)
 
#define IS_GPIO_OTYPE(OTYPE)   (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD))
 
#define IS_GPIO_SPEED(SPEED)
 
#define IS_GPIO_PUPD(PUPD)
 
#define IS_GPIO_BIT_ACTION(ACTION)   (((ACTION) == Bit_RESET) || ((ACTION) == Bit_SET))
 

Enumerations

enum  GPIOMode_TypeDef { GPIO_Mode_IN = 0x00, GPIO_Mode_OUT = 0x01, GPIO_Mode_AF = 0x02, GPIO_Mode_AN = 0x03 }
 GPIO Configuration Mode enumeration. More...
 
enum  GPIOOType_TypeDef { GPIO_OType_PP = 0x00, GPIO_OType_OD = 0x01 }
 GPIO Output type enumeration.
 
enum  GPIOSpeed_TypeDef { GPIO_Speed_2MHz = 0x00, GPIO_Speed_25MHz = 0x01, GPIO_Speed_50MHz = 0x02, GPIO_Speed_100MHz = 0x03 }
 GPIO Output Maximum frequency enumeration. More...
 
enum  GPIOPuPd_TypeDef { GPIO_PuPd_NOPULL = 0x00, GPIO_PuPd_UP = 0x01, GPIO_PuPd_DOWN = 0x02 }
 GPIO Configuration PullUp PullDown enumeration.
 
enum  BitAction { Bit_RESET = 0, Bit_SET }
 GPIO Bit SET and Bit RESET enumeration.
 

Functions

void GPIO_DeInit (GPIO_TypeDef *GPIOx)
 Deinitializes the GPIOx peripheral registers to their default reset values. More...
 
void GPIO_Init (GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_InitStruct)
 Initializes the GPIOx peripheral according to the specified parameters in the GPIO_InitStruct. More...
 
void GPIO_StructInit (GPIO_InitTypeDef *GPIO_InitStruct)
 Fills each GPIO_InitStruct member with its default value. More...
 
void GPIO_PinLockConfig (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
 Locks GPIO Pins configuration registers. More...
 
uint8_t GPIO_ReadInputDataBit (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
 Reads the specified input port pin. More...
 
uint16_t GPIO_ReadInputData (GPIO_TypeDef *GPIOx)
 Reads the specified GPIO input data port. More...
 
uint8_t GPIO_ReadOutputDataBit (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
 Reads the specified output data port bit. More...
 
uint16_t GPIO_ReadOutputData (GPIO_TypeDef *GPIOx)
 Reads the specified GPIO output data port. More...
 
void GPIO_SetBits (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
 Sets the selected data port bits. More...
 
void GPIO_ResetBits (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
 Clears the selected data port bits. More...
 
void GPIO_WriteBit (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
 Sets or clears the selected data port bit. More...
 
void GPIO_Write (GPIO_TypeDef *GPIOx, uint16_t PortVal)
 Writes data to the specified GPIO data port. More...
 
void GPIO_ToggleBits (GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
 Toggles the specified GPIO pins.. More...
 
void GPIO_PinAFConfig (GPIO_TypeDef *GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
 Changes the mapping of the specified pin. More...
 

Detailed Description

GPIO driver modules.

Macro Definition Documentation

#define IS_GPIO_ALL_PERIPH (   PERIPH)
Value:
(((PERIPH) == GPIOA) || \
((PERIPH) == GPIOB) || \
((PERIPH) == GPIOC) || \
((PERIPH) == GPIOD) || \
((PERIPH) == GPIOE) || \
((PERIPH) == GPIOF) || \
((PERIPH) == GPIOG) || \
((PERIPH) == GPIOH) || \
((PERIPH) == GPIOI))
#define IS_GPIO_MODE (   MODE)
Value:
(((MODE) == GPIO_Mode_IN) || ((MODE) == GPIO_Mode_OUT) || \
((MODE) == GPIO_Mode_AF)|| ((MODE) == GPIO_Mode_AN))
#define IS_GPIO_PUPD (   PUPD)
Value:
(((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \
((PUPD) == GPIO_PuPd_DOWN))
#define IS_GPIO_SPEED (   SPEED)
Value:
(((SPEED) == GPIO_Speed_2MHz) || ((SPEED) == GPIO_Speed_25MHz) || \
((SPEED) == GPIO_Speed_50MHz)|| ((SPEED) == GPIO_Speed_100MHz))

Enumeration Type Documentation

GPIO Configuration Mode enumeration.

Enumerator
GPIO_Mode_IN 

GPIO Input Mode

GPIO_Mode_OUT 

GPIO Output Mode

GPIO_Mode_AF 

GPIO Alternate function Mode

GPIO_Mode_AN 

GPIO Analog Mode

GPIO Output Maximum frequency enumeration.

Enumerator
GPIO_Speed_2MHz 

Low speed

GPIO_Speed_25MHz 

Medium speed

GPIO_Speed_50MHz 

Fast speed

GPIO_Speed_100MHz 

High speed on 30 pF (80 MHz Output max speed on 15 pF)

Function Documentation

void GPIO_DeInit ( GPIO_TypeDef *  GPIOx)

Deinitializes the GPIOx peripheral registers to their default reset values.

Note
By default, The GPIO pins are configured in input floating mode (except JTAG pins).
Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
Return values
None
void GPIO_Init ( GPIO_TypeDef *  GPIOx,
GPIO_InitTypeDef GPIO_InitStruct 
)

Initializes the GPIOx peripheral according to the specified parameters in the GPIO_InitStruct.

Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
GPIO_InitStruct,:pointer to a GPIO_InitTypeDef structure that contains the configuration information for the specified GPIO peripheral.
Return values
None
void GPIO_PinAFConfig ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_PinSource,
uint8_t  GPIO_AF 
)

Changes the mapping of the specified pin.

Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
GPIO_PinSource,:specifies the pin for the Alternate function. This parameter can be GPIO_PinSourcex where x can be (0..15).
GPIO_AFSelection,:selects the pin to used as Alternate function. This parameter can be one of the following values:
  • GPIO_AF_RTC_50Hz: Connect RTC_50Hz pin to AF0 (default after reset)
  • GPIO_AF_MCO: Connect MCO pin (MCO1 and MCO2) to AF0 (default after reset)
  • GPIO_AF_TAMPER: Connect TAMPER pins (TAMPER_1 and TAMPER_2) to AF0 (default after reset)
  • GPIO_AF_SWJ: Connect SWJ pins (SWD and JTAG)to AF0 (default after reset)
  • GPIO_AF_TRACE: Connect TRACE pins to AF0 (default after reset)
  • GPIO_AF_TIM1: Connect TIM1 pins to AF1
  • GPIO_AF_TIM2: Connect TIM2 pins to AF1
  • GPIO_AF_TIM3: Connect TIM3 pins to AF2
  • GPIO_AF_TIM4: Connect TIM4 pins to AF2
  • GPIO_AF_TIM5: Connect TIM5 pins to AF2
  • GPIO_AF_TIM8: Connect TIM8 pins to AF3
  • GPIO_AF_TIM9: Connect TIM9 pins to AF3
  • GPIO_AF_TIM10: Connect TIM10 pins to AF3
  • GPIO_AF_TIM11: Connect TIM11 pins to AF3
  • GPIO_AF_I2C1: Connect I2C1 pins to AF4
  • GPIO_AF_I2C2: Connect I2C2 pins to AF4
  • GPIO_AF_I2C3: Connect I2C3 pins to AF4
  • GPIO_AF_SPI1: Connect SPI1 pins to AF5
  • GPIO_AF_SPI2: Connect SPI2/I2S2 pins to AF5
  • GPIO_AF_SPI3: Connect SPI3/I2S3 pins to AF6
  • GPIO_AF_USART1: Connect USART1 pins to AF7
  • GPIO_AF_USART2: Connect USART2 pins to AF7
  • GPIO_AF_USART3: Connect USART3 pins to AF7
  • GPIO_AF_UART4: Connect UART4 pins to AF8
  • GPIO_AF_UART5: Connect UART5 pins to AF8
  • GPIO_AF_USART6: Connect USART6 pins to AF8
  • GPIO_AF_CAN1: Connect CAN1 pins to AF9
  • GPIO_AF_CAN2: Connect CAN2 pins to AF9
  • GPIO_AF_TIM12: Connect TIM12 pins to AF9
  • GPIO_AF_TIM13: Connect TIM13 pins to AF9
  • GPIO_AF_TIM14: Connect TIM14 pins to AF9
  • GPIO_AF_OTG_FS: Connect OTG_FS pins to AF10
  • GPIO_AF_OTG_HS: Connect OTG_HS pins to AF10
  • GPIO_AF_ETH: Connect ETHERNET pins to AF11
  • GPIO_AF_FSMC: Connect FSMC pins to AF12
  • GPIO_AF_OTG_HS_FS: Connect OTG HS (configured in FS) pins to AF12
  • GPIO_AF_SDIO: Connect SDIO pins to AF12
  • GPIO_AF_DCMI: Connect DCMI pins to AF13
  • GPIO_AF_EVENTOUT: Connect EVENTOUT pins to AF15
Return values
None
void GPIO_PinLockConfig ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Locks GPIO Pins configuration registers.

Note
The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR, GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
The configuration of the locked GPIO pins can no longer be modified until the next reset.
Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bit to be locked. This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
Return values
None
uint16_t GPIO_ReadInputData ( GPIO_TypeDef *  GPIOx)

Reads the specified GPIO input data port.

Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
Return values
GPIOinput data port value.
uint8_t GPIO_ReadInputDataBit ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Reads the specified input port pin.

Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bit to read. This parameter can be GPIO_Pin_x where x can be (0..15).
Return values
Theinput port pin value.
uint16_t GPIO_ReadOutputData ( GPIO_TypeDef *  GPIOx)

Reads the specified GPIO output data port.

Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
Return values
GPIOoutput data port value.
uint8_t GPIO_ReadOutputDataBit ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Reads the specified output data port bit.

Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bit to read. This parameter can be GPIO_Pin_x where x can be (0..15).
Return values
Theoutput port pin value.
void GPIO_ResetBits ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Clears the selected data port bits.

Note
This functions uses GPIOx_BSRR register to allow atomic read/modify accesses. In this way, there is no risk of an IRQ occurring between the read and the modify access.
Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bits to be written. This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
Return values
None
void GPIO_SetBits ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Sets the selected data port bits.

Note
This functions uses GPIOx_BSRR register to allow atomic read/modify accesses. In this way, there is no risk of an IRQ occurring between the read and the modify access.
Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bits to be written. This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
Return values
None
void GPIO_StructInit ( GPIO_InitTypeDef GPIO_InitStruct)

Fills each GPIO_InitStruct member with its default value.

Parameters
GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure which will be initialized.
Return values
None
void GPIO_ToggleBits ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Toggles the specified GPIO pins..

Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
GPIO_Pin,:Specifies the pins to be toggled.
Return values
None
void GPIO_Write ( GPIO_TypeDef *  GPIOx,
uint16_t  PortVal 
)

Writes data to the specified GPIO data port.

Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
PortVal,:specifies the value to be written to the port output data register.
Return values
None
void GPIO_WriteBit ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin,
BitAction  BitVal 
)

Sets or clears the selected data port bit.

Parameters
GPIOx,:where x can be (A..I) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bit to be written. This parameter can be one of GPIO_Pin_x where x can be (0..15).
BitVal,:specifies the value to be written to the selected bit. This parameter can be one of the BitAction enum values:
  • Bit_RESET: to clear the port pin
  • Bit_SET: to set the port pin
Return values
None