]> git.sur5r.net Git - freertos/blob - Demo/CORTEX_STM32F103_Keil/STM32F10xFWLib/inc/stm32f10x_gpio.h
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / CORTEX_STM32F103_Keil / STM32F10xFWLib / inc / stm32f10x_gpio.h
1 /******************** (C) COPYRIGHT 2007 STMicroelectronics ********************\r
2 * File Name          : stm32f10x_gpio.h\r
3 * Author             : MCD Application Team\r
4 * Date First Issued  : 09/29/2006\r
5 * Description        : This file contains all the functions prototypes for the\r
6 *                      GPIO firmware library.\r
7 ********************************************************************************\r
8 * History:\r
9 * 04/02/2007: V0.2\r
10 * 02/05/2007: V0.1\r
11 * 09/29/2006: V0.01\r
12 ********************************************************************************\r
13 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
14 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.\r
15 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,\r
16 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE\r
17 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING\r
18 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
19 *******************************************************************************/\r
20 \r
21 /* Define to prevent recursive inclusion -------------------------------------*/\r
22 #ifndef __STM32F10x_GPIO_H\r
23 #define __STM32F10x_GPIO_H\r
24 \r
25 /* Includes ------------------------------------------------------------------*/\r
26 #include "stm32f10x_map.h"\r
27 \r
28 /* Exported types ------------------------------------------------------------*/\r
29 /* Output Maximum frequency selection ----------------------------------------*/\r
30 typedef enum\r
31\r
32   GPIO_Speed_10MHz = 1,\r
33   GPIO_Speed_2MHz, \r
34   GPIO_Speed_50MHz\r
35 }GPIOSpeed_TypeDef;\r
36 \r
37 #define IS_GPIO_SPEED(SPEED) ((SPEED == GPIO_Speed_10MHz) || (SPEED == GPIO_Speed_2MHz) || \\r
38                               (SPEED == GPIO_Speed_50MHz))\r
39                                          \r
40 /* Configuration Mode enumeration --------------------------------------------*/\r
41 typedef enum\r
42 { GPIO_Mode_AIN = 0x0,\r
43   GPIO_Mode_IN_FLOATING = 0x04,\r
44   GPIO_Mode_IPD = 0x28,\r
45   GPIO_Mode_IPU = 0x48,\r
46   GPIO_Mode_Out_OD = 0x14,\r
47   GPIO_Mode_Out_PP = 0x10,\r
48   GPIO_Mode_AF_OD = 0x1C,\r
49   GPIO_Mode_AF_PP = 0x18\r
50 }GPIOMode_TypeDef;\r
51 \r
52 #define IS_GPIO_MODE(MODE) ((MODE == GPIO_Mode_AIN) || (MODE == GPIO_Mode_IN_FLOATING) || \\r
53                             (MODE == GPIO_Mode_IPD) || (MODE == GPIO_Mode_IPU) || \\r
54                             (MODE == GPIO_Mode_Out_OD) || (MODE == GPIO_Mode_Out_PP) || \\r
55                             (MODE == GPIO_Mode_AF_OD) || (MODE == GPIO_Mode_AF_PP))\r
56                               \r
57 /* GPIO Init structure definition */\r
58 typedef struct\r
59 {\r
60   u16 GPIO_Pin;\r
61   GPIOSpeed_TypeDef GPIO_Speed;\r
62   GPIOMode_TypeDef GPIO_Mode;\r
63 }GPIO_InitTypeDef;\r
64 \r
65 /* Bit_SET and Bit_RESET enumeration -----------------------------------------*/\r
66 typedef enum\r
67 { Bit_RESET = 0,\r
68   Bit_SET\r
69 }BitAction;\r
70 #define IS_GPIO_BIT_ACTION(ACTION) ((ACTION == Bit_RESET) || (ACTION == Bit_SET))\r
71 \r
72 /* Exported constants --------------------------------------------------------*/\r
73 /* GPIO pins define ----------------------------------------------------------*/\r
74 #define GPIO_Pin_0                 ((u16)0x0001)  /* Pin 0 selected */\r
75 #define GPIO_Pin_1                 ((u16)0x0002)  /* Pin 1 selected */\r
76 #define GPIO_Pin_2                 ((u16)0x0004)  /* Pin 2 selected */\r
77 #define GPIO_Pin_3                 ((u16)0x0008)  /* Pin 3 selected */\r
78 #define GPIO_Pin_4                 ((u16)0x0010)  /* Pin 4 selected */\r
79 #define GPIO_Pin_5                 ((u16)0x0020)  /* Pin 5 selected */\r
80 #define GPIO_Pin_6                 ((u16)0x0040)  /* Pin 6 selected */\r
81 #define GPIO_Pin_7                 ((u16)0x0080)  /* Pin 7 selected */\r
82 #define GPIO_Pin_8                 ((u16)0x0100)  /* Pin 8 selected */\r
83 #define GPIO_Pin_9                 ((u16)0x0200)  /* Pin 9 selected */\r
84 #define GPIO_Pin_10                ((u16)0x0400)  /* Pin 10 selected */\r
85 #define GPIO_Pin_11                ((u16)0x0800)  /* Pin 11 selected */\r
86 #define GPIO_Pin_12                ((u16)0x1000)  /* Pin 12 selected */\r
87 #define GPIO_Pin_13                ((u16)0x2000)  /* Pin 13 selected */\r
88 #define GPIO_Pin_14                ((u16)0x4000)  /* Pin 14 selected */\r
89 #define GPIO_Pin_15                ((u16)0x8000)  /* Pin 15 selected */\r
90 #define GPIO_Pin_All               ((u16)0xFFFF)  /* All pins selected */\r
91 \r
92 #define IS_GPIO_PIN(PIN) (((PIN & (u16)0x00) == 0x00) && (PIN != (u16)0x00))\r
93                             \r
94 /* GPIO Remap define ---------------------------------------------------------*/\r
95 #define GPIO_Remap_SPI1            ((u32)0x00000001)  /* SPI1 Alternate Function mapping */\r
96 #define GPIO_Remap_I2C1            ((u32)0x00000002)  /* I2C1 Alternate Function mapping */\r
97 #define GPIO_Remap_USART1          ((u32)0x00000004)  /* USART1 Alternate Function mapping */\r
98 #define GPIO_Remap_USART2          ((u32)0x00000008)  /* USART2 Alternate Function mapping */\r
99 #define GPIO_PartialRemap_USART3   ((u32)0x00140010)  /* USART3 Partial Alternate Function mapping */\r
100 #define GPIO_FullRemap_USART3      ((u32)0x00140030)  /* USART3 Full Alternate Function mapping */\r
101 #define GPIO_PartialRemap_TIM1     ((u32)0x00160040)  /* TIM1 Partial Alternate Function mapping */\r
102 #define GPIO_FullRemap_TIM1        ((u32)0x001600C0)  /* TIM1 Full Alternate Function mapping */\r
103 #define GPIO_PartialRemap1_TIM2    ((u32)0x00180100)  /* TIM2 Partial1 Alternate Function mapping */\r
104 #define GPIO_PartialRemap2_TIM2    ((u32)0x00180200)  /* TIM2 Partial2 Alternate Function mapping */\r
105 #define GPIO_FullRemap_TIM2        ((u32)0x00180300)  /* TIM2 Full Alternate Function mapping */\r
106 #define GPIO_PartialRemap_TIM3     ((u32)0x001A0800)  /* TIM3 Partial Alternate Function mapping */\r
107 #define GPIO_FullRemap_TIM3        ((u32)0x001A0C00)  /* TIM3 Full Alternate Function mapping */\r
108 #define GPIO_Remap_TIM4            ((u32)0x00001000)  /* TIM4 Alternate Function mapping */\r
109 #define GPIO_Remap1_CAN            ((u32)0x001D2000)  /* CAN Alternate Function mapping */\r
110 #define GPIO_Remap2_CAN            ((u32)0x001D6000)  /* CAN Alternate Function mapping */\r
111 #define GPIO_Remap_PD01            ((u32)0x00008000)  /* PD01 Alternate Function mapping */\r
112 #define GPIO_Remap_SWJ_NoJTRST     ((u32)0x00300100)  /* Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST */\r
113 #define GPIO_Remap_SWJ_JTAGDisable ((u32)0x00300200)  /* JTAG-DP Disabled and SW-DP Enabled */\r
114 #define GPIO_Remap_SWJ_Disable     ((u32)0x00300400)  /* Full SWJ Disabled (JTAG-DP + SW-DP) */\r
115 \r
116 #define IS_GPIO_REMAP(REMAP) ((REMAP == GPIO_Remap_SPI1) || (REMAP == GPIO_Remap_I2C1) || \\r
117                               (REMAP == GPIO_Remap_USART1) || (REMAP == GPIO_Remap_USART2) || \\r
118                               (REMAP == GPIO_PartialRemap_USART3) || (REMAP == GPIO_FullRemap_USART3) || \\r
119                               (REMAP == GPIO_PartialRemap_TIM1) || (REMAP == GPIO_FullRemap_TIM1) || \\r
120                               (REMAP == GPIO_PartialRemap1_TIM2) || (REMAP == GPIO_PartialRemap2_TIM2) || \\r
121                               (REMAP == GPIO_FullRemap_TIM2) || (REMAP == GPIO_PartialRemap_TIM3) || \\r
122                               (REMAP == GPIO_FullRemap_TIM3) || (REMAP == GPIO_Remap_TIM4) || \\r
123                               (REMAP == GPIO_Remap1_CAN) || (REMAP == GPIO_Remap2_CAN) || \\r
124                               (REMAP == GPIO_Remap_PD01) || (REMAP == GPIO_Remap_SWJ_NoJTRST) || \\r
125                               (REMAP == GPIO_Remap_SWJ_JTAGDisable) || (REMAP == GPIO_Remap_SWJ_Disable))\r
126                               \r
127 /* GPIO Port Sources ---------------------------------------------------------*/\r
128 #define GPIO_PortSourceGPIOA       ((u8)0x00)\r
129 #define GPIO_PortSourceGPIOB       ((u8)0x01)\r
130 #define GPIO_PortSourceGPIOC       ((u8)0x02)\r
131 #define GPIO_PortSourceGPIOD       ((u8)0x03)\r
132 #define GPIO_PortSourceGPIOE       ((u8)0x04)\r
133 \r
134 #define IS_GPIO_PORT_SOURCE(PORTSOURCE) ((PORTSOURCE == GPIO_PortSourceGPIOA) || \\r
135                                          (PORTSOURCE == GPIO_PortSourceGPIOB) || \\r
136                                          (PORTSOURCE == GPIO_PortSourceGPIOC) || \\r
137                                          (PORTSOURCE == GPIO_PortSourceGPIOD) || \\r
138                                          (PORTSOURCE == GPIO_PortSourceGPIOE))\r
139                                        \r
140 /* GPIO Pin sources ----------------------------------------------------------*/\r
141 #define GPIO_PinSource0            ((u8)0x00)\r
142 #define GPIO_PinSource1            ((u8)0x01)\r
143 #define GPIO_PinSource2            ((u8)0x02)\r
144 #define GPIO_PinSource3            ((u8)0x03)\r
145 #define GPIO_PinSource4            ((u8)0x04)\r
146 #define GPIO_PinSource5            ((u8)0x05)\r
147 #define GPIO_PinSource6            ((u8)0x06)\r
148 #define GPIO_PinSource7            ((u8)0x07)\r
149 #define GPIO_PinSource8            ((u8)0x08)\r
150 #define GPIO_PinSource9            ((u8)0x09)\r
151 #define GPIO_PinSource10           ((u8)0x0A)\r
152 #define GPIO_PinSource11           ((u8)0x0B)\r
153 #define GPIO_PinSource12           ((u8)0x0C)\r
154 #define GPIO_PinSource13           ((u8)0x0D)\r
155 #define GPIO_PinSource14           ((u8)0x0E)\r
156 #define GPIO_PinSource15           ((u8)0x0F)\r
157 \r
158 #define IS_GPIO_PIN_SOURCE(PINSOURCE) ((PINSOURCE == GPIO_PinSource0) || \\r
159                                        (PINSOURCE == GPIO_PinSource1) || \\r
160                                        (PINSOURCE == GPIO_PinSource2) || \\r
161                                        (PINSOURCE == GPIO_PinSource3) || \\r
162                                        (PINSOURCE == GPIO_PinSource4) || \\r
163                                        (PINSOURCE == GPIO_PinSource5) || \\r
164                                        (PINSOURCE == GPIO_PinSource6) || \\r
165                                        (PINSOURCE == GPIO_PinSource7) || \\r
166                                        (PINSOURCE == GPIO_PinSource8) || \\r
167                                        (PINSOURCE == GPIO_PinSource9) || \\r
168                                        (PINSOURCE == GPIO_PinSource10) || \\r
169                                        (PINSOURCE == GPIO_PinSource11) || \\r
170                                        (PINSOURCE == GPIO_PinSource12) || \\r
171                                        (PINSOURCE == GPIO_PinSource13) || \\r
172                                        (PINSOURCE == GPIO_PinSource14) || \\r
173                                        (PINSOURCE == GPIO_PinSource15))\r
174                           \r
175 /* Exported macro ------------------------------------------------------------*/\r
176 /* Exported functions ------------------------------------------------------- */\r
177 void GPIO_DeInit(GPIO_TypeDef* GPIOx);\r
178 void GPIO_AFIODeInit(void);\r
179 void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);\r
180 void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);\r
181 u8 GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin);\r
182 u16 GPIO_ReadInputData(GPIO_TypeDef* GPIOx);\r
183 u8 GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin);\r
184 u16 GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);\r
185 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin, BitAction BitVal);\r
186 void GPIO_Write(GPIO_TypeDef* GPIOx, u16 PortVal);\r
187 void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, u16 GPIO_Pin);\r
188 void GPIO_EventOutputConfig(u8 GPIO_PortSource, u8 GPIO_PinSource);\r
189 void GPIO_EventOutputCmd(FunctionalState NewState);\r
190 void GPIO_PinRemapConfig(u32 GPIO_Remap, FunctionalState NewState);\r
191 void GPIO_EXTILineConfig(u8 GPIO_PortSource, u8 GPIO_PinSource);\r
192 \r
193 #endif /* __STM32F10x_GPIO_H */\r
194 \r
195 /******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/\r