OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [ST/] [STM32F10xFWLib/] [src/] [stm32f10x_exti.c] - Blame information for rev 637

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 608 jeremybenn
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
2
* File Name          : stm32f10x_exti.c
3
* Author             : MCD Application Team
4
* Date First Issued  : 09/29/2006
5
* Description        : This file provides all the EXTI firmware functions.
6
********************************************************************************
7
* History:
8
* 04/02/2007: V0.2
9
* 02/05/2007: V0.1
10
* 09/29/2006: V0.01
11
********************************************************************************
12
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
14
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
15
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
16
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
17
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18
*******************************************************************************/
19
 
20
/* Includes ------------------------------------------------------------------*/
21
#include "stm32f10x_exti.h"
22
 
23
/* Private typedef -----------------------------------------------------------*/
24
/* Private define ------------------------------------------------------------*/
25
#define EXTI_LineNone    ((u32)0x00000)  /* No interrupt selected */
26
 
27
/* Private macro -------------------------------------------------------------*/
28
/* Private variables ---------------------------------------------------------*/
29
/* Private function prototypes -----------------------------------------------*/
30
/* Private functions ---------------------------------------------------------*/
31
 
32
/*******************************************************************************
33
* Function Name  : EXTI_DeInit
34
* Description    : Deinitializes the EXTI peripheral registers to their default
35
*                  reset values.
36
* Input          : None
37
* Output         : None
38
* Return         : None
39
*******************************************************************************/
40
void EXTI_DeInit(void)
41
{
42
  EXTI->IMR = 0x00000000;
43
  EXTI->EMR = 0x00000000;
44
  EXTI->RTSR = 0x00000000;
45
  EXTI->FTSR = 0x00000000;
46
  EXTI->PR = 0x0007FFFF;
47
}
48
 
49
/*******************************************************************************
50
* Function Name  : EXTI_Init
51
* Description    : Initializes the EXTI peripheral according to the specified
52
*                  parameters in the EXTI_InitStruct.
53
* Input          : - EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure
54
*                    that contains the configuration information for the EXTI
55
*                    peripheral.
56
* Output         : None
57
* Return         : None
58
*******************************************************************************/
59
void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct)
60
{
61
  /* Check the parameters */
62
  assert(IS_EXTI_MODE(EXTI_InitStruct->EXTI_Mode));
63
  assert(IS_EXTI_TRIGGER(EXTI_InitStruct->EXTI_Trigger));
64
  assert(IS_EXTI_LINE(EXTI_InitStruct->EXTI_Line));
65
  assert(IS_FUNCTIONAL_STATE(EXTI_InitStruct->EXTI_LineCmd));
66
 
67
  if (EXTI_InitStruct->EXTI_LineCmd != DISABLE)
68
  {
69
    *(u32 *)(EXTI_BASE + (u32)EXTI_InitStruct->EXTI_Mode)|= EXTI_InitStruct->EXTI_Line;
70
 
71
    /* Clear Rising Falling edge configuration */
72
    EXTI->RTSR &= ~EXTI_InitStruct->EXTI_Line;
73
    EXTI->FTSR &= ~EXTI_InitStruct->EXTI_Line;
74
 
75
    /* Select the trigger for the selected external interrupts */
76
    if (EXTI_InitStruct->EXTI_Trigger == EXTI_Trigger_Rising_Falling)
77
    {
78
      /* Rising Falling edge */
79
      EXTI->RTSR |= EXTI_InitStruct->EXTI_Line;
80
      EXTI->FTSR |= EXTI_InitStruct->EXTI_Line;
81
    }
82
    else
83
    {
84
      *(u32 *)(EXTI_BASE + (u32)EXTI_InitStruct->EXTI_Trigger)|= EXTI_InitStruct->EXTI_Line;
85
    }
86
  }
87
  else
88
  {
89
    /* Disable the selected external lines */
90
    *(u32 *)(EXTI_BASE + (u32)EXTI_InitStruct->EXTI_Mode)&= ~EXTI_InitStruct->EXTI_Line;
91
  }
92
}
93
 
94
/*******************************************************************************
95
* Function Name  : EXTI_StructInit
96
* Description    : Fills each EXTI_InitStruct member with its reset value.
97
* Input          : - EXTI_InitStruct: pointer to a EXTI_InitTypeDef structure
98
*                    which will be initialized.
99
* Output         : None
100
* Return         : None
101
*******************************************************************************/
102
void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct)
103
{
104
  EXTI_InitStruct->EXTI_Line = EXTI_LineNone;
105
  EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt;
106
  EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling;
107
  EXTI_InitStruct->EXTI_LineCmd = DISABLE;
108
}
109
 
