diff options
Diffstat (limited to 'lib/chibios/os/hal/ports/LPC/LPC214x/vic.c')
-rw-r--r-- | lib/chibios/os/hal/ports/LPC/LPC214x/vic.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/LPC/LPC214x/vic.c b/lib/chibios/os/hal/ports/LPC/LPC214x/vic.c new file mode 100644 index 000000000..9a2fa2be1 --- /dev/null +++ b/lib/chibios/os/hal/ports/LPC/LPC214x/vic.c | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file LPC214x/vic.c | ||
19 | * @brief LPC214x VIC peripheral support code. | ||
20 | * | ||
21 | * @addtogroup LPC214x_VIC | ||
22 | * @{ | ||
23 | */ | ||
24 | |||
25 | #include "hal.h" | ||
26 | |||
27 | /** | ||
28 | * @brief VIC Initialization. | ||
29 | * @note Better reset everything in the VIC, it is a HUGE source of trouble. | ||
30 | * | ||
31 | * @notapi | ||
32 | */ | ||
33 | void vic_init(void) { | ||
34 | int i; | ||
35 | |||
36 | VIC *vic = VICBase; | ||
37 | vic->VIC_IntSelect = 0; /* All sources assigned to IRQ. */ | ||
38 | vic->VIC_SoftIntClear = ALLINTMASK; /* No interrupts enforced */ | ||
39 | vic->VIC_IntEnClear = ALLINTMASK; /* All sources disabled. */ | ||
40 | for (i = 0; i < 16; i++) { | ||
41 | vic->VIC_VectCntls[i] = 0; | ||
42 | vic->VIC_VectAddrs[i] = 0; | ||
43 | vic->VIC_VectAddr = 0; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * @brief Initializes a VIC vector. | ||
49 | * @details Set a vector for an interrupt source and enables it. | ||
50 | * | ||
51 | * @param[in] handler the pointer to the IRQ service routine | ||
52 | * @param[in] vector the vector number | ||
53 | * @param[in] source the IRQ source to be associated to the vector | ||
54 | * | ||
55 | * @api | ||
56 | */ | ||
57 | void SetVICVector(void *handler, int vector, int source) { | ||
58 | |||
59 | VIC *vicp = VICBase; | ||
60 | vicp->VIC_VectAddrs[vector] = (IOREG32)handler; | ||
61 | vicp->VIC_VectCntls[vector] = (IOREG32)(source | 0x20); | ||
62 | } | ||
63 | |||
64 | /** @} */ | ||