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