110
/*******************************************************************************
111
* Function Name  : EXTI_GenerateSWInterrupt
112
* Description    : Generates a Software interrupt.
113
* Input          : - EXTI_Line: specifies the EXTI lines to be enabled or
114
*                    disabled.
115
*                    This parameter can be:
116
*                       - EXTI_Linex: External interrupt line x where x(0..18)
117
* Output         : None
118
* Return         : None
119
*******************************************************************************/
120
void EXTI_GenerateSWInterrupt(u32 EXTI_Line)
121
{
122
  /* Check the parameters */
123
  assert(IS_EXTI_LINE(EXTI_Line));
124
 
125
  EXTI->SWIER |= EXTI_Line;
126
}
127
 
128
/*******************************************************************************
129
* Function Name  : EXTI_GetFlagStatus
130
* Description    : Checks whether the specified EXTI line flag is set or not.
131
* Input          : - EXTI_Line: specifies the EXTI lines flag to check.
132
*                    This parameter can be:
133
*                       - EXTI_Linex: External interrupt line x where x(0..18)
134
* Output         : None
135
* Return         : The new state of EXTI_Line (SET or RESET).
136
*******************************************************************************/
137
FlagStatus EXTI_GetFlagStatus(u32 EXTI_Line)
138
{
139
  FlagStatus bitstatus = RESET;
140
 
141
  /* Check the parameters */
142
  assert(IS_GET_EXTI_LINE(EXTI_Line));
143
 
144
  if ((EXTI->PR & EXTI_Line) != (u32)RESET)
145
  {
146
    bitstatus = SET;
147
  }
148
  else
149
  {
150
    bitstatus = RESET;
151
  }
152
  return bitstatus;
153
}
154
 
155
/*******************************************************************************
156
* Function Name  : EXTI_ClearFlag
157
* Description    : Clears the EXTI’s line pending flags.
158
* Input          : - EXTI_Line: specifies the EXTI lines flags to clear.
159
*                    This parameter can be:
160
*                       - EXTI_Linex: External interrupt line x where x(0..18)
161
* Output         : None
162
* Return         : None
163
*******************************************************************************/
164
void EXTI_ClearFlag(u32 EXTI_Line)
165
{
166
  /* Check the parameters */
167
  assert(IS_EXTI_LINE(EXTI_Line));
168
 
169
  EXTI->PR = EXTI_Line;
170
}
171
 
172
/*******************************************************************************
173
* Function Name  : EXTI_GetITStatus
174
* Description    : Checks whether the specified EXTI line is asserted or not.
175
* Input          : - EXTI_Line: specifies the EXTI lines to check.
176
*                    This parameter can be:
177
*                       - EXTI_Linex: External interrupt line x where x(0..18)
178
* Output         : None
179
* Return         : The new state of EXTI_Line (SET or RESET).
180
*******************************************************************************/
181
ITStatus EXTI_GetITStatus(u32 EXTI_Line)
182
{
183
  ITStatus bitstatus = RESET;
184
  u32 enablestatus = 0;
185
 
186
  /* Check the parameters */
187
  assert(IS_GET_EXTI_LINE(EXTI_Line));
188
 
189
  enablestatus =  EXTI->IMR & EXTI_Line;
190
 
191
  if (((EXTI->PR & EXTI_Line) != (u32)RESET) && enablestatus)
192
  {
193
    bitstatus = SET;
194
  }
195
  else
196
  {
197
    bitstatus = RESET;
198
  }
199
  return bitstatus;
200
}
201
 
202
/*******************************************************************************
203
* Function Name  : EXTI_ClearITPendingBit
204
* Description    : Clears the EXTI’s line pending bits.
205
* Input          : - EXTI_Line: specifies the EXTI lines to clear.
206
*                    This parameter can be:
207
*                       - EXTI_Linex: External interrupt line x where x(0..18)
208
* Output         : None
209
* Return         : None
210
*******************************************************************************/
211
void EXTI_ClearITPendingBit(u32 EXTI_Line)
212
{
213
  /* Check the parameters */
214
  assert(IS_EXTI_LINE(EXTI_Line));
215
 
216
  EXTI->PR = EXTI_Line;
217
}
218
 
219
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

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