Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | /******************** (C) COPYRIGHT 2006 STMicroelectronics ******************** |
2 | * File Name : 91x_wiu.c |
||
3 | * Author : MCD Application Team |
||
4 | * Date First Issued : 05/18/2006 : Version 1.0 |
||
5 | * Description : This file provides all the WIU software functions. |
||
6 | ********************************************************************************** |
||
7 | * History: |
||
8 | * 05/22/2007 : Version 1.2 |
||
9 | * 05/24/2006 : Version 1.1 |
||
10 | * 05/18/2006 : Version 1.0 |
||
11 | ********************************************************************************** |
||
12 | * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH |
||
13 | * 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, INDIRECT |
||
15 | * OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT |
||
16 | * OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION |
||
17 | * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
||
18 | *********************************************************************************/ |
||
19 | |||
20 | /* Standard include ----------------------------------------------------------*/ |
||
21 | #include "91x_wiu.h" |
||
22 | #include "91x_scu.h" |
||
23 | |||
24 | /* Include of other module interface headers ---------------------------------*/ |
||
25 | /* Local includes ------------------------------------------------------------*/ |
||
26 | /* Private typedef -----------------------------------------------------------*/ |
||
27 | /* Private define ------------------------------------------------------------*/ |
||
28 | |||
29 | |||
30 | /* WIU Masks "used" only in this module */ |
||
31 | #define WIU_Enable 0x02 |
||
32 | |||
33 | |||
34 | /* Private macro -------------------------------------------------------------*/ |
||
35 | /* Private variables ---------------------------------------------------------*/ |
||
36 | /* Private function prototypes -----------------------------------------------*/ |
||
37 | /* Interface functions -------------------------------------------------------*/ |
||
38 | /* Private functions ---------------------------------------------------------*/ |
||
39 | /****************************************************************************** |
||
40 | * Function Name : WIU_Init |
||
41 | * Description : Initializes the WIU unit according to the specified parameters |
||
42 | * in the WIU_InitTypeDef structure. |
||
43 | * Input : WIU_InitStruct: pointer to a WIU_InitTypeDef structure that |
||
44 | * contains the configuration information for the WIU peripheral. |
||
45 | * Output : None |
||
46 | * Return : None |
||
47 | ******************************************************************************/ |
||
48 | void WIU_Init(WIU_InitTypeDef* WIU_InitStruct) |
||
49 | { |
||
50 | /* select the Wake-up line to be used */ |
||
51 | WIU->MR |= WIU_InitStruct->WIU_Line; |
||
52 | |||
53 | /* configure the triggering edge */ |
||
54 | if(WIU_InitStruct->WIU_TriggerEdge == WIU_RisingEdge) |
||
55 | { |
||
56 | /* trigger on rising edge */ |
||
57 | WIU->TR |= WIU_InitStruct->WIU_Line; |
||
58 | } |
||
59 | else |
||
60 | { |
||
61 | /* trigger on falling edge */ |
||
62 | WIU->TR &= ~WIU_InitStruct->WIU_Line; |
||
63 | } |
||
64 | |||
65 | } |
||
66 | |||
67 | /****************************************************************************** |
||
68 | * Function Name : WIU_DeInit |
||
69 | * Description : Deinitializes the WIU registers to their default reset values. |
||
70 | * Input : None |
||
71 | * Output : None |
||
72 | * Return : None |
||
73 | ******************************************************************************/ |
||
74 | void WIU_DeInit(void) |
||
75 | { |
||
76 | /* initialize the WIU registers to their reset value */ |
||
77 | SCU_APBPeriphReset(__WIU, ENABLE); |
||
78 | SCU_APBPeriphReset(__WIU, DISABLE); |
||
79 | } |
||
80 | |||
81 | /****************************************************************************** |
||
82 | * Function Name : WIU_StructInit |
||
83 | * Description : Fills in a WIU_InitTypeDef structure with the reset value of |
||
84 | * each parameter. |
||
85 | * Input : WIU_InitStruct : pointer to a WIU_InitTypeDef structure |
||
86 | * which will be initialized. |
||
87 | * Output : None |
||
88 | * Return : None |
||
89 | ******************************************************************************/ |
||
90 | void WIU_StructInit(WIU_InitTypeDef* WIU_InitStruct) |
||
91 | { |
||
92 | /* initialize the WIU_InitStruct fields to their reset values */ |
||
93 | WIU_InitStruct->WIU_Line = 0x0 ; |
||
94 | WIU_InitStruct->WIU_TriggerEdge = WIU_FallingEdge ; |
||
95 | } |
||
96 | |||
97 | /******************************************************************************* |
||
98 | * Function Name : WIU_Cmd |
||
99 | * Description : Enables or disables the WIU peripheral. |
||
100 | * Input : NewState: new state of the WIU peripheral (Newstate can be |
||
101 | * ENABLE or DISABLE) |
||
102 | * Output : None |
||
103 | * Return : None |
||
104 | *******************************************************************************/ |
||
105 | void WIU_Cmd(FunctionalState NewState ) |
||
106 | { |
||
107 | if(NewState == ENABLE) |
||
108 | { |
||
109 | /* Enable the Wake-up Unit (for interrupts and wake-up from low power modes) */ |
||
110 | WIU->CTRL |= WIU_Enable ; |
||
111 | } |
||
112 | else |
||
113 | { |
||
114 | /* Disable the Wake-up Unit (for interrupts and wake-up from low power modes) */ |
||
115 | |||
116 | WIU->CTRL &= WIU_Enable ; |
||
117 | } |
||
118 | } |
||
119 | |||
120 | /******************************************************************************* |
||
121 | * Function Name : WIU_GenerateSWInterrupt |
||
122 | * Description : Generates a Software interrupt. |
||
123 | * Input : - WIU_Line: specifies the WIU lines to be enabled or |
||
124 | * disabled. This parameter can be: |
||
125 | * - WIU_Linex: External interrupt line x where x(0..31) |
||
126 | * Output : None |
||
127 | * Return : None |
||
128 | *******************************************************************************/ |
||
129 | void WIU_GenerateSWInterrupt(u32 WIU_Line) |
||
130 | { |
||
131 | WIU->INTR |= WIU_Line; |
||
132 | } |
||
133 | |||
134 | /******************************************************************************* |
||
135 | * Function Name : WIU_GetFlagStatus |
||
136 | * Description : Checks whether the specified WIU line flag is set or not. |
||
137 | * Input : - WIU_Line: specifies the WIU lines flag to check. |
||
138 | * This parameter can be: |
||
139 | * - WIU_Linex: External interrupt line x where x(0..31) |
||
140 | * Output : None |
||
141 | * Return : The new state of WIU_Line (SET or RESET). |
||
142 | *******************************************************************************/ |
||
143 | FlagStatus WIU_GetFlagStatus(u32 WIU_Line) |
||
144 | { |
||
145 | if((WIU->PR & WIU_Line) != RESET) |
||
146 | { |
||
147 | return SET; |
||
148 | } |
||
149 | else |
||
150 | { |
||
151 | return RESET; |
||
152 | } |
||
153 | } |
||
154 | |||
155 | /******************************************************************************* |
||
156 | * Function Name : WIU_ClearFlag |
||
157 | * Description : Clears the WIU’s line pending flags. |
||
158 | * Input : - WIU_Line: specifies the WIU lines flags to clear. |
||
159 | * This parameter can be: |
||
160 | * - WIU_Linex: External interrupt line x where x(0..31) |
||
161 | * Output : None |
||
162 | * Return : None |
||
163 | *******************************************************************************/ |
||
164 | void WIU_ClearFlag(u32 WIU_Line) |
||
165 | { |
||
166 | WIU->PR = WIU_Line; |
||
167 | } |
||
168 | |||
169 | /******************************************************************************* |
||
170 | * Function Name : WIU_GetITStatus |
||
171 | * Description : Checks whether the specified WIU line is asserted or not. |
||
172 | * Input : - WIU_Line: specifies the WIU lines to check. |
||
173 | * This parameter can be: |
||
174 | * - WIU_Linex: External interrupt line x where x(0..31) |
||
175 | * Output : None |
||
176 | * Return : The new state of WIU_Line (SET or RESET). |
||
177 | *******************************************************************************/ |
||
178 | ITStatus WIU_GetITStatus(u32 WIU_Line) |
||
179 | { |
||
180 | if(((WIU->PR & WIU_Line) != RESET)&& ((WIU->MR & WIU_Line) != RESET)) |
||
181 | { |
||
182 | return SET; |
||
183 | } |
||
184 | else |
||
185 | { |
||
186 | return RESET; |
||
187 | } |
||
188 | } |
||
189 | |||
190 | /******************************************************************************* |
||
191 | * Function Name : WIU_ClearITPendingBit |
||
192 | * Description : Clears the WIU’s line pending bits. |
||
193 | * Input : - WIU_Line: specifies the WIU lines to clear. |
||
194 | * This parameter can be: |
||
195 | * - WIU_Linex: External interrupt line x where x(0..31) |
||
196 | * Output : None |
||
197 | * Return : None |
||
198 | *******************************************************************************/ |
||
199 | void WIU_ClearITPendingBit(u32 WIU_Line) |
||
200 | { |
||
201 | WIU->PR = WIU_Line; |
||
202 | } |
||
203 | |||
204 | |||
205 | /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/ |