STM32F0 Standard Peripheral bibliotheek  1.0
ST Microelectronics standard peripheral bibliotheek documentatie voor de STM32F0 familie
 All Data Structures Files Functions Variables Enumerations Enumerator Groups

GPIO driver modules. More...

Modules

 Configuration_Mode_enumeration
 
 Output_type_enumeration
 
 Output_Maximum_frequency_enumeration
 
 Configuration_Pull-Up_Pull-Down_enumeration
 
 Bit_SET_and_Bit_RESET_enumeration
 
 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_LIST_PERIPH(PERIPH)
 

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 input port pin. 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_PinAFConfig (GPIO_TypeDef *GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
 Writes data to the specified GPIO data port. 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) == GPIOF))
#define IS_GPIO_LIST_PERIPH (   PERIPH)
Value:
(((PERIPH) == GPIOA) || \
((PERIPH) == GPIOB))

Function Documentation

void GPIO_DeInit ( GPIO_TypeDef *  GPIOx)

Deinitializes the GPIOx peripheral registers to their default reset values.

Parameters
GPIOx,:where x can be (A, B, C, D or F) 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, B, C, D or F) to select the GPIO peripheral.
GPIO_InitStruct,:pointer to a GPIO_InitTypeDef structure that contains the configuration information for the specified GPIO peripheral.
Note
The configured pins can be: GPIO_Pin_0 to GPIO_Pin_15 for GPIOA, GPIOB and GPIOC, GPIO_Pin_0 to GPIO_Pin_2 for GPIOD, GPIO_Pin_0 to GPIO_Pin_3 for GPIOF.
Return values
None
void GPIO_PinAFConfig ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_PinSource,
uint8_t  GPIO_AF 
)

Writes data to the specified GPIO data port.

Parameters
GPIOx,:where x can be (A or B) 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_AF,:selects the pin to used as Alternate function. This parameter can be one of the following value:
  • GPIO_AF_0: WKUP, EVENTOUT, TIM15, SPI1, TIM17,MCO, SWDAT, SWCLK, TIM14, BOOT,USART1, CEC, IR_OUT, SPI2
  • GPIO_AF_1: USART2, CEC, Tim3, USART1, USART2,EVENTOUT, I2C1, I2C2, TIM15
  • GPIO_AF_2: TIM2, TIM1, EVENTOUT, TIM16, TIM17
  • GPIO_AF_3: TS, I2C1, TIM15, EVENTOUT
  • GPIO_AF_4: TIM14
  • GPIO_AF_5: TIM16, TIM17
  • GPIO_AF_6: EVENTOUT
  • GPIO_AF_7: COMP1 OUT, COMP2 OUT
Note
The pin should already been configured in Alternate Function mode(AF) using GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
Refer to the Alternate function mapping table in the device datasheet for the detailed mapping of the system and peripherals'alternate function I/O pins.
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 device reset.
Parameters
GPIOx,:where x can be (A or B) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bit to be written. 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 input port pin.

Parameters
GPIOx,:where x can be (A, B, C, D or F) to select the GPIO peripheral.
Return values
Theinput port pin 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, B, C, D or F) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bit to read.
Note
This parameter can be GPIO_Pin_x where x can be:(0..15) for GPIOA, GPIOB or GPIOC,(0..2) for GPIOD and(0..3) for GPIOF.
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, B, C, D or F) 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, B, C, D or F) to select the GPIO peripheral.
GPIO_Pin,:Specifies the port bit to read.
Note
This parameter can be GPIO_Pin_x where x can be:(0..15) for GPIOA, GPIOB or GPIOC,(0..2) for GPIOD and(0..3) for GPIOF.
Return values
Theoutput port pin value.
void GPIO_ResetBits ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Clears the selected data port bits.

Parameters
GPIOx,:where x can be (A, B, C, D or F) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bits to be written.
Note
This parameter can be GPIO_Pin_x where x can be: (0..15) for GPIOA, GPIOB or GPIOC,(0..2) for GPIOD and(0..3) for GPIOF.
Return values
None
void GPIO_SetBits ( GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Sets the selected data port bits.

Parameters
GPIOx,:where x can be (A, B, C, D or F) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bits to be written.
Note
This parameter can be GPIO_Pin_x where x can be:(0..15) for GPIOA, GPIOB or GPIOC,(0..2) for GPIOD and(0..3) for GPIOF.
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_Write ( GPIO_TypeDef *  GPIOx,
uint16_t  PortVal 
)

Writes data to the specified GPIO data port.

Parameters
GPIOx,:where x can be (A, B, C, D or F) 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, B, C, D or F) to select the GPIO peripheral.
GPIO_Pin,:specifies the port bit to be written.
BitVal,:specifies the value to be written to the selected bit. This parameter can be one of the BitAction enumeration values:
  • Bit_RESET: to clear the port pin
  • Bit_SET: to set the port pin
Note
The GPIO_Pin parameter can be GPIO_Pin_x where x can be: (0..15) for GPIOA, GPIOB or GPIOC,(0..2) for GPIOD and(0..3) for GPIOF.
Return values
None