1 |
577 |
jeremybenn |
/******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
|
2 |
|
|
* File Name : 75x_extit.c
|
3 |
|
|
* Author : MCD Application Team
|
4 |
|
|
* Date First Issued : 03/10/2006
|
5 |
|
|
* Description : This file provides all the EXTIT software functions.
|
6 |
|
|
********************************************************************************
|
7 |
|
|
* History:
|
8 |
|
|
* 07/17/2006 : V1.0
|
9 |
|
|
* 03/10/2006 : V0.1
|
10 |
|
|
********************************************************************************
|
11 |
|
|
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
12 |
|
|
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
13 |
|
|
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
14 |
|
|
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
15 |
|
|
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
16 |
|
|
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
17 |
|
|
*******************************************************************************/
|
18 |
|
|
|
19 |
|
|
/* Includes ------------------------------------------------------------------*/
|
20 |
|
|
#include "75x_extit.h"
|
21 |
|
|
#include "75x_mrcc.h"
|
22 |
|
|
|
23 |
|
|
/* Private typedef -----------------------------------------------------------*/
|
24 |
|
|
/* Private define ------------------------------------------------------------*/
|
25 |
|
|
/* Private macro -------------------------------------------------------------*/
|
26 |
|
|
/* Private variables ---------------------------------------------------------*/
|
27 |
|
|
/* Private function prototypes -----------------------------------------------*/
|
28 |
|
|
/* Private functions ---------------------------------------------------------*/
|
29 |
|
|
|
30 |
|
|
/*******************************************************************************
|
31 |
|
|
* Function Name : EXTIT_DeInit
|
32 |
|
|
* Description : Deinitializes the EXTIT peripheral registers to their default
|
33 |
|
|
* reset values.
|
34 |
|
|
* Input : None
|
35 |
|
|
* Output : None
|
36 |
|
|
* Return : None
|
37 |
|
|
*******************************************************************************/
|
38 |
|
|
void EXTIT_DeInit(void)
|
39 |
|
|
{
|
40 |
|
|
MRCC_PeripheralSWResetConfig(MRCC_Peripheral_EXTIT,ENABLE);
|
41 |
|
|
MRCC_PeripheralSWResetConfig(MRCC_Peripheral_EXTIT,DISABLE);
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
/*******************************************************************************
|
45 |
|
|
* Function Name : EXTIT_Init
|
46 |
|
|
* Description : Initializes the EXTIT peripheral according to the specified
|
47 |
|
|
* parameters in the EXTIT_InitStruct .
|
48 |
|
|
* Input : - EXTIT_InitStruct: pointer to a EXTIT_InitTypeDef structure
|
49 |
|
|
* that contains the configuration information for the EXTIT
|
50 |
|
|
* peripheral.
|
51 |
|
|
* Output : None
|
52 |
|
|
* Return : None
|
53 |
|
|
*******************************************************************************/
|
54 |
|
|
void EXTIT_Init(EXTIT_InitTypeDef* EXTIT_InitStruct)
|
55 |
|
|
{
|
56 |
|
|
if(EXTIT_InitStruct->EXTIT_ITLineCmd == ENABLE)
|
57 |
|
|
{
|
58 |
|
|
/* Enable the selected external interrupts */
|
59 |
|
|
EXTIT->MR |= EXTIT_InitStruct->EXTIT_ITLine;
|
60 |
|
|
|
61 |
|
|
/* Select the trigger for the selected external interrupts */
|
62 |
|
|
if(EXTIT_InitStruct->EXTIT_ITTrigger == EXTIT_ITTrigger_Falling)
|
63 |
|
|
{
|
64 |
|
|
/* Falling edge */
|
65 |
|
|
EXTIT->TSR &= ~EXTIT_InitStruct->EXTIT_ITLine;
|
66 |
|
|
}
|
67 |
|
|
else if (EXTIT_InitStruct->EXTIT_ITTrigger == EXTIT_ITTrigger_Rising)
|
68 |
|
|
{
|
69 |
|
|
/* Rising edge */
|
70 |
|
|
EXTIT->TSR |= EXTIT_InitStruct->EXTIT_ITLine;
|
71 |
|
|
}
|
72 |
|
|
}
|
73 |
|
|
else if(EXTIT_InitStruct->EXTIT_ITLineCmd == DISABLE)
|
74 |
|
|
{
|
75 |
|
|
/* Disable the selected external interrupts */
|
76 |
|
|
EXTIT->MR &= ~EXTIT_InitStruct->EXTIT_ITLine;
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
/*******************************************************************************
|
81 |
|
|
* Function Name : EXTIT_StructInit
|
82 |
|
|
* Description : Fills each EXTIT_InitStruct member with its reset value.
|
83 |
|
|
* Input : - EXTIT_InitStruct: pointer to a EXTIT_InitTypeDef structure
|
84 |
|
|
* which will be initialized.
|
85 |
|
|
* Output : None
|
86 |
|
|
* Return : None
|
87 |
|
|
*******************************************************************************/
|
88 |
|
|
void EXTIT_StructInit(EXTIT_InitTypeDef* EXTIT_InitStruct)
|
89 |
|
|
{
|
90 |
|
|
EXTIT_InitStruct->EXTIT_ITLine = EXTIT_ITLineNone;
|
91 |
|
|
EXTIT_InitStruct->EXTIT_ITTrigger = EXTIT_ITTrigger_Falling;
|
92 |
|
|
EXTIT_InitStruct->EXTIT_ITLineCmd = DISABLE;
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
/*******************************************************************************
|
96 |
|
|
* Function Name : EXTIT_GenerateSWInterrupt
|
97 |
|
|
* Description : Generates a Software interrupt.
|
98 |
|
|
* Input : - EXTIT_ITLine: specifies the EXTIT lines to be enabled or
|
99 |
|
|
* disabled. This parameter can be:
|
100 |
|
|
* - EXTIT_ITLinex: External interrupt line x where x(0..15)
|
101 |
|
|
* Output : None
|
102 |
|
|
* Return : None
|
103 |
|
|
*******************************************************************************/
|
104 |
|
|
void EXTIT_GenerateSWInterrupt(u16 EXTIT_ITLine)
|
105 |
|
|
{
|
106 |
|
|
EXTIT->SWIR |= EXTIT_ITLine;
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
/*******************************************************************************
|
110 |
|
|
* Function Name : EXTIT_GetFlagStatus
|
111 |
|
|
* Description : Checks whether the specified EXTIT line flag is set or not.
|
112 |
|
|
* Input : - EXTIT_ITLine: specifies the EXTIT lines flag to check.
|
113 |
|
|
* This parameter can be:
|
114 |
|
|
* - EXTIT_ITLinex: External interrupt line x where x(0..15)
|
115 |
|
|
* Output : None
|
116 |
|
|
* Return : The new state of EXTIT_ITLine (SET or RESET).
|
117 |
|
|
*******************************************************************************/
|
118 |
|
|
FlagStatus EXTIT_GetFlagStatus(u16 EXTIT_ITLine)
|
119 |
|
|
{
|
120 |
|
|
if((EXTIT->PR & EXTIT_ITLine) != RESET)
|
121 |
|
|
{
|
122 |
|
|
return SET;
|
123 |
|
|
}
|
124 |
|
|
else
|
125 |
|
|
{
|
126 |
|
|
return RESET;
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
/*******************************************************************************
|
131 |
|
|
* Function Name : EXTIT_ClearFlag
|
132 |
|
|
* Description : Clears the EXTIT’s line pending flags.
|
133 |
|
|
* Input : - EXTIT_ITLine: specifies the EXTIT lines flags to clear.
|
134 |
|
|
* This parameter can be:
|
135 |
|
|
* - EXTIT_ITLinex: External interrupt line x where x(0..15)
|
136 |
|
|
* Output : None
|
137 |
|
|
* Return : None
|
138 |
|
|
*******************************************************************************/
|
139 |
|
|
void EXTIT_ClearFlag(u16 EXTIT_ITLine)
|
140 |
|
|
{
|
141 |
|
|
EXTIT->PR = EXTIT_ITLine;
|
142 |
|
|
}
|
143 |
|
|
|
144 |
|
|
/*******************************************************************************
|
145 |
|
|
* Function Name : EXTIT_GetITStatus
|
146 |
|
|
* Description : Checks whether the specified EXTIT line is asserted or not.
|
147 |
|
|
* Input : - EXTIT_ITLine: specifies the EXTIT lines to check.
|
148 |
|
|
* This parameter can be:
|
149 |
|
|
* - EXTIT_ITLinex: External interrupt line x where x(0..15)
|
150 |
|
|
* Output : None
|
151 |
|
|
* Return : The new state of EXTIT_ITLine (SET or RESET).
|
152 |
|
|
*******************************************************************************/
|
153 |
|
|
ITStatus EXTIT_GetITStatus(u16 EXTIT_ITLine)
|
154 |
|
|
{
|
155 |
|
|
if(((EXTIT->PR & EXTIT_ITLine) != RESET)&& ((EXTIT->MR & EXTIT_ITLine) != RESET))
|
156 |
|
|
{
|
157 |
|
|
return SET;
|
158 |
|
|
}
|
159 |
|
|
else
|
160 |
|
|
{
|
161 |
|
|
return RESET;
|
162 |
|
|
}
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
/*******************************************************************************
|
166 |
|
|
* Function Name : EXTIT_ClearITPendingBit
|
167 |
|
|
* Description : Clears the EXTIT’s line pending bits.
|
168 |
|
|
* Input : - EXTIT_ITLine: specifies the EXTIT lines to clear.
|
169 |
|
|
* This parameter can be:
|
170 |
|
|
* - EXTIT_ITLinex: External interrupt line x where x(0..15)
|
171 |
|
|
* Output : None
|
172 |
|
|
* Return : None
|
173 |
|
|
*******************************************************************************/
|
174 |
|
|
void EXTIT_ClearITPendingBit(u16 EXTIT_ITLine)
|
175 |
|
|
{
|
176 |
|
|
EXTIT->PR = EXTIT_ITLine;
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/
|