OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM9_STR91X_IAR/] [Library/] [source/] [91x_vic.c] - Blame information for rev 588

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

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

powered by: WebSVN 2.1.0

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