OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_STM32F103_GCC_Rowley/] [ST Library/] [inc/] [stm32f10x_gpio.h] - Blame information for rev 582

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.