2 ******************************************************************************
\r
3 * @file stm32f4xx_gpio.c
\r
4 * @author MCD Application Team
\r
6 * @date 30-September-2011
\r
7 * @brief This file provides firmware functions to manage the following
\r
8 * functionalities of the GPIO peripheral:
\r
9 * - Initialization and Configuration
\r
10 * - GPIO Read and Write
\r
11 * - GPIO Alternate functions configuration
\r
15 * ===================================================================
\r
16 * How to use this driver
\r
17 * ===================================================================
\r
18 * 1. Enable the GPIO AHB clock using the following function
\r
19 * RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE);
\r
21 * 2. Configure the GPIO pin(s) using GPIO_Init()
\r
22 * Four possible configuration are available for each pin:
\r
23 * - Input: Floating, Pull-up, Pull-down.
\r
24 * - Output: Push-Pull (Pull-up, Pull-down or no Pull)
\r
25 * Open Drain (Pull-up, Pull-down or no Pull).
\r
26 * In output mode, the speed is configurable: 2 MHz, 25 MHz,
\r
27 * 50 MHz or 100 MHz.
\r
28 * - Alternate Function: Push-Pull (Pull-up, Pull-down or no Pull)
\r
29 * Open Drain (Pull-up, Pull-down or no Pull).
\r
30 * - Analog: required mode when a pin is to be used as ADC channel
\r
33 * 3- Peripherals alternate function:
\r
34 * - For ADC and DAC, configure the desired pin in analog mode using
\r
35 * GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AN;
\r
36 * - For other peripherals (TIM, USART...):
\r
37 * - Connect the pin to the desired peripherals' Alternate
\r
38 * Function (AF) using GPIO_PinAFConfig() function
\r
39 * - Configure the desired pin in alternate function mode using
\r
40 * GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
\r
41 * - Select the type, pull-up/pull-down and output speed via
\r
42 * GPIO_PuPd, GPIO_OType and GPIO_Speed members
\r
43 * - Call GPIO_Init() function
\r
45 * 4. To get the level of a pin configured in input mode use GPIO_ReadInputDataBit()
\r
47 * 5. To set/reset the level of a pin configured in output mode use
\r
48 * GPIO_SetBits()/GPIO_ResetBits()
\r
50 * 6. During and just after reset, the alternate functions are not
\r
51 * active and the GPIO pins are configured in input floating mode
\r
52 * (except JTAG pins).
\r
54 * 7. The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as
\r
55 * general-purpose (PC14 and PC15, respectively) when the LSE
\r
56 * oscillator is off. The LSE has priority over the GPIO function.
\r
58 * 8. The HSE oscillator pins OSC_IN/OSC_OUT can be used as
\r
59 * general-purpose PH0 and PH1, respectively, when the HSE
\r
60 * oscillator is off. The HSE has priority over the GPIO function.
\r
64 ******************************************************************************
\r
67 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
\r
68 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
\r
69 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
\r
70 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
\r
71 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
\r
72 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
\r
74 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
\r
75 ******************************************************************************
\r
78 /* Includes ------------------------------------------------------------------*/
\r
79 #include "stm32f4xx_gpio.h"
\r
80 #include "stm32f4xx_rcc.h"
\r
82 /** @addtogroup STM32F4xx_StdPeriph_Driver
\r
87 * @brief GPIO driver modules
\r
91 /* Private typedef -----------------------------------------------------------*/
\r
92 /* Private define ------------------------------------------------------------*/
\r
93 /* Private macro -------------------------------------------------------------*/
\r
94 /* Private variables ---------------------------------------------------------*/
\r
95 /* Private function prototypes -----------------------------------------------*/
\r
96 /* Private functions ---------------------------------------------------------*/
\r
98 /** @defgroup GPIO_Private_Functions
\r
102 /** @defgroup GPIO_Group1 Initialization and Configuration
\r
103 * @brief Initialization and Configuration
\r
106 ===============================================================================
\r
107 Initialization and Configuration
\r
108 ===============================================================================
\r
115 * @brief Deinitializes the GPIOx peripheral registers to their default reset values.
\r
116 * @note By default, The GPIO pins are configured in input floating mode (except JTAG pins).
\r
117 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
120 void GPIO_DeInit(GPIO_TypeDef* GPIOx)
\r
122 /* Check the parameters */
\r
123 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
125 if (GPIOx == GPIOA)
\r
127 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOA, ENABLE);
\r
128 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOA, DISABLE);
\r
130 else if (GPIOx == GPIOB)
\r
132 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOB, ENABLE);
\r
133 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOB, DISABLE);
\r
135 else if (GPIOx == GPIOC)
\r
137 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOC, ENABLE);
\r
138 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOC, DISABLE);
\r
140 else if (GPIOx == GPIOD)
\r
142 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOD, ENABLE);
\r
143 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOD, DISABLE);
\r
145 else if (GPIOx == GPIOE)
\r
147 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOE, ENABLE);
\r
148 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOE, DISABLE);
\r
150 else if (GPIOx == GPIOF)
\r
152 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOF, ENABLE);
\r
153 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOF, DISABLE);
\r
155 else if (GPIOx == GPIOG)
\r
157 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOG, ENABLE);
\r
158 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOG, DISABLE);
\r
160 else if (GPIOx == GPIOH)
\r
162 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOH, ENABLE);
\r
163 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOH, DISABLE);
\r
167 if (GPIOx == GPIOI)
\r
169 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOI, ENABLE);
\r
170 RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOI, DISABLE);
\r
176 * @brief Initializes the GPIOx peripheral according to the specified parameters in the GPIO_InitStruct.
\r
177 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
178 * @param GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure that contains
\r
179 * the configuration information for the specified GPIO peripheral.
\r
182 void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
\r
184 uint32_t pinpos = 0x00, pos = 0x00 , currentpin = 0x00;
\r
186 /* Check the parameters */
\r
187 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
188 assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));
\r
189 assert_param(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode));
\r
190 assert_param(IS_GPIO_PUPD(GPIO_InitStruct->GPIO_PuPd));
\r
192 /* -------------------------Configure the port pins---------------- */
\r
193 /*-- GPIO Mode Configuration --*/
\r
194 for (pinpos = 0x00; pinpos < 0x10; pinpos++)
\r
196 pos = ((uint32_t)0x01) << pinpos;
\r
197 /* Get the port pins position */
\r
198 currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;
\r
200 if (currentpin == pos)
\r
202 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (pinpos * 2));
\r
203 GPIOx->MODER |= (((uint32_t)GPIO_InitStruct->GPIO_Mode) << (pinpos * 2));
\r
205 if ((GPIO_InitStruct->GPIO_Mode == GPIO_Mode_OUT) || (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_AF))
\r
207 /* Check Speed mode parameters */
\r
208 assert_param(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed));
\r
210 /* Speed mode configuration */
\r
211 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (pinpos * 2));
\r
212 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_InitStruct->GPIO_Speed) << (pinpos * 2));
\r
214 /* Check Output mode parameters */
\r
215 assert_param(IS_GPIO_OTYPE(GPIO_InitStruct->GPIO_OType));
\r
217 /* Output mode configuration*/
\r
218 GPIOx->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)pinpos)) ;
\r
219 GPIOx->OTYPER |= (uint16_t)(((uint16_t)GPIO_InitStruct->GPIO_OType) << ((uint16_t)pinpos));
\r
222 /* Pull-up Pull down resistor configuration*/
\r
223 GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)pinpos * 2));
\r
224 GPIOx->PUPDR |= (((uint32_t)GPIO_InitStruct->GPIO_PuPd) << (pinpos * 2));
\r
230 * @brief Fills each GPIO_InitStruct member with its default value.
\r
231 * @param GPIO_InitStruct : pointer to a GPIO_InitTypeDef structure which will be initialized.
\r
234 void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)
\r
236 /* Reset GPIO init structure parameters values */
\r
237 GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All;
\r
238 GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN;
\r
239 GPIO_InitStruct->GPIO_Speed = GPIO_Speed_2MHz;
\r
240 GPIO_InitStruct->GPIO_OType = GPIO_OType_PP;
\r
241 GPIO_InitStruct->GPIO_PuPd = GPIO_PuPd_NOPULL;
\r
245 * @brief Locks GPIO Pins configuration registers.
\r
246 * @note The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR,
\r
247 * GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
\r
248 * @note The configuration of the locked GPIO pins can no longer be modified
\r
249 * until the next reset.
\r
250 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
251 * @param GPIO_Pin: specifies the port bit to be locked.
\r
252 * This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
\r
255 void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
\r
257 __IO uint32_t tmp = 0x00010000;
\r
259 /* Check the parameters */
\r
260 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
261 assert_param(IS_GPIO_PIN(GPIO_Pin));
\r
266 /* Reset LCKK bit */
\r
267 GPIOx->LCKR = GPIO_Pin;
\r
280 /** @defgroup GPIO_Group2 GPIO Read and Write
\r
281 * @brief GPIO Read and Write
\r
284 ===============================================================================
\r
285 GPIO Read and Write
\r
286 ===============================================================================
\r
293 * @brief Reads the specified input port pin.
\r
294 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
295 * @param GPIO_Pin: specifies the port bit to read.
\r
296 * This parameter can be GPIO_Pin_x where x can be (0..15).
\r
297 * @retval The input port pin value.
\r
299 uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
\r
301 uint8_t bitstatus = 0x00;
\r
303 /* Check the parameters */
\r
304 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
305 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
\r
307 if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)Bit_RESET)
\r
309 bitstatus = (uint8_t)Bit_SET;
\r
313 bitstatus = (uint8_t)Bit_RESET;
\r
319 * @brief Reads the specified GPIO input data port.
\r
320 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
321 * @retval GPIO input data port value.
\r
323 uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx)
\r
325 /* Check the parameters */
\r
326 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
328 return ((uint16_t)GPIOx->IDR);
\r
332 * @brief Reads the specified output data port bit.
\r
333 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
334 * @param GPIO_Pin: specifies the port bit to read.
\r
335 * This parameter can be GPIO_Pin_x where x can be (0..15).
\r
336 * @retval The output port pin value.
\r
338 uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
\r
340 uint8_t bitstatus = 0x00;
\r
342 /* Check the parameters */
\r
343 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
344 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
\r
346 if ((GPIOx->ODR & GPIO_Pin) != (uint32_t)Bit_RESET)
\r
348 bitstatus = (uint8_t)Bit_SET;
\r
352 bitstatus = (uint8_t)Bit_RESET;
\r
358 * @brief Reads the specified GPIO output data port.
\r
359 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
360 * @retval GPIO output data port value.
\r
362 uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)
\r
364 /* Check the parameters */
\r
365 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
367 return ((uint16_t)GPIOx->ODR);
\r
371 * @brief Sets the selected data port bits.
\r
372 * @note This functions uses GPIOx_BSRR register to allow atomic read/modify
\r
373 * accesses. In this way, there is no risk of an IRQ occurring between
\r
374 * the read and the modify access.
\r
375 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
376 * @param GPIO_Pin: specifies the port bits to be written.
\r
377 * This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
\r
380 void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
\r
382 /* Check the parameters */
\r
383 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
384 assert_param(IS_GPIO_PIN(GPIO_Pin));
\r
386 GPIOx->BSRRL = GPIO_Pin;
\r
390 * @brief Clears the selected data port bits.
\r
391 * @note This functions uses GPIOx_BSRR register to allow atomic read/modify
\r
392 * accesses. In this way, there is no risk of an IRQ occurring between
\r
393 * the read and the modify access.
\r
394 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
395 * @param GPIO_Pin: specifies the port bits to be written.
\r
396 * This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
\r
399 void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
\r
401 /* Check the parameters */
\r
402 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
403 assert_param(IS_GPIO_PIN(GPIO_Pin));
\r
405 GPIOx->BSRRH = GPIO_Pin;
\r
409 * @brief Sets or clears the selected data port bit.
\r
410 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
411 * @param GPIO_Pin: specifies the port bit to be written.
\r
412 * This parameter can be one of GPIO_Pin_x where x can be (0..15).
\r
413 * @param BitVal: specifies the value to be written to the selected bit.
\r
414 * This parameter can be one of the BitAction enum values:
\r
415 * @arg Bit_RESET: to clear the port pin
\r
416 * @arg Bit_SET: to set the port pin
\r
419 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
\r
421 /* Check the parameters */
\r
422 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
423 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
\r
424 assert_param(IS_GPIO_BIT_ACTION(BitVal));
\r
426 if (BitVal != Bit_RESET)
\r
428 GPIOx->BSRRL = GPIO_Pin;
\r
432 GPIOx->BSRRH = GPIO_Pin ;
\r
437 * @brief Writes data to the specified GPIO data port.
\r
438 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
439 * @param PortVal: specifies the value to be written to the port output data register.
\r
442 void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal)
\r
444 /* Check the parameters */
\r
445 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
447 GPIOx->ODR = PortVal;
\r
451 * @brief Toggles the specified GPIO pins..
\r
452 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
453 * @param GPIO_Pin: Specifies the pins to be toggled.
\r
456 void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
\r
458 /* Check the parameters */
\r
459 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
461 GPIOx->ODR ^= GPIO_Pin;
\r
468 /** @defgroup GPIO_Group3 GPIO Alternate functions configuration function
\r
469 * @brief GPIO Alternate functions configuration function
\r
472 ===============================================================================
\r
473 GPIO Alternate functions configuration function
\r
474 ===============================================================================
\r
481 * @brief Changes the mapping of the specified pin.
\r
482 * @param GPIOx: where x can be (A..I) to select the GPIO peripheral.
\r
483 * @param GPIO_PinSource: specifies the pin for the Alternate function.
\r
484 * This parameter can be GPIO_PinSourcex where x can be (0..15).
\r
485 * @param GPIO_AFSelection: selects the pin to used as Alternate function.
\r
486 * This parameter can be one of the following values:
\r
487 * @arg GPIO_AF_RTC_50Hz: Connect RTC_50Hz pin to AF0 (default after reset)
\r
488 * @arg GPIO_AF_MCO: Connect MCO pin (MCO1 and MCO2) to AF0 (default after reset)
\r
489 * @arg GPIO_AF_TAMPER: Connect TAMPER pins (TAMPER_1 and TAMPER_2) to AF0 (default after reset)
\r
490 * @arg GPIO_AF_SWJ: Connect SWJ pins (SWD and JTAG)to AF0 (default after reset)
\r
491 * @arg GPIO_AF_TRACE: Connect TRACE pins to AF0 (default after reset)
\r
492 * @arg GPIO_AF_TIM1: Connect TIM1 pins to AF1
\r
493 * @arg GPIO_AF_TIM2: Connect TIM2 pins to AF1
\r
494 * @arg GPIO_AF_TIM3: Connect TIM3 pins to AF2
\r
495 * @arg GPIO_AF_TIM4: Connect TIM4 pins to AF2
\r
496 * @arg GPIO_AF_TIM5: Connect TIM5 pins to AF2
\r
497 * @arg GPIO_AF_TIM8: Connect TIM8 pins to AF3
\r
498 * @arg GPIO_AF_TIM9: Connect TIM9 pins to AF3
\r
499 * @arg GPIO_AF_TIM10: Connect TIM10 pins to AF3
\r
500 * @arg GPIO_AF_TIM11: Connect TIM11 pins to AF3
\r
501 * @arg GPIO_AF_I2C1: Connect I2C1 pins to AF4
\r
502 * @arg GPIO_AF_I2C2: Connect I2C2 pins to AF4
\r
503 * @arg GPIO_AF_I2C3: Connect I2C3 pins to AF4
\r
504 * @arg GPIO_AF_SPI1: Connect SPI1 pins to AF5
\r
505 * @arg GPIO_AF_SPI2: Connect SPI2/I2S2 pins to AF5
\r
506 * @arg GPIO_AF_SPI3: Connect SPI3/I2S3 pins to AF6
\r
507 * @arg GPIO_AF_I2S3ext: Connect I2S3ext pins to AF7
\r
508 * @arg GPIO_AF_USART1: Connect USART1 pins to AF7
\r
509 * @arg GPIO_AF_USART2: Connect USART2 pins to AF7
\r
510 * @arg GPIO_AF_USART3: Connect USART3 pins to AF7
\r
511 * @arg GPIO_AF_UART4: Connect UART4 pins to AF8
\r
512 * @arg GPIO_AF_UART5: Connect UART5 pins to AF8
\r
513 * @arg GPIO_AF_USART6: Connect USART6 pins to AF8
\r
514 * @arg GPIO_AF_CAN1: Connect CAN1 pins to AF9
\r
515 * @arg GPIO_AF_CAN2: Connect CAN2 pins to AF9
\r
516 * @arg GPIO_AF_TIM12: Connect TIM12 pins to AF9
\r
517 * @arg GPIO_AF_TIM13: Connect TIM13 pins to AF9
\r
518 * @arg GPIO_AF_TIM14: Connect TIM14 pins to AF9
\r
519 * @arg GPIO_AF_OTG_FS: Connect OTG_FS pins to AF10
\r
520 * @arg GPIO_AF_OTG_HS: Connect OTG_HS pins to AF10
\r
521 * @arg GPIO_AF_ETH: Connect ETHERNET pins to AF11
\r
522 * @arg GPIO_AF_FSMC: Connect FSMC pins to AF12
\r
523 * @arg GPIO_AF_OTG_HS_FS: Connect OTG HS (configured in FS) pins to AF12
\r
524 * @arg GPIO_AF_SDIO: Connect SDIO pins to AF12
\r
525 * @arg GPIO_AF_DCMI: Connect DCMI pins to AF13
\r
526 * @arg GPIO_AF_EVENTOUT: Connect EVENTOUT pins to AF15
\r
529 void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
\r
531 uint32_t temp = 0x00;
\r
532 uint32_t temp_2 = 0x00;
\r
534 /* Check the parameters */
\r
535 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
\r
536 assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
\r
537 assert_param(IS_GPIO_AF(GPIO_AF));
\r
539 temp = ((uint32_t)(GPIO_AF) << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4)) ;
\r
540 GPIOx->AFR[GPIO_PinSource >> 0x03] &= ~((uint32_t)0xF << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4)) ;
\r
541 temp_2 = GPIOx->AFR[GPIO_PinSource >> 0x03] | temp;
\r
542 GPIOx->AFR[GPIO_PinSource >> 0x03] = temp_2;
\r
561 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
\r