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