]> git.sur5r.net Git - freertos/blob - Demo/Common/drivers/ST/STM32F10xFWLib/src/stm32f10x_gpio.c
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / Common / drivers / ST / STM32F10xFWLib / src / stm32f10x_gpio.c
1 /******************** (C) COPYRIGHT 2007 STMicroelectronics ********************\r
2 * File Name          : stm32f10x_gpio.c\r
3 * Author             : MCD Application Team\r
4 * Date First Issued  : 09/29/2006\r
5 * Description        : This file provides all the GPIO firmware functions.\r
6 ********************************************************************************\r
7 * History:\r
8 * 04/02/2007: V0.2\r
9 * 02/05/2007: V0.1\r
10 * 09/29/2006: V0.01\r
11 ********************************************************************************\r
12 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.\r
14 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,\r
15 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE\r
16 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING\r
17 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
18 *******************************************************************************/\r
19 \r
20 /* Includes ------------------------------------------------------------------*/\r
21 #include "stm32f10x_gpio.h"\r
22 #include "stm32f10x_rcc.h"\r
23 \r
24 /* Private typedef -----------------------------------------------------------*/\r
25 /* Private define ------------------------------------------------------------*/\r
26 /* ------------ RCC registers bit address in the alias region ----------- */\r
27 #define AFIO_OFFSET                 (AFIO_BASE - PERIPH_BASE)\r
28 \r
29 /* --- EVENTCR Register ---*/\r
30 /* Alias word address of EVOE bit */\r
31 #define EVCR_OFFSET                 (AFIO_OFFSET + 0x00)\r
32 #define EVOE_BitNumber              ((u8)0x07)\r
33 #define EVCR_EVOE_BB                (PERIPH_BB_BASE + (EVCR_OFFSET * 32) + (EVOE_BitNumber * 4))\r
34 \r
35 #define EVCR_PORTPINCONFIG_MASK     ((u16)0xFF80)\r
36 #define LSB_MASK                    ((u16)0xFFFF)\r
37 #define DBGAFR_POSITION_MASK        ((u32)0x000F0000)\r
38 #define DBGAFR_SWJCFG_MASK          ((u32)0xF8FFFFFF)\r
39 #define DBGAFR_LOCATION_MASK        ((u32)0x00200000)\r
40 #define DBGAFR_NUMBITS_MASK         ((u32)0x00100000)\r
41 \r
42 /* Private macro -------------------------------------------------------------*/\r
43 /* Private variables ---------------------------------------------------------*/\r
44 /* Private function prototypes -----------------------------------------------*/\r
45 /* Private functions ---------------------------------------------------------*/\r
46 \r
47 /*******************************************************************************\r
48 * Function Name  : GPIO_DeInit\r
49 * Description    : Deinitializes the GPIOx peripheral registers to their default\r
50 *                  reset values.\r
51 * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.\r
52 * Output         : None\r
53 * Return         : None\r
54 *******************************************************************************/\r
55 void GPIO_DeInit(GPIO_TypeDef* GPIOx)\r
56 {\r
57   switch (*(u32*)&GPIOx)\r
58   {\r
59     case GPIOA_BASE:\r
60       RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOA, ENABLE);\r
61       RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOA, DISABLE);\r
62       break;\r
63 \r
64     case GPIOB_BASE:\r
65       RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOB, ENABLE);\r
66       RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOB, DISABLE);\r
67       break;\r
68 \r
69     case GPIOC_BASE:\r
70       RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, ENABLE);\r
71       RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, DISABLE);\r
72       break;\r
73 \r
74     case GPIOD_BASE:\r
75       RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD, ENABLE);\r
76       RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOD, DISABLE);\r
77       break;\r
78       \r
79     case GPIOE_BASE:\r
80       RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, ENABLE);\r
81       RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, DISABLE);\r
82       break;            \r
83 \r
84     default:\r
85       break;\r
86   }\r
87 }\r
88 \r
89 /*******************************************************************************\r
90 * Function Name  : GPIO_AFIODeInit\r
91 * Description    : Deinitializes the Alternate Functions (remap, event control\r
92 *                  and EXTI configuration) registers to their default reset\r
93 *                  values.\r
94 * Input          : None\r
95 * Output         : None\r
96 * Return         : None\r
97 *******************************************************************************/\r
98 void GPIO_AFIODeInit(void)\r
99 {\r
100   RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO, ENABLE);\r
101   RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO, DISABLE);\r
102 }\r
103 \r
104 /*******************************************************************************\r
105 * Function Name  : GPIO_Init\r
106 * Description    : Initializes the GPIOx peripheral according to the specified\r
107 *                  parameters in the GPIO_InitStruct.\r
108 * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.\r
109 *                  - GPIO_InitStruct: pointer to a GPIO_InitTypeDef structure that\r
110 *                    contains the configuration information for the specified GPIO\r
111 *                    peripheral.\r
112 * Output         : None\r
113 * Return         : None\r
114 *******************************************************************************/\r
115 void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)\r
116 {\r
117   u32 currentmode = 0x00, currentpin = 0x00, pinpos = 0x00, pos = 0x00;\r
118   u32 tmpreg = 0x00, pinmask = 0x00;\r
119 \r
120   /* Check the parameters */\r
121   assert(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode));\r
122   assert(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));  \r
123   \r
124 /*---------------------------- GPIO Mode Configuration -----------------------*/\r
125   currentmode = ((u32)GPIO_InitStruct->GPIO_Mode) & ((u32)0x0F);\r
126 \r
127   if ((((u32)GPIO_InitStruct->GPIO_Mode) & ((u32)0x10)) != 0x00)\r
128   { \r
129     /* Check the parameters */\r
130     assert(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed));\r
131     /* Output mode */\r
132     currentmode |= (u32)GPIO_InitStruct->GPIO_Speed;\r
133   }\r
134 \r
135 /*---------------------------- GPIO CRL Configuration ------------------------*/\r
136   /* Configure the eight low port pins */\r
137   if (((u32)GPIO_InitStruct->GPIO_Pin & ((u32)0x00FF)) != 0x00)\r
138   {\r
139     tmpreg = GPIOx->CRL;\r
140 \r
141     for (pinpos = 0x00; pinpos < 0x08; pinpos++)\r
142     {\r
143       pos = ((u32)0x01) << pinpos;\r
144       /* Get the port pins position */\r
145       currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;\r
146 \r
147       if (currentpin == pos)\r
148       {\r
149         pos = pinpos << 2;\r
150         /* Clear the corresponding low control register bits */\r
151         pinmask = ((u32)0x0F) << pos;\r
152         tmpreg &= ~pinmask;\r
153 \r
154         /* Write the mode configuration in the corresponding bits */\r
155         tmpreg |= (currentmode << pos);\r
156 \r
157         /* Reset the corresponding ODR bit */\r
158         if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD)\r
159         {\r
160           GPIOx->BRR = (((u32)0x01) << pinpos);\r
161         }\r
162         /* Set the corresponding ODR bit */\r
163         if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU)\r
164         {\r
165           GPIOx->BSRR = (((u32)0x01) << pinpos);\r
166         }\r
167       }\r
168     }\r
169     GPIOx->CRL = tmpreg;\r
170     tmpreg = 0;\r
171   }\r
172 \r
173 /*---------------------------- GPIO CRH Configuration ------------------------*/\r
174   /* Configure the eight high port pins */\r
175   if (GPIO_InitStruct->GPIO_Pin > 0x00FF)\r
176   {\r
177     tmpreg = GPIOx->CRH;\r
178     for (pinpos = 0x00; pinpos < 0x08; pinpos++)\r
179     {\r
180       pos = (((u32)0x01) << (pinpos + 0x08));\r
181       /* Get the port pins position */\r
182       currentpin = ((GPIO_InitStruct->GPIO_Pin) & pos);\r
183       if (currentpin == pos)\r
184       {\r
185         pos = pinpos << 2;\r
186         /* Clear the corresponding high control register bits */\r
187         pinmask = ((u32)0x0F) << pos;\r
188         tmpreg &= ~pinmask;\r
189 \r
190         /* Write the mode configuration in the corresponding bits */\r
191         tmpreg |= (currentmode << pos);\r
192 \r
193         /* Reset the corresponding ODR bit */\r
194         if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPD)\r
195         {\r
196           GPIOx->BRR = (((u32)0x01) << (pinpos + 0x08));\r
197         }\r
198         /* Set the corresponding ODR bit */\r
199         if (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_IPU)\r
200         {\r
201           GPIOx->BSRR = (((u32)0x01) << (pinpos + 0x08));\r
202         }\r
203       }\r
204     }\r
205     GPIOx->CRH = tmpreg;\r
206   }\r
207 }\r
208 \r
209 /*******************************************************************************\r
210 * Function Name  : GPIO_StructInit\r
211 * Description    : Fills each GPIO_InitStruct member with its default value.\r
212 * Input          : - GPIO_InitStruct : pointer to a GPIO_InitTypeDef structure\r
213 *                    which will be initialized.\r
214 * Output         : None\r
215 * Return         : None\r
216 *******************************************************************************/\r
217 void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)\r
218 {\r
219   /* Reset GPIO init structure parameters values */\r
220   GPIO_InitStruct->GPIO_Pin  = GPIO_Pin_All;\r
221   GPIO_InitStruct->GPIO_Speed = GPIO_Speed_2MHz;\r
222   GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN_FLOATING;\r
223 }\r
224 \r
225 /*******************************************************************************\r
226 * Function Name  : GPIO_ReadInputDataBit\r
227 * Description    : Reads the specified input port pin.\r
228 * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.\r
229 *                : - GPIO_Pin:  specifies the port bit to read.\r
230 *                    This parameter can be GPIO_Pin_x where x can be (0..15).\r
231 * Output         : None\r
232 * Return         : The input port pin value.\r
233 *******************************************************************************/\r
234 u8 GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)\r
235 {\r
236   u8 bitstatus = 0x00;\r
237   \r
238   /* Check the parameters */\r
239   assert(IS_GPIO_PIN(GPIO_Pin)); \r
240   \r
241   if ((GPIOx->IDR & GPIO_Pin) != (u32)Bit_RESET)\r
242   {\r
243     bitstatus = (u8)Bit_SET;\r
244   }\r
245   else\r
246   {\r
247     bitstatus = (u8)Bit_RESET;\r
248   }\r
249   return bitstatus;\r
250 }\r
251 \r
252 /*******************************************************************************\r
253 * Function Name  : GPIO_ReadInputData\r
254 * Description    : Reads the specified GPIO input data port.\r
255 * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.\r
256 * Output         : None\r
257 * Return         : GPIO input data port value.\r
258 *******************************************************************************/\r
259 u16 GPIO_ReadInputData(GPIO_TypeDef* GPIOx)\r
260 {\r
261   return ((u16)GPIOx->IDR);\r
262 }\r
263 \r
264 /*******************************************************************************\r
265 * Function Name  : GPIO_ReadOutputDataBit\r
266 * Description    : Reads the specified output data port bit.\r
267 * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.\r
268 *                : - GPIO_Pin:  specifies the port bit to read.\r
269 *                    This parameter can be GPIO_Pin_x where x can be (0..15).\r
270 * Output         : None\r
271 * Return         : The output port pin value.\r
272 *******************************************************************************/\r
273 u8 GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)\r
274 {\r
275   u8 bitstatus = 0x00;\r
276 \r
277   /* Check the parameters */\r
278   assert(IS_GPIO_PIN(GPIO_Pin)); \r
279   \r
280   if ((GPIOx->ODR & GPIO_Pin) != (u32)Bit_RESET)\r
281   {\r
282     bitstatus = (u8)Bit_SET;\r
283   }\r
284   else\r
285   {\r
286     bitstatus = (u8)Bit_RESET;\r
287   }\r
288   return bitstatus;\r
289 }\r
290 \r
291 /*******************************************************************************\r
292 * Function Name  : GPIO_ReadOutputData\r
293 * Description    : Reads the specified GPIO output data port.\r
294 * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.\r
295 * Output         : None\r
296 * Return         : GPIO output data port value.\r
297 *******************************************************************************/\r
298 u16 GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)\r
299 {\r
300   return ((u16)GPIOx->ODR);\r
301 }\r
302 \r
303 /*******************************************************************************\r
304 * Function Name  : GPIO_WriteBit\r
305 * Description    : Sets or clears the selected data port bit.\r
306 * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.\r
307 *                  - GPIO_Pin: specifies the port bit to be written.\r
308 *                    This parameter can be GPIO_Pin_x where x can be (0..15).\r
309 *                  - BitVal: specifies the value to be written to the selected bit.\r
310 *                    This parameter can be one of the BitAction enum values:\r
311 *                       - Bit_RESET: to clear the port pin\r
312 *                       - Bit_SET: to set the port pin\r
313 * Output         : None\r
314 * Return         : None\r
315 *******************************************************************************/\r
316 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin, BitAction BitVal)\r
317 {\r
318   /* Check the parameters */\r
319   assert(IS_GPIO_PIN(GPIO_Pin));\r
320   assert(IS_GPIO_BIT_ACTION(BitVal)); \r
321   \r
322   if (BitVal != Bit_RESET)\r
323   {\r
324     GPIOx->BSRR = GPIO_Pin;\r
325   }\r
326   else\r
327   {\r
328     GPIOx->BRR = GPIO_Pin;\r
329   }\r
330 }\r
331 \r
332 /*******************************************************************************\r
333 * Function Name  : GPIO_Write\r
334 * Description    : Writes data to the specified GPIO data port.\r
335 * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.\r
336 *                  - PortVal: specifies the value to be written to the port output\r
337 *                    data register.\r
338 * Output         : None\r
339 * Return         : None\r
340 *******************************************************************************/\r
341 void GPIO_Write(GPIO_TypeDef* GPIOx, u16 PortVal)\r
342 {\r
343   GPIOx->ODR = PortVal;\r
344 }\r
345 \r
346 /*******************************************************************************\r
347 * Function Name  : GPIO_PinLockConfig\r
348 * Description    : Locks GPIO Pins configuration registers.\r
349 * Input          : - GPIOx: where x can be (A..E) to select the GPIO peripheral.\r
350 *                  - GPIO_Pin: specifies the port bit to be written.\r
351 *                    This parameter can be GPIO_Pin_x where x can be (0..15).\r
352 * Output         : None\r
353 * Return         : None\r
354 *******************************************************************************/\r
355 void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)\r
356 {\r
357   u32 tmp = 0x00010000;\r
358   \r
359   /* Check the parameters */\r
360   assert(IS_GPIO_PIN(GPIO_Pin));\r
361   \r
362   tmp |= GPIO_Pin;\r
363   /* Set LCKK bit */\r
364   GPIOx->LCKR = tmp;\r
365   /* Reset LCKK bit */\r
366   GPIOx->LCKR =  GPIO_Pin;\r
367   /* Set LCKK bit */\r
368   GPIOx->LCKR = tmp;\r
369   /* Read LCKK bit*/\r
370   tmp = GPIOx->LCKR;\r
371   /* Read LCKK bit*/\r
372   tmp = GPIOx->LCKR;\r
373 }\r
374 \r
375 /*******************************************************************************\r
376 * Function Name  : GPIO_EventOutputConfig\r
377 * Description    : Selects the GPIO pin used as Event output.\r
378 * Input          : - GPIO_PortSource: selects the GPIO port to be used as source\r
379 *                    for Event output.\r
380 *                    This parameter can be GPIO_PortSourceGPIOx where x can be\r
381 *                    (A..E).\r
382 *                  - GPIO_PinSource: specifies the pin for the Event output.\r
383 *                    This parameter can be GPIO_PinSourcex where x can be (0..15).\r
384 * Output         : None\r
385 * Return         : None\r
386 *******************************************************************************/\r
387 void GPIO_EventOutputConfig(u8 GPIO_PortSource, u8 GPIO_PinSource)\r
388 {\r
389   u32 tmpreg = 0x00;\r
390 \r
391   /* Check the parameters */\r
392   assert(IS_GPIO_PORT_SOURCE(GPIO_PortSource));\r
393   assert(IS_GPIO_PIN_SOURCE(GPIO_PinSource));\r
394     \r
395   tmpreg = AFIO->EVCR;\r
396   /* Clear the PORT[6:4] and PIN[3:0] bits */\r
397   tmpreg &= EVCR_PORTPINCONFIG_MASK;\r
398   tmpreg |= (u32)GPIO_PortSource << 0x04;\r
399   tmpreg |= GPIO_PinSource;\r
400 \r
401   AFIO->EVCR = tmpreg;\r
402 }\r
403 \r
404 /*******************************************************************************\r
405 * Function Name  : GPIO_EventOutputCmd\r
406 * Description    : Enables or disables the Event Output.\r
407 * Input          : - NewState: new state of the Event output.\r
408 *                    This parameter can be: ENABLE or DISABLE.\r
409 * Output         : None\r
410 * Return         : None\r
411 *******************************************************************************/\r
412 void GPIO_EventOutputCmd(FunctionalState NewState)\r
413 {\r
414   /* Check the parameters */\r
415   assert(IS_FUNCTIONAL_STATE(NewState));\r
416   \r
417   *(vu32 *) EVCR_EVOE_BB = (u32)NewState;\r
418 }\r
419 \r
420 /*******************************************************************************\r
421 * Function Name  : GPIO_PinRemapConfig\r
422 * Description    : Changes the mapping of the specified pin.\r
423 * Input          : - GPIO_Remap: selects the pin to remap.\r
424 *                    This parameter can be one of the following values:\r
425 *                       - GPIO_Remap_SPI1\r
426 *                       - GPIO_Remap_I2C1\r
427 *                       - GPIO_Remap_USART1\r
428 *                       - GPIO_Remap_USART2\r
429 *                       - GPIO_PartialRemap_USART3\r
430 *                       - GPIO_FullRemap_USART3\r
431 *                       - GPIO_PartialRemap_TIM1\r
432 *                       - GPIO_FullRemap_TIM1\r
433 *                       - GPIO_PartialRemap1_TIM2\r
434 *                       - GPIO_PartialRemap2_TIM2\r
435 *                       - GPIO_FullRemap_TIM2\r
436 *                       - GPIO_PartialRemap_TIM3\r
437 *                       - GPIO_FullRemap_TIM3\r
438 *                       - GPIO_Remap_TIM4\r
439 *                       - GPIO_Remap1_CAN\r
440 *                       - GPIO_Remap2_CAN\r
441 *                       - GPIO_Remap_PD01\r
442 *                       - GPIO_Remap_SWJ_NoJTRST\r
443 *                       - GPIO_Remap_SWJ_JTAGDisable\r
444 *                       - GPIO_Remap_SWJ_Disable\r
445 *                  - NewState: new state of the port pin remapping.\r
446 *                    This parameter can be: ENABLE or DISABLE.\r
447 * Output         : None\r
448 * Return         : None\r
449 *******************************************************************************/\r
450 void GPIO_PinRemapConfig(u32 GPIO_Remap, FunctionalState NewState)\r
451 {\r
452   u32 tmp = 0x00, tmp1 = 0x00, tmpreg = 0x00, tmpmask = 0x00;\r
453 \r
454   /* Check the parameters */\r
455   assert(IS_GPIO_REMAP(GPIO_Remap));\r
456   assert(IS_FUNCTIONAL_STATE(NewState));  \r
457   \r
458   tmpreg = AFIO->MAPR;\r
459 \r
460   tmpmask = (GPIO_Remap & DBGAFR_POSITION_MASK) >> 0x10;\r
461   tmp = GPIO_Remap & LSB_MASK;\r
462 \r
463   if ((GPIO_Remap & DBGAFR_LOCATION_MASK) == DBGAFR_LOCATION_MASK)\r
464   {\r
465     tmpreg &= DBGAFR_SWJCFG_MASK;\r
466   }\r
467   else if ((GPIO_Remap & DBGAFR_NUMBITS_MASK) == DBGAFR_NUMBITS_MASK)\r
468   {\r
469     tmp1 = ((u32)0x03) << tmpmask;\r
470     tmpreg &= ~tmp1;\r
471   }\r
472   else\r
473   {\r
474     tmpreg &= ~tmp;\r
475   }\r
476 \r
477   if (NewState != DISABLE)\r
478   {\r
479     if ((GPIO_Remap & DBGAFR_LOCATION_MASK) == DBGAFR_LOCATION_MASK)\r
480     {\r
481       tmpreg |= (tmp << 0x10);\r
482     }\r
483     else\r
484     {\r
485       tmpreg |= tmp;\r
486     }\r
487   }\r
488   AFIO->MAPR = tmpreg;\r
489 }\r
490 \r
491 /*******************************************************************************\r
492 * Function Name  : GPIO_EXTILineConfig\r
493 * Description    : Selects the GPIO pin used as EXTI Line.\r
494 * Input          : - GPIO_PortSource: selects the GPIO port to be used as\r
495 *                    source for EXTI lines.\r
496 *                  - GPIO_PinSource: specifies the EXTI line to be configured.\r
497 *                   This parameter can be GPIO_PinSourcex where x can be (0..15).\r
498 * Output         : None\r
499 * Return         : None\r
500 *******************************************************************************/\r
501 void GPIO_EXTILineConfig(u8 GPIO_PortSource, u8 GPIO_PinSource)\r
502 {\r
503   u32 tmp = 0x00;\r
504 \r
505   /* Check the parameters */\r
506   assert(IS_GPIO_PORT_SOURCE(GPIO_PortSource));\r
507   assert(IS_GPIO_PIN_SOURCE(GPIO_PinSource));\r
508   \r
509   tmp = ((u32)0x0F) << (0x04 * (GPIO_PinSource & (u8)0x03));\r
510 \r
511   AFIO->EXTICR[GPIO_PinSource >> 0x02] &= ~tmp;\r
512   AFIO->EXTICR[GPIO_PinSource >> 0x02] |= (((u32)GPIO_PortSource) << (0x04 * (GPIO_PinSource & (u8)0x03)));\r
513 }\r
514 \r
515 /******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/\r