iLLD_TC27xC  1.0
IfxCpu_Irq.c
Go to the documentation of this file.
1 /**
2  * \file IfxCpu_Irq.c
3  * \brief This file contains the APIs for Interrupt related functions.
4  *
5  *
6  * \version iLLD_0_1_0_10
7  * \copyright Copyright (c) 2012 Infineon Technologies AG. All rights reserved.
8  *
9  *
10  * IMPORTANT NOTICE
11  *
12  *
13  * Infineon Technologies AG (Infineon) is supplying this file for use
14  * exclusively with Infineon's microcontroller products. This file can be freely
15  * distributed within development tools that are supporting such microcontroller
16  * products.
17  *
18  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23  *
24  *
25  */
26 
27 /*******************************************************************************
28 ** Includes **
29 *******************************************************************************/
30 #include "Cpu/Irq/IfxCpu_Irq.h"
33 #include "IfxCpu_reg.h"
34 
35 /*******************************************************************************
36 ** Private macros **
37 *******************************************************************************/
38 
39 /*******************************************************************************
40 ** Global variables/constants **
41 *******************************************************************************/
42 #if defined(IFX_USE_SW_MANAGED_INT)
43 
44 typedef void (*Ifx_Isr)(void);
45 
46 static Ifx_Isr IfxCpu_Irq_swIntVector[256];
47 
48 #endif /*defined(IFX_USE_SW_MANAGED_INT) */
49 
50 /*******************************************************************************
51 ** Global Function definitions **
52 *******************************************************************************/
53 #if defined(IFX_USE_SW_MANAGED_INT)
54 
55 /** \brief Macro to abstract compilers for the pre interrupt service routine instructions.
56  *
57  */
58 IFX_INLINE void IfxCpu_Irq_preIsrCall(void)
59 {
60 #if defined(__DCC__)
61 /*__svlcx(); is introduced by Windriver automatically*/
62 
63 #elif defined(__GNUC__)
64  __svlcx();
65 
66 #elif defined(__TASKING__)
67  __svlcx();
68 
69 #else
70 #error Compiler unsupported
71 #endif
72 }
73 
74 
75 /** \brief Macro to abstract compilers for the post interrupt service routine instructions.
76  *
77  */
78 IFX_INLINE void IfxCpu_Irq_postIsrCall(void)
79 {
80 #if defined(__DCC__)
81  /*__rslcx();; is introduced by DCC automatically*/
82 
83 #elif defined(__GNUC__)
84  /*__rslcx();; is introduced by GCC automatically*/
85 
86 #elif defined(__TASKING__)
87  __rslcx();
88 
89 #else
90 #error Compiler unsupported
91 #endif
92 }
93 
94 
95 /** \brief API to install the interrupt service routine for Software Managed Interrupts.
96  *
97  */
98 void IfxCpu_Irq_installInterruptHandler(void *isrFuncPointer, uint32 serviceReqPrioNumber)
99 {
100  IfxCpu_Irq_swIntVector[serviceReqPrioNumber] = (Ifx_Isr)isrFuncPointer;
101 }
102 
103 
104 /** SW managed Interrupt vector table
105  *
106  * This is vector table with single entry for Software Managed Interrupts.
107  * This function need to be located at boundary 0xXFE0 where (X=1,3,5 and so on). For the software managed
108  * interrupts to work correctly, the BIV must be set to address of this function.
109  *
110  */
111 #if defined(__DCC__)
112 #define IFXCPU_IRQ_INT_ATTRIBUTE __interrupt__ void
113 #pragma section CODE ".intvec_tc0_255" far-absolute X
114 
115 #elif defined(__GNUC__)
116 #define IFXCPU_IRQ_INT_ATTRIBUTE void /*Nothing else required to define this attribute */
117 void __attribute__ ((interrupt_handler)) IfxCpu_Irq_intVecTable();
118 #pragma section ".intvec_tc0_255" x
119 
120 #elif defined(__TASKING__)
121 #define IFXCPU_IRQ_INT_ATTRIBUTE void __interrupt(255) __vector_table(0)
122 #else
123 #error Compiler unsupported
124 #endif
125 
126 IFXCPU_IRQ_INT_ATTRIBUTE IfxCpu_Irq_intVecTable(void)
127 {
128  Ifx_CPU_ICR icr;
129 
130  IfxCpu_Irq_preIsrCall(); /*call svlcx if required explicitly, for compiler used */
131 
132  icr.U = __mfcr(CPU_ICR); /*Fetch the ICR value */
133 
134  /*Call the ISR */
135  IfxCpu_Irq_swIntVector[icr.B.CCPN]();
136 
137  IfxCpu_Irq_postIsrCall(); /*call rslcx if required explicitly, for compiler used */
138 }
139 
140 
141 /*reset the pragma sections */
142 #if defined(__DCC__)
143 #pragma section CODE X
144 #elif defined(__GNUC__)
145 #pragma section
146 #elif defined(__TASKING__)
147 /*No user section defined */
148 #else
149 #error Compiler unsupported
150 #endif /*defined(__TASKING__) */
151 
152 #endif /*defined(IFX_USE_SW_MANAGED_INT) */