STM32F4 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F4 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f4xx_gpio.c File Reference

This file provides firmware functions to manage the following functionalities of the GPIO peripheral: More...

#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"

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

This file provides firmware functions to manage the following functionalities of the GPIO peripheral:

Author
MCD Application Team
Version
V1.0.2
Date
05-March-2012
  • Initialization and Configuration
  • GPIO Read and Write
  • GPIO Alternate functions configuration
*
*          ===================================================================
*                                 How to use this driver
*          ===================================================================       
*           1. Enable the GPIO AHB clock using the following function
*                RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE);
*             
*           2. Configure the GPIO pin(s) using GPIO_Init()
*              Four possible configuration are available for each pin:
*                - Input: Floating, Pull-up, Pull-down.
*                - Output: Push-Pull (Pull-up, Pull-down or no Pull)
*                          Open Drain (Pull-up, Pull-down or no Pull).
*                  In output mode, the speed is configurable: 2 MHz, 25 MHz,
*                  50 MHz or 100 MHz.
*                - Alternate Function: Push-Pull (Pull-up, Pull-down or no Pull)
*                                      Open Drain (Pull-up, Pull-down or no Pull).
*                - Analog: required mode when a pin is to be used as ADC channel
*                          or DAC output.
* 
*          3- Peripherals alternate function:
*              - For ADC and DAC, configure the desired pin in analog mode using 
*                  GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AN;
*              - For other peripherals (TIM, USART...):
*                 - Connect the pin to the desired peripherals' Alternate 
*                   Function (AF) using GPIO_PinAFConfig() function
*                 - Configure the desired pin in alternate function mode using
*                   GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
*                 - Select the type, pull-up/pull-down and output speed via 
*                   GPIO_PuPd, GPIO_OType and GPIO_Speed members
*                 - Call GPIO_Init() function
*        
*          4. To get the level of a pin configured in input mode use GPIO_ReadInputDataBit()
*          
*          5. To set/reset the level of a pin configured in output mode use
*             GPIO_SetBits()/GPIO_ResetBits()
*               
*          6. During and just after reset, the alternate functions are not 
*             active and the GPIO pins are configured in input floating mode
*             (except JTAG pins).
*
*          7. The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as 
*             general-purpose (PC14 and PC15, respectively) when the LSE
*             oscillator is off. The LSE has priority over the GPIO function.
*
*          8. The HSE oscillator pins OSC_IN/OSC_OUT can be used as 
*             general-purpose PH0 and PH1, respectively, when the HSE 
*             oscillator is off. The HSE has priority over the GPIO function.
*             
*  
Attention

© COPYRIGHT 2012 STMicroelectronics

Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:

   http://www.st.com/software_license_agreement_liberty_v2

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.