Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | /******************** (C) COPYRIGHT 2006 STMicroelectronics ******************** |
2 | * File Name : 91x_vic.c |
||
3 | * Author : MCD Application Team |
||
4 | * Date First Issued : 05/18/2006 : Version 1.0 |
||
5 | * Description : This file provides all the VIC 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. AS |
||
14 | * 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 | |||
21 | /* Standard include ----------------------------------------------------------*/ |
||
22 | #include "91x_vic.h" |
||
23 | |||
24 | /* Include of other module interface headers ---------------------------------*/ |
||
25 | /* Local includes ------------------------------------------------------------*/ |
||
26 | /* Private typedef -----------------------------------------------------------*/ |
||
27 | /* Private define ------------------------------------------------------------*/ |
||
28 | |||
29 | #define VIC_REGISTER_NUMBER 16 |
||
30 | #define VIC_PROTECTION_ENABLE_MASK 0x1 |
||
31 | #define VIC_PROTECTION_DISABLE_MASK 0xFFFFFFFE |
||
32 | #define VIC_VECTOR_ENABLE_MASK 0x20 |
||
33 | #define VIC_IT_SOURCE_MASK 0xFFFFFFE0 |
||
34 | /* Private macro -------------------------------------------------------------*/ |
||
35 | /* Private variables ---------------------------------------------------------*/ |
||
36 | /* Private function prototypes -----------------------------------------------*/ |
||
37 | |||
38 | static void VIC_ITModeConfig(u16 VIC_Source, VIC_ITLineMode VIC_LineMode); |
||
39 | static void VIC_ISRVectAddConfig(u16 VIC_Source, u16 VIC_Priority, \ |
||
40 | void (*VIC_VectAddress)(void)); |
||
41 | static void VIC_VectEnableConfig(u16 VIC_Source, u16 VIC_Priority); |
||
42 | static void VIC_ITSourceConfig(u16 VIC_Source, u16 VIC_Priority); |
||
43 | |||
44 | /* Interface functions -------------------------------------------------------*/ |
||
45 | /* Private functions ---------------------------------------------------------*/ |
||
46 | |||
47 | /******************************************************************************* |
||
48 | * Function Name : VIC_DeInit |
||
49 | * Description : Deinitialize the VIC module registers to their default reset |
||
50 | * values. |
||
51 | * Input : None |
||
52 | * Output : None |
||
53 | * Return : None |
||
54 | *******************************************************************************/ |
||
55 | void VIC_DeInit(void) |
||
56 | { |
||
57 | SCU_AHBPeriphReset(__VIC, ENABLE); /* VIC peripheral is under Reset */ |
||
58 | SCU_AHBPeriphReset(__VIC, DISABLE); /* VIC peripheral Reset off */ |
||
59 | } |
||
60 | |||
61 | /******************************************************************************* |
||
62 | * Function Name : VIC_GetIRQStatus |
||
63 | * Description : Get the status of interrupts after IRQ masking. |
||
64 | * Input : VIC_Source: specifies the number of the source line. |
||
65 | * This parameter can be one of the following values: |
||
66 | * - WDG_ITLine : VIC source 0 |
||
67 | * - SW_ITLine : VIC source 1 |
||
68 | * - ARMRX_ITLine : VIC source 2 |
||
69 | * - ARMTX_ITLine : VIC source 3 |
||
70 | * - TIM0_ITLine : VIC source 4 |
||
71 | * - TIM1_ITLine : VIC source 5 |
||
72 | * - TIM2_ITLine : VIC source 6 |
||
73 | * - TIM3_ITLine : VIC source 7 |
||
74 | * - USBHP_ITLine : VIC source 8 |
||
75 | * - USBLP_ITLine : VIC source 9 |
||
76 | * - SCU_ITLine : VIC source 10 |
||
77 | * - ENET_ITLine : VIC source 11 |
||
78 | * - DMA_ITLine : VIC source 12 |
||
79 | * - CAN_ITLine : VIC source 13 |
||
80 | * - MC_ITLine : VIC source 14 |
||
81 | * - ADC_ITLine : VIC source 15 |
||
82 | * - UART0_ITLine : VIC source 16 |
||
83 | * - UART1_ITLine : VIC source 17 |
||
84 | * - UART2_ITLine : VIC source 18 |
||
85 | * - I2C0_ITLine : VIC source 19 |
||
86 | * - I2C1_ITLine : VIC source 20 |
||
87 | * - SSP0_ITLine : VIC source 21 |
||
88 | * - SSP1_ITLine : VIC source 22 |
||
89 | * - LVD_ITLine : VIC source 23 |
||
90 | * - RTC_ITLine : VIC source 24 |
||
91 | * - WIU_ITLine : VIC source 25 |
||
92 | * - EXTIT0_ITLine: VIC source 26 |
||
93 | * - EXTIT1_ITLine: VIC source 27 |
||
94 | * - EXTIT2_ITLine: VIC source 28 |
||
95 | * - EXTIT3_ITLine: VIC source 29 |
||
96 | * - USBWU_ITLine : VIC source 30 |
||
97 | * - PFQBC_ITLine : VIC source 31 |
||
98 | * Output : None |
||
99 | * Return : The status of the IRQ interrupt after masking (SET or RESET). |
||
100 | *******************************************************************************/ |
||
101 | FlagStatus VIC_GetIRQStatus(u16 VIC_Source) |
||
102 | { |
||
103 | u32 VIC_Mask = 1; |
||
104 | if (VIC_Source < VIC_REGISTER_NUMBER) |
||
105 | { |
||
106 | if ((VIC0->ISR | VIC_Mask << VIC_Source) != RESET) |
||
107 | return SET; |
||
108 | else |
||
109 | return RESET; |
||
110 | } |
||
111 | else |
||
112 | { |
||
113 | if ((VIC1->ISR | VIC_Mask << (VIC_Source - VIC_REGISTER_NUMBER)) != RESET) |
||
114 | return SET; |
||
115 | else |
||
116 | return RESET; |
||
117 | } |
||
118 | } |
||
119 | |||
120 | /******************************************************************************* |
||
121 | * Function Name : VIC_GetFIQStatus |
||
122 | * Description : Get the status of interrupts after FIQ masking |
||
123 | * Input : VIC_Source: specifies the number of the source line. |
||
124 | * This parameter can be one of the following values: |
||
125 | * - WDG_ITLine : VIC source 0 |
||
126 | * - SW_ITLine : VIC source 1 |
||
127 | * - ARMRX_ITLine : VIC source 2 |
||
128 | * - ARMTX_ITLine : VIC source 3 |
||
129 | * - TIM0_ITLine : VIC source 4 |
||
130 | * - TIM1_ITLine : VIC source 5 |
||
131 | * - TIM2_ITLine : VIC source 6 |
||
132 | * - TIM3_ITLine : VIC source 7 |
||
133 | * - USBHP_ITLine : VIC source 8 |
||
134 | * - USBLP_ITLine : VIC source 9 |
||
135 | * - SCU_ITLine : VIC source 10 |
||
136 | * - ENET_ITLine : VIC source 11 |
||
137 | * - DMA_ITLine : VIC source 12 |
||
138 | * - CAN_ITLine : VIC source 13 |
||
139 | * - MC_ITLine : VIC source 14 |
||
140 | * - ADC_ITLine : VIC source 15 |
||
141 | * - UART0_ITLine : VIC source 16 |
||
142 | * - UART1_ITLine : VIC source 17 |
||
143 | * - UART2_ITLine : VIC source 18 |
||
144 | * - I2C0_ITLine : VIC source 19 |
||
145 | * - I2C1_ITLine : VIC source 20 |
||
146 | * - SSP0_ITLine : VIC source 21 |
||
147 | * - SSP1_ITLine : VIC source 22 |
||
148 | * - LVD_ITLine : VIC source 23 |
||
149 | * - RTC_ITLine : VIC source 24 |
||
150 | * - WIU_ITLine : VIC source 25 |
||
151 | * - EXTIT0_ITLine: VIC source 26 |
||
152 | * - EXTIT1_ITLine: VIC source 27 |
||
153 | * - EXTIT2_ITLine: VIC source 28 |
||
154 | * - EXTIT3_ITLine: VIC source 29 |
||
155 | * - USBWU_ITLine : VIC source 30 |
||
156 | * - PFQBC_ITLine : VIC source 31 |
||
157 | * Output : None |
||
158 | * Return : The status of the FIQ interrupt after masking (SET or RESET) |
||
159 | *******************************************************************************/ |
||
160 | FlagStatus VIC_GetFIQStatus(u16 VIC_Source) |
||
161 | { |
||
162 | u32 VIC_Mask = 1; |
||
163 | if (VIC_Source < VIC_REGISTER_NUMBER) |
||
164 | { |
||
165 | if ((VIC0->RINTSR | VIC_Mask << VIC_Source) != RESET) |
||
166 | return SET; |
||
167 | else |
||
168 | return RESET; |
||
169 | } |
||
170 | else |
||
171 | { |
||
172 | if ((VIC1->RINTSR | VIC_Mask << (VIC_Source - VIC_REGISTER_NUMBER)) != RESET) |
||
173 | return SET; |
||
174 | else |
||
175 | return RESET; |
||
176 | } |
||
177 | } |
||
178 | |||
179 | /******************************************************************************* |
||
180 | * Function Name : VIC_GetSourceITStatus |
||
181 | * Description : Get the status of the source interrupts before masking. |
||
182 | * Input : VIC_Source: specifies the number of the source line. |
||
183 | * This parameter can be one of the following values: |
||
184 | * - WDG_ITLine : VIC source 0 |
||
185 | * - SW_ITLine : VIC source 1 |
||
186 | * - ARMRX_ITLine : VIC source 2 |
||
187 | * - ARMTX_ITLine : VIC source 3 |
||
188 | * - TIM0_ITLine : VIC source 4 |
||
189 | * - TIM1_ITLine : VIC source 5 |
||
190 | * - TIM2_ITLine : VIC source 6 |
||
191 | * - TIM3_ITLine : VIC source 7 |
||
192 | * - USBHP_ITLine : VIC source 8 |
||
193 | * - USBLP_ITLine : VIC source 9 |
||
194 | * - SCU_ITLine : VIC source 10 |
||
195 | * - ENET_ITLine : VIC source 11 |
||
196 | * - DMA_ITLine : VIC source 12 |
||
197 | * - CAN_ITLine : VIC source 13 |
||
198 | * - MC_ITLine : VIC source 14 |
||
199 | * - ADC_ITLine : VIC source 15 |
||
200 | * - UART0_ITLine : VIC source 16 |
||
201 | * - UART1_ITLine : VIC source 17 |
||
202 | * - UART2_ITLine : VIC source 18 |
||
203 | * - I2C0_ITLine : VIC source 19 |
||
204 | * - I2C1_ITLine : VIC source 20 |
||
205 | * - SSP0_ITLine : VIC source 21 |
||
206 | * - SSP1_ITLine : VIC source 22 |
||
207 | * - LVD_ITLine : VIC source 23 |
||
208 | * - RTC_ITLine : VIC source 24 |
||
209 | * - WIU_ITLine : VIC source 25 |
||
210 | * - EXTIT0_ITLine: VIC source 26 |
||
211 | * - EXTIT1_ITLine: VIC source 27 |
||
212 | * - EXTIT2_ITLine: VIC source 28 |
||
213 | * - EXTIT3_ITLine: VIC source 29 |
||
214 | * - USBWU_ITLine : VIC source 30 |
||
215 | * - PFQBC_ITLine : VIC source 31 |
||
216 | * Output : None |
||
217 | * Return : The status of the source interrupt before masking |
||
218 | *******************************************************************************/ |
||
219 | FlagStatus VIC_GetSourceITStatus(u16 VIC_Source) |
||
220 | { |
||
221 | u32 VIC_Mask = 1; |
||
222 | if (VIC_Source < VIC_REGISTER_NUMBER) |
||
223 | { |
||
224 | if ((VIC0->FSR | VIC_Mask << VIC_Source) != RESET) |
||
225 | return SET; |
||
226 | else |
||
227 | return RESET; |
||
228 | } |
||
229 | else |
||
230 | { |
||
231 | if ((VIC1->FSR | VIC_Mask << (VIC_Source - VIC_REGISTER_NUMBER)) != RESET) |
||
232 | return SET; |
||
233 | else |
||
234 | return RESET; |
||
235 | } |
||
236 | } |
||
237 | |||
238 | /******************************************************************************* |
||
239 | * Function Name : VIC_ITModeConfig |
||
240 | * Description : Select the type of interrupt (IRQ or FIQ) |
||
241 | * Input1 : VIC_Source: specifies the number of the source line. |
||
242 | * This parameter can be one of the following values: |
||
243 | * - WDG_ITLine : VIC source 0 |
||
244 | * - SW_ITLine : VIC source 1 |
||
245 | * - ARMRX_ITLine : VIC source 2 |
||
246 | * - ARMTX_ITLine : VIC source 3 |
||
247 | * - TIM0_ITLine : VIC source 4 |
||
248 | * - TIM1_ITLine : VIC source 5 |
||
249 | * - TIM2_ITLine : VIC source 6 |
||
250 | * - TIM3_ITLine : VIC source 7 |
||
251 | * - USBHP_ITLine : VIC source 8 |
||
252 | * - USBLP_ITLine : VIC source 9 |
||
253 | * - SCU_ITLine : VIC source 10 |
||
254 | * - ENET_ITLine : VIC source 11 |
||
255 | * - DMA_ITLine : VIC source 12 |
||
256 | * - CAN_ITLine : VIC source 13 |
||
257 | * - MC_ITLine : VIC source 14 |
||
258 | * - ADC_ITLine : VIC source 15 |
||
259 | * - UART0_ITLine : VIC source 16 |
||
260 | * - UART1_ITLine : VIC source 17 |
||
261 | * - UART2_ITLine : VIC source 18 |
||
262 | * - I2C0_ITLine : VIC source 19 |
||
263 | * - I2C1_ITLine : VIC source 20 |
||
264 | * - SSP0_ITLine : VIC source 21 |
||
265 | * - SSP1_ITLine : VIC source 22 |
||
266 | * - LVD_ITLine : VIC source 23 |
||
267 | * - RTC_ITLine : VIC source 24 |
||
268 | * - WIU_ITLine : VIC source 25 |
||
269 | * - EXTIT0_ITLine: VIC source 26 |
||
270 | * - EXTIT1_ITLine: VIC source 27 |
||
271 | * - EXTIT2_ITLine: VIC source 28 |
||
272 | * - EXTIT3_ITLine: VIC source 29 |
||
273 | * - USBWU_ITLine : VIC source 30 |
||
274 | * - PFQBC_ITLine : VIC source 31 |
||
275 | * Input2 : VIC_LineMode :specifies the type of interrupt of the source |
||
276 | * line. This parameter can be one of the following values: |
||
277 | * - VIC_IRQ: the correspondent line is configured as IRQ. |
||
278 | * - VIC_FIQ: the correspondent line is configured as FIQ. |
||
279 | * Output : None |
||
280 | * Return : None |
||
281 | *******************************************************************************/ |
||
282 | static void VIC_ITModeConfig(u16 VIC_Source, VIC_ITLineMode VIC_LineMode) |
||
283 | { |
||
284 | u32 VIC_Mask = 1; |
||
285 | |||
286 | if (VIC_Source < VIC_REGISTER_NUMBER) /* VIC0 */ |
||
287 | { |
||
288 | if (VIC_LineMode == VIC_IRQ) |
||
289 | VIC0->INTSR &= ~(VIC_Mask << VIC_Source); |
||
290 | else /* VIC_LineMode == VIC_FIQ */ |
||
291 | VIC0->INTSR |= (VIC_Mask << VIC_Source); |
||
292 | } |
||
293 | else /* VIC1 */ |
||
294 | { |
||
295 | if (VIC_LineMode == VIC_IRQ) |
||
296 | VIC1->INTSR &= ~(VIC_Mask << (VIC_Source - VIC_REGISTER_NUMBER)); |
||
297 | else /* VIC_LineMode == VIC_FIQ */ |
||
298 | VIC1->INTSR |= (VIC_Mask << (VIC_Source - VIC_REGISTER_NUMBER)); |
||
299 | } |
||
300 | } |
||
301 | |||
302 | /******************************************************************************* |
||
303 | * Function Name : VIC_ITCmd |
||
304 | * Description : Enable or disable the interrupt request lines. |
||
305 | * Input1 : VIC_Source: specifies the number of the source line. |
||
306 | * This parameter can be one of the following values: |
||
307 | * - WDG_ITLine : VIC source 0 |
||
308 | * - SW_ITLine : VIC source 1 |
||
309 | * - ARMRX_ITLine : VIC source 2 |
||
310 | * - ARMTX_ITLine : VIC source 3 |
||
311 | * - TIM0_ITLine : VIC source 4 |
||
312 | * - TIM1_ITLine : VIC source 5 |
||
313 | * - TIM2_ITLine : VIC source 6 |
||
314 | * - TIM3_ITLine : VIC source 7 |
||
315 | * - USBHP_ITLine : VIC source 8 |
||
316 | * - USBLP_ITLine : VIC source 9 |
||
317 | * - SCU_ITLine : VIC source 10 |
||
318 | * - ENET_ITLine : VIC source 11 |
||
319 | * - DMA_ITLine : VIC source 12 |
||
320 | * - CAN_ITLine : VIC source 13 |
||
321 | * - MC_ITLine : VIC source 14 |
||
322 | * - ADC_ITLine : VIC source 15 |
||
323 | * - UART0_ITLine : VIC source 16 |
||
324 | * - UART1_ITLine : VIC source 17 |
||
325 | * - UART2_ITLine : VIC source 18 |
||
326 | * - I2C0_ITLine : VIC source 19 |
||
327 | * - I2C1_ITLine : VIC source 20 |
||
328 | * - SSP0_ITLine : VIC source 21 |
||
329 | * - SSP1_ITLine : VIC source 22 |
||
330 | * - LVD_ITLine : VIC source 23 |
||
331 | * - RTC_ITLine : VIC source 24 |
||
332 | * - WIU_ITLine : VIC source 25 |
||
333 | * - EXTIT0_ITLine: VIC source 26 |
||
334 | * - EXTIT1_ITLine: VIC source 27 |
||
335 | * - EXTIT2_ITLine: VIC source 28 |
||
336 | * - EXTIT3_ITLine: VIC source 29 |
||
337 | * - USBWU_ITLine : VIC source 30 |
||
338 | * - PFQBC_ITLine : VIC source 31 |
||
339 | * Input2 : FMI_NewState: specifies the line status. |
||
340 | * This parameter can be one of the following values: |
||
341 | * - ENABLE: The line is enabled. |
||
342 | * - DISABLE: The line is disabled. |
||
343 | * Output : None |
||
344 | * Return : None |
||
345 | *******************************************************************************/ |
||
346 | void VIC_ITCmd(u16 VIC_Source, FunctionalState VIC_NewState) |
||
347 | { |
||
348 | u32 VIC_Mask = 1; |
||
349 | |||
350 | if (VIC_NewState == ENABLE) |
||
351 | { |
||
352 | if (VIC_Source < VIC_REGISTER_NUMBER) /* VIC0 */ |
||
353 | VIC0->INTER |= (VIC_Mask << VIC_Source); |
||
354 | else /* VIC1 */ |
||
355 | VIC1->INTER |= (VIC_Mask << (VIC_Source - VIC_REGISTER_NUMBER)); |
||
356 | } |
||
357 | else /* VIC_NewState == DISABLE */ |
||
358 | { |
||
359 | if (VIC_Source < VIC_REGISTER_NUMBER) /* VIC0 */ |
||
360 | VIC0->INTECR |= (VIC_Mask << VIC_Source); |
||
361 | else /* VIC1 */ |
||
362 | VIC1->INTECR |= (VIC_Mask << (VIC_Source - VIC_REGISTER_NUMBER)); |
||
363 | } |
||
364 | } |
||
365 | |||
366 | /******************************************************************************* |
||
367 | * Function Name : VIC_SWITCmd |
||
368 | * Description : Generate a software interrupt for the specific source |
||
369 | * interrupt. |
||
370 | * Input1 : VIC_Source: specifies the number of the source line. |
||
371 | * This parameter can be one of the following values: |
||
372 | * - WDG_ITLine : VIC source 0 |
||
373 | * - SW_ITLine : VIC source 1 |
||
374 | * - ARMRX_ITLine : VIC source 2 |
||
375 | * - ARMTX_ITLine : VIC source 3 |
||
376 | * - TIM0_ITLine : VIC source 4 |
||
377 | * - TIM1_ITLine : VIC source 5 |
||
378 | * - TIM2_ITLine : VIC source 6 |
||
379 | * - TIM3_ITLine : VIC source 7 |
||
380 | * - USBHP_ITLine : VIC source 8 |
||
381 | * - USBLP_ITLine : VIC source 9 |
||
382 | * - SCU_ITLine : VIC source 10 |
||
383 | * - ENET_ITLine : VIC source 11 |
||
384 | * - DMA_ITLine : VIC source 12 |
||
385 | * - CAN_ITLine : VIC source 13 |
||
386 | * - MC_ITLine : VIC source 14 |
||
387 | * - ADC_ITLine : VIC source 15 |
||
388 | * - UART0_ITLine : VIC source 16 |
||
389 | * - UART1_ITLine : VIC source 17 |
||
390 | * - UART2_ITLine : VIC source 18 |
||
391 | * - I2C0_ITLine : VIC source 19 |
||
392 | * - I2C1_ITLine : VIC source 20 |
||
393 | * - SSP0_ITLine : VIC source 21 |
||
394 | * - SSP1_ITLine : VIC source 22 |
||
395 | * - LVD_ITLine : VIC source 23 |
||
396 | * - RTC_ITLine : VIC source 24 |
||
397 | * - WIU_ITLine : VIC source 25 |
||
398 | * - EXTIT0_ITLine: VIC source 26 |
||
399 | * - EXTIT1_ITLine: VIC source 27 |
||
400 | * - EXTIT2_ITLine: VIC source 28 |
||
401 | * - EXTIT3_ITLine: VIC source 29 |
||
402 | * - USBWU_ITLine : VIC source 30 |
||
403 | * - PFQBC_ITLine : VIC source 31 |
||
404 | * Input2 : FMI_NewState: specifies the software interrupt status. |
||
405 | * This parameter can be one of the following values: |
||
406 | * - ENABLE: The software interrupt is enabled. |
||
407 | * - DISABLE: The software interrupt is disabled. |
||
408 | * Output : None |
||
409 | * Return : None |
||
410 | *******************************************************************************/ |
||
411 | void VIC_SWITCmd(u16 VIC_Source, FunctionalState VIC_NewState) |
||
412 | { |
||
413 | u32 VIC_Mask = 1; |
||
414 | |||
415 | if (VIC_NewState == ENABLE) |
||
416 | { |
||
417 | if (VIC_Source < VIC_REGISTER_NUMBER) /* VIC0 */ |
||
418 | VIC0->SWINTR |= (VIC_Mask << VIC_Source); |
||
419 | else /* VIC1 */ |
||
420 | VIC1->SWINTR |= (VIC_Mask << (VIC_Source - VIC_REGISTER_NUMBER)); |
||
421 | } |
||
422 | else /* VIC_NewState == DISABLE */ |
||
423 | { |
||
424 | if (VIC_Source < VIC_REGISTER_NUMBER) /* VIC0 */ |
||
425 | VIC0->SWINTCR = (VIC_Mask << VIC_Source); |
||
426 | else /* VIC1 */ |
||
427 | VIC1->SWINTCR = (VIC_Mask << (VIC_Source - VIC_REGISTER_NUMBER)); |
||
428 | } |
||
429 | } |
||
430 | |||
431 | /******************************************************************************* |
||
432 | * Function Name : VIC_ProtectionCmd |
||
433 | * Description : Enable or Disable the register access protection. |
||
434 | * Input : FMI_NewState: specifies the protection status. |
||
435 | * This parameter can be one of the following values: |
||
436 | * - ENABLE: The protection is enabled. |
||
437 | * - DISABLE: The protection is disabled. |
||
438 | * Output : None |
||
439 | * Return : None |
||
440 | *******************************************************************************/ |
||
441 | void VIC_ProtectionCmd(FunctionalState VIC_NewState) |
||
442 | { |
||
443 | if (VIC_NewState == ENABLE) |
||
444 | { |
||
445 | VIC0->PER |= VIC_PROTECTION_ENABLE_MASK; |
||
446 | VIC1->PER |= VIC_PROTECTION_ENABLE_MASK; |
||
447 | } |
||
448 | else |
||
449 | { |
||
450 | VIC0->PER &= VIC_PROTECTION_DISABLE_MASK; |
||
451 | VIC1->PER &= VIC_PROTECTION_DISABLE_MASK; |
||
452 | } |
||
453 | } |
||
454 | |||
455 | /******************************************************************************* |
||
456 | * Function Name : VIC_GetCurrentISRAdd |
||
457 | * Description : Get the address of the current active ISR. |
||
458 | * Input : VICx: specifies the VIC peripheral |
||
459 | * This parameter can be one of the following values: |
||
460 | * - VIC0: To select VIC0. |
||
461 | * - VIC1: To select VIC1. |
||
462 | * Output : None |
||
463 | * Return : The Address of the active ISR. |
||
464 | *******************************************************************************/ |
||
465 | u32 VIC_GetCurrentISRAdd(VIC_TypeDef* VICx) |
||
466 | { |
||
467 | return VICx->VAR; |
||
468 | } |
||
469 | |||
470 | /******************************************************************************* |
||
471 | * Function Name : VIC_ISRVectAddConfig |
||
472 | * Description : Configuration of the ISR vector address. |
||
473 | * Input1 : VIC_Source: specifies the number of the source line. |
||
474 | * This parameter can be one of the following values: |
||
475 | * - WDG_ITLine : VIC source 0 |
||
476 | * - SW_ITLine : VIC source 1 |
||
477 | * - ARMRX_ITLine : VIC source 2 |
||
478 | * - ARMTX_ITLine : VIC source 3 |
||
479 | * - TIM0_ITLine : VIC source 4 |
||
480 | * - TIM1_ITLine : VIC source 5 |
||
481 | * - TIM2_ITLine : VIC source 6 |
||
482 | * - TIM3_ITLine : VIC source 7 |
||
483 | * - USBHP_ITLine : VIC source 8 |
||
484 | * - USBLP_ITLine : VIC source 9 |
||
485 | * - SCU_ITLine : VIC source 10 |
||
486 | * - ENET_ITLine : VIC source 11 |
||
487 | * - DMA_ITLine : VIC source 12 |
||
488 | * - CAN_ITLine : VIC source 13 |
||
489 | * - MC_ITLine : VIC source 14 |
||
490 | * - ADC_ITLine : VIC source 15 |
||
491 | * - UART0_ITLine : VIC source 16 |
||
492 | * - UART1_ITLine : VIC source 17 |
||
493 | * - UART2_ITLine : VIC source 18 |
||
494 | * - I2C0_ITLine : VIC source 19 |
||
495 | * - I2C1_ITLine : VIC source 20 |
||
496 | * - SSP0_ITLine : VIC source 21 |
||
497 | * - SSP1_ITLine : VIC source 22 |
||
498 | * - LVD_ITLine : VIC source 23 |
||
499 | * - RTC_ITLine : VIC source 24 |
||
500 | * - WIU_ITLine : VIC source 25 |
||
501 | * - EXTIT0_ITLine: VIC source 26 |
||
502 | * - EXTIT1_ITLine: VIC source 27 |
||
503 | * - EXTIT2_ITLine: VIC source 28 |
||
504 | * - EXTIT3_ITLine: VIC source 29 |
||
505 | * - USBWU_ITLine : VIC source 30 |
||
506 | * - PFQBC_ITLine : VIC source 31 |
||
507 | * Input2 : VIC_Priority: specifies the priority of the interrupt. |
||
508 | * It can be a value from 0 to 15. 0 is the highest priority. |
||
509 | * Input3 : void (*VIC_VectAddress)(void): specifies the ISR vector |
||
510 | * address pointer. |
||
511 | * Output : None |
||
512 | * Return : None |
||
513 | *******************************************************************************/ |
||
514 | static void VIC_ISRVectAddConfig(u16 VIC_Source, u16 VIC_Priority, \ |
||
515 | void (*VIC_VectAddress)(void)) |
||
516 | { |
||
517 | if (VIC_Source < VIC_REGISTER_NUMBER) /* VIC0 */ |
||
518 | VIC0->VAiR[VIC_Priority] = (u32)VIC_VectAddress; |
||
519 | else /* VIC1 */ |
||
520 | VIC1->VAiR[VIC_Priority] = (u32)VIC_VectAddress; |
||
521 | } |
||
522 | |||
523 | /******************************************************************************* |
||
524 | * Function Name : VIC_GetISRVectAdd |
||
525 | * Description : Get the ISR vector address of the correspondent line. |
||
526 | * Input : VIC_Source: specifies the number of the source line. |
||
527 | * This parameter can be one of the following values: |
||
528 | * - WDG_ITLine : VIC source 0 |
||
529 | * - SW_ITLine : VIC source 1 |
||
530 | * - ARMRX_ITLine : VIC source 2 |
||
531 | * - ARMTX_ITLine : VIC source 3 |
||
532 | * - TIM0_ITLine : VIC source 4 |
||
533 | * - TIM1_ITLine : VIC source 5 |
||
534 | * - TIM2_ITLine : VIC source 6 |
||
535 | * - TIM3_ITLine : VIC source 7 |
||
536 | * - USBHP_ITLine : VIC source 8 |
||
537 | * - USBLP_ITLine : VIC source 9 |
||
538 | * - SCU_ITLine : VIC source 10 |
||
539 | * - ENET_ITLine : VIC source 11 |
||
540 | * - DMA_ITLine : VIC source 12 |
||
541 | * - CAN_ITLine : VIC source 13 |
||
542 | * - MC_ITLine : VIC source 14 |
||
543 | * - ADC_ITLine : VIC source 15 |
||
544 | * - UART0_ITLine : VIC source 16 |
||
545 | * - UART1_ITLine : VIC source 17 |
||
546 | * - UART2_ITLine : VIC source 18 |
||
547 | * - I2C0_ITLine : VIC source 19 |
||
548 | * - I2C1_ITLine : VIC source 20 |
||
549 | * - SSP0_ITLine : VIC source 21 |
||
550 | * - SSP1_ITLine : VIC source 22 |
||
551 | * - LVD_ITLine : VIC source 23 |
||
552 | * - RTC_ITLine : VIC source 24 |
||
553 | * - WIU_ITLine : VIC source 25 |
||
554 | * - EXTIT0_ITLine: VIC source 26 |
||
555 | * - EXTIT1_ITLine: VIC source 27 |
||
556 | * - EXTIT2_ITLine: VIC source 28 |
||
557 | * - EXTIT3_ITLine: VIC source 29 |
||
558 | * - USBWU_ITLine : VIC source 30 |
||
559 | * - PFQBC_ITLine : VIC source 31 |
||
560 | * Output : None |
||
561 | * Return : The correspondent ISR vector address. |
||
562 | *******************************************************************************/ |
||
563 | u32 VIC_GetISRVectAdd(u16 VIC_Source) |
||
564 | { |
||
565 | if (VIC_Source < VIC_REGISTER_NUMBER) /* VIC0 */ |
||
566 | return VIC0->VAiR[VIC_Source]; |
||
567 | else /* VIC1 */ |
||
568 | return VIC1->VAiR[VIC_Source - VIC_REGISTER_NUMBER]; |
||
569 | } |
||
570 | |||
571 | /******************************************************************************* |
||
572 | * Function Name : VIC_VectEnableConfig |
||
573 | * Description : Enable the vector interrupt. |
||
574 | * Input1 : VIC_Source: specifies the number of the source line. |
||
575 | * This parameter can be one of the following values: |
||
576 | * - WDG_ITLine : VIC source 0 |
||
577 | * - SW_ITLine : VIC source 1 |
||
578 | * - ARMRX_ITLine : VIC source 2 |
||
579 | * - ARMTX_ITLine : VIC source 3 |
||
580 | * - TIM0_ITLine : VIC source 4 |
||
581 | * - TIM1_ITLine : VIC source 5 |
||
582 | * - TIM2_ITLine : VIC source 6 |
||
583 | * - TIM3_ITLine : VIC source 7 |
||
584 | * - USBHP_ITLine : VIC source 8 |
||
585 | * - USBLP_ITLine : VIC source 9 |
||
586 | * - SCU_ITLine : VIC source 10 |
||
587 | * - ENET_ITLine : VIC source 11 |
||
588 | * - DMA_ITLine : VIC source 12 |
||
589 | * - CAN_ITLine : VIC source 13 |
||
590 | * - MC_ITLine : VIC source 14 |
||
591 | * - ADC_ITLine : VIC source 15 |
||
592 | * - UART0_ITLine : VIC source 16 |
||
593 | * - UART1_ITLine : VIC source 17 |
||
594 | * - UART2_ITLine : VIC source 18 |
||
595 | * - I2C0_ITLine : VIC source 19 |
||
596 | * - I2C1_ITLine : VIC source 20 |
||
597 | * - SSP0_ITLine : VIC source 21 |
||
598 | * - SSP1_ITLine : VIC source 22 |
||
599 | * - LVD_ITLine : VIC source 23 |
||
600 | * - RTC_ITLine : VIC source 24 |
||
601 | * - WIU_ITLine : VIC source 25 |
||
602 | * - EXTIT0_ITLine: VIC source 26 |
||
603 | * - EXTIT1_ITLine: VIC source 27 |
||
604 | * - EXTIT2_ITLine: VIC source 28 |
||
605 | * - EXTIT3_ITLine: VIC source 29 |
||
606 | * - USBWU_ITLine : VIC source 30 |
||
607 | * - PFQBC_ITLine : VIC source 31 |
||
608 | * Input2 : VIC_Priority: specifies the priority of the interrupt. |
||
609 | * It can be a value from 0 to 15. 0 is the highest priority. |
||
610 | * Output : None |
||
611 | * Return : None |
||
612 | *******************************************************************************/ |
||
613 | static void VIC_VectEnableConfig(u16 VIC_Source, u16 VIC_Priority) |
||
614 | { |
||
615 | if (VIC_Source < VIC_REGISTER_NUMBER) /* VIC0 */ |
||
616 | VIC0->VCiR[VIC_Priority] |= VIC_VECTOR_ENABLE_MASK; |
||
617 | else /* VIC1 */ |
||
618 | VIC1->VCiR[VIC_Priority] |= VIC_VECTOR_ENABLE_MASK; |
||
619 | } |
||
620 | |||
621 | /******************************************************************************* |
||
622 | * Function Name : VIC_ITSourceConfig |
||
623 | * Description : Select the interrupt source. |
||
624 | * Input1 : VIC_Source: specifies the number of the source line. |
||
625 | * This parameter can be one of the following values: |
||
626 | * - WDG_ITLine : VIC source 0 |
||
627 | * - SW_ITLine : VIC source 1 |
||
628 | * - ARMRX_ITLine : VIC source 2 |
||
629 | * - ARMTX_ITLine : VIC source 3 |
||
630 | * - TIM0_ITLine : VIC source 4 |
||
631 | * - TIM1_ITLine : VIC source 5 |
||
632 | * - TIM2_ITLine : VIC source 6 |
||
633 | * - TIM3_ITLine : VIC source 7 |
||
634 | * - USBHP_ITLine : VIC source 8 |
||
635 | * - USBLP_ITLine : VIC source 9 |
||
636 | * - SCU_ITLine : VIC source 10 |
||
637 | * - ENET_ITLine : VIC source 11 |
||
638 | * - DMA_ITLine : VIC source 12 |
||
639 | * - CAN_ITLine : VIC source 13 |
||
640 | * - MC_ITLine : VIC source 14 |
||
641 | * - ADC_ITLine : VIC source 15 |
||
642 | * - UART0_ITLine : VIC source 16 |
||
643 | * - UART1_ITLine : VIC source 17 |
||
644 | * - UART2_ITLine : VIC source 18 |
||
645 | * - I2C0_ITLine : VIC source 19 |
||
646 | * - I2C1_ITLine : VIC source 20 |
||
647 | * - SSP0_ITLine : VIC source 21 |
||
648 | * - SSP1_ITLine : VIC source 22 |
||
649 | * - LVD_ITLine : VIC source 23 |
||
650 | * - RTC_ITLine : VIC source 24 |
||
651 | * - WIU_ITLine : VIC source 25 |
||
652 | * - EXTIT0_ITLine: VIC source 26 |
||
653 | * - EXTIT1_ITLine: VIC source 27 |
||
654 | * - EXTIT2_ITLine: VIC source 28 |
||
655 | * - EXTIT3_ITLine: VIC source 29 |
||
656 | * - USBWU_ITLine : VIC source 30 |
||
657 | * - PFQBC_ITLine : VIC source 31 |
||
658 | * Input2 : VIC_Priority: specifies the priority of the interrupt. |
||
659 | * It can be a value from 0 to 15. 0 is the highest priority. |
||
660 | * Output : None |
||
661 | * Return : None |
||
662 | *******************************************************************************/ |
||
663 | static void VIC_ITSourceConfig(u16 VIC_Source, u16 VIC_Priority) |
||
664 | { |
||
665 | if (VIC_Source < VIC_REGISTER_NUMBER) /* VIC0 */ |
||
666 | { |
||
667 | VIC0->VCiR[VIC_Priority] &= VIC_IT_SOURCE_MASK; |
||
668 | VIC0->VCiR[VIC_Priority] |= VIC_Source; |
||
669 | } |
||
670 | else /* VIC1 */ |
||
671 | { |
||
672 | VIC1->VCiR[VIC_Priority] &= VIC_IT_SOURCE_MASK; |
||
673 | VIC1->VCiR[VIC_Priority] |= VIC_Source - VIC_REGISTER_NUMBER; |
||
674 | } |
||
675 | } |
||
676 | |||
677 | /******************************************************************************* |
||
678 | * Function Name : VIC_Config |
||
679 | * Description : Configure the ISR, the line, the mode and the priority for |
||
680 | * each interrupt source line. |
||
681 | * Input1 : VIC_Source: specifies the number of the source line. |
||
682 | * This parameter can be one of the following values: |
||
683 | * - WDG_ITLine : VIC source 0 |
||
684 | * - SW_ITLine : VIC source 1 |
||
685 | * - ARMRX_ITLine : VIC source 2 |
||
686 | * - ARMTX_ITLine : VIC source 3 |
||
687 | * - TIM0_ITLine : VIC source 4 |
||
688 | * - TIM1_ITLine : VIC source 5 |
||
689 | * - TIM2_ITLine : VIC source 6 |
||
690 | * - TIM3_ITLine : VIC source 7 |
||
691 | * - USBHP_ITLine : VIC source 8 |
||
692 | * - USBLP_ITLine : VIC source 9 |
||
693 | * - SCU_ITLine : VIC source 10 |
||
694 | * - ENET_ITLine : VIC source 11 |
||
695 | * - DMA_ITLine : VIC source 12 |
||
696 | * - CAN_ITLine : VIC source 13 |
||
697 | * - MC_ITLine : VIC source 14 |
||
698 | * - ADC_ITLine : VIC source 15 |
||
699 | * - UART0_ITLine : VIC source 16 |
||
700 | * - UART1_ITLine : VIC source 17 |
||
701 | * - UART2_ITLine : VIC source 18 |
||
702 | * - I2C0_ITLine : VIC source 19 |
||
703 | * - I2C1_ITLine : VIC source 20 |
||
704 | * - SSP0_ITLine : VIC source 21 |
||
705 | * - SSP1_ITLine : VIC source 22 |
||
706 | * - LVD_ITLine : VIC source 23 |
||
707 | * - RTC_ITLine : VIC source 24 |
||
708 | * - WIU_ITLine : VIC source 25 |
||
709 | * - EXTIT0_ITLine: VIC source 26 |
||
710 | * - EXTIT1_ITLine: VIC source 27 |
||
711 | * - EXTIT2_ITLine: VIC source 28 |
||
712 | * - EXTIT3_ITLine: VIC source 29 |
||
713 | * - USBWU_ITLine : VIC source 30 |
||
714 | * - PFQBC_ITLine : VIC source 31 |
||
715 | * Input2 : VIC_LineMode :specifies the type of interrupt of the source |
||
716 | * line. This parameter can be one of the following values: |
||
717 | * - VIC_IRQ: the correspondent line is configured as IRQ. |
||
718 | * - VIC_FIQ: the correspondent line is configured as FIQ. |
||
719 | * Input3 : VIC_Priority: specifies the priority of the interrupt. |
||
720 | * It can be a value from 0 to 15. 0 is the highest priority. |
||
721 | * Output : None |
||
722 | * Return : None |
||
723 | *******************************************************************************/ |
||
724 | void VIC_Config(u16 VIC_Source, VIC_ITLineMode VIC_LineMode, u8 VIC_Priority) |
||
725 | { |
||
726 | switch (VIC_Source) |
||
727 | { |
||
728 | case 0: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, WDG_IRQHandler); |
||
729 | break; |
||
730 | |||
731 | case 1: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, SW_IRQHandler); |
||
732 | break; |
||
733 | |||
734 | case 2: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, ARMRX_IRQHandler); |
||
735 | break; |
||
736 | |||
737 | case 3: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, ARMTX_IRQHandler); |
||
738 | break; |
||
739 | |||
740 | case 4: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, TIM0_IRQHandler); |
||
741 | break; |
||
742 | |||
743 | case 5: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, TIM1_IRQHandler); |
||
744 | break; |
||
745 | |||
746 | case 6: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, TIM2_IRQHandler); |
||
747 | break; |
||
748 | |||
749 | case 7: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, TIM3_IRQHandler); |
||
750 | break; |
||
751 | |||
752 | case 8: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, USBHP_IRQHandler); |
||
753 | break; |
||
754 | |||
755 | case 9: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, USBLP_IRQHandler); |
||
756 | break; |
||
757 | |||
758 | case 10: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, SCU_IRQHandler); |
||
759 | break; |
||
760 | |||
761 | case 11: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, ENET_IRQHandler); |
||
762 | break; |
||
763 | |||
764 | case 12: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, DMA_IRQHandler); |
||
765 | break; |
||
766 | |||
767 | case 13: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, CAN_IRQHandler); |
||
768 | break; |
||
769 | |||
770 | case 14: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, MC_IRQHandler); |
||
771 | break; |
||
772 | |||
773 | case 15: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, ADC_IRQHandler); |
||
774 | break; |
||
775 | |||
776 | case 16: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, UART0_IRQHandler); |
||
777 | break; |
||
778 | |||
779 | case 17: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, UART1_IRQHandler); |
||
780 | break; |
||
781 | |||
782 | case 18: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, UART2_IRQHandler); |
||
783 | break; |
||
784 | |||
785 | case 19: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, I2C0_IRQHandler); |
||
786 | break; |
||
787 | |||
788 | case 20: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, I2C1_IRQHandler); |
||
789 | break; |
||
790 | |||
791 | case 21: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, SSP0_IRQHandler); |
||
792 | break; |
||
793 | |||
794 | case 22: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, SSP1_IRQHandler); |
||
795 | break; |
||
796 | |||
797 | case 23: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, LVD_IRQHandler); |
||
798 | break; |
||
799 | |||
800 | case 24: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, RTC_IRQHandler); |
||
801 | break; |
||
802 | |||
803 | case 25: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, WIU_IRQHandler); |
||
804 | break; |
||
805 | |||
806 | case 26: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, EXTIT0_IRQHandler); |
||
807 | break; |
||
808 | |||
809 | case 27: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, EXTIT1_IRQHandler); |
||
810 | break; |
||
811 | |||
812 | case 28: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, EXTIT2_IRQHandler); |
||
813 | break; |
||
814 | |||
815 | case 29: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, EXTIT3_IRQHandler); |
||
816 | break; |
||
817 | |||
818 | case 30: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, USBWU_IRQHandler); |
||
819 | break; |
||
820 | |||
821 | case 31: VIC_ISRVectAddConfig(VIC_Source, VIC_Priority, PFQBC_IRQHandler); |
||
822 | break; |
||
823 | |||
824 | default: break; |
||
825 | } |
||
826 | VIC_ITModeConfig(VIC_Source, VIC_LineMode); |
||
827 | VIC_VectEnableConfig(VIC_Source, VIC_Priority); |
||
828 | VIC_ITSourceConfig(VIC_Source, VIC_Priority); |
||
829 | } |
||
830 | |||
831 | /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/ |