]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/edma3_lld.git/blob - packages/ti/sdo/edma3/rm/sample/src/platforms/sample_am335x_arm_int_reg.c
fixed build warning
[keystone-rtos/edma3_lld.git] / packages / ti / sdo / edma3 / rm / sample / src / platforms / sample_am335x_arm_int_reg.c
1 /*
2  * sample_am335x_arm_int_reg.c 
3  *
4  * Platform specific interrupt registration and un-registration routines.
5  *
6  * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
7  *
8  *
9  *  Redistribution and use in source and binary forms, with or without
10  *  modification, are permitted provided that the following conditions
11  *  are met:
12  *
13  *    Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  *
16  *    Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the
19  *    distribution.
20  *
21  *    Neither the name of Texas Instruments Incorporated nor the names of
22  *    its contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37 */
39 #include <ti/sysbios/knl/Semaphore.h>
41 #include <ti/sysbios/hal/Hwi.h>
42 #include <xdc/runtime/Error.h>
43 #include <xdc/runtime/System.h>
45 #include <ti/sdo/edma3/rm/sample/bios6_edma3_rm_sample.h>
47 // #include <stdio.h>
48 /**
49   * EDMA3 TC ISRs which need to be registered with the underlying OS by the user
50   * (Not all TC error ISRs need to be registered, register only for the
51   * available Transfer Controllers).
52   */
53 void (*ptrEdma3TcIsrHandler[EDMA3_MAX_TC])(uint32_t arg) =
54                                                 {
55                                                 &lisrEdma3TC0ErrHandler0,
56                                                 &lisrEdma3TC1ErrHandler0,
57                                                 &lisrEdma3TC2ErrHandler0,
58                                                 &lisrEdma3TC3ErrHandler0,
59                                                 &lisrEdma3TC4ErrHandler0,
60                                                 &lisrEdma3TC5ErrHandler0,
61                                                 &lisrEdma3TC6ErrHandler0,
62                                                 &lisrEdma3TC7ErrHandler0,
63                                                 };
65 extern uint32_t ccXferCompInt[][EDMA3_MAX_REGIONS];
66 extern uint32_t ccErrorInt[];
67 extern uint32_t tcErrorInt[][EDMA3_MAX_TC];
68 extern uint32_t numEdma3Tc[];
70 /**
71  * Variables which will be used internally for referring the hardware interrupt
72  * for various EDMA3 interrupts.
73  */
74 extern uint32_t hwIntXferComp;
75 extern uint32_t hwIntCcErr;
76 extern uint32_t hwIntTcErr;
78 extern uint32_t dsp_num;
79 /* This variable has to be used as an extern */
80 //uint32_t gpp_num = 4;
82 Hwi_Handle hwiCCXferCompInt;
83 Hwi_Handle hwiCCErrInt;
84 Hwi_Handle hwiTCErrInt[EDMA3_MAX_TC];
86 /**  To Register the ISRs with the underlying OS, if required. */
87 void registerEdma3Interrupts (uint32_t edma3Id)
88     {
89     static UInt32 cookie = 0;
90 //#ifdef BUILD_NETRA_A8
91     uint32_t numTc = 0;
92 //#endif
93     Hwi_Params hwiParams; 
94     Error_Block      eb;
96     /* Initialize the Error Block                                             */
97     Error_init(&eb);
98         
99     /* Disabling the global interrupts */
100     cookie = Hwi_disable();
102     /* Initialize the HWI parameters with user specified values */
103     Hwi_Params_init(&hwiParams);
104     
105     /* argument for the ISR */
106     hwiParams.arg = edma3Id;
107         /* set the priority ID     */
108         //hwiParams.priority = hwIntXferComp;
109         //hwiParams.enableInt = TRUE;
110     
111     hwiCCXferCompInt = Hwi_create( ccXferCompInt[edma3Id][dsp_num],
112                             ((Hwi_FuncPtr)&lisrEdma3ComplHandler0),
113                             (const Hwi_Params *) (&hwiParams),
114                             &eb);
115     if (TRUE == Error_check(&eb))
116     {
117         System_printf("HWI Create Failed\n",Error_getCode(&eb));
118     }
121 //#ifdef BUILD_NETRA_A8
122     /* Initialize the HWI parameters with user specified values */
123     Hwi_Params_init(&hwiParams);
124     /* argument for the ISR */
125     hwiParams.arg = edma3Id;
126         /* set the priority ID     */
127         hwiParams.priority = hwIntCcErr;
128         //hwiParams.enableInt = TRUE;
129         
130         hwiCCErrInt = Hwi_create( ccErrorInt[edma3Id],
131                 ((Hwi_FuncPtr)&lisrEdma3CCErrHandler0),
132                 (const Hwi_Params *) (&hwiParams),
133                 &eb);
135     if (TRUE == Error_check(&eb))
136     {
137         System_printf("HWI Create Failed\n",Error_getCode(&eb));
138     }
140     while (numTc < numEdma3Tc[edma3Id])
141             {
142         /* Initialize the HWI parameters with user specified values */
143         Hwi_Params_init(&hwiParams);
144         /* argument for the ISR */
145         hwiParams.arg = edma3Id;
146         /* set the priority ID     */
147         hwiParams.priority = hwIntTcErr;
148                 //hwiParams.enableInt = TRUE;
149         
150         hwiTCErrInt[numTc] = Hwi_create( tcErrorInt[edma3Id][numTc],
151                     ((Hwi_FuncPtr)ptrEdma3TcIsrHandler[numTc]),
152                     (const Hwi_Params *) (&hwiParams),
153                     &eb);
154         if (TRUE == Error_check(&eb))
155         {
156             System_printf("HWI Create Failed\n",Error_getCode(&eb));
157         }
158         numTc++;
159         }
160    /**
161     * Enabling the HWI_ID.
162     * EDMA3 interrupts (transfer completion, CC error etc.)
163     * correspond to different ECM events (SoC specific). These ECM events come
164     * under ECM block XXX (handling those specific ECM events). Normally, block
165     * 0 handles events 4-31 (events 0-3 are reserved), block 1 handles events
166     * 32-63 and so on. This ECM block XXX (or interrupt selection number XXX)
167     * is mapped to a specific HWI_INT YYY in the tcf file. So to enable this
168     * mapped HWI_INT YYY, one should use the corresponding bitmask in the
169     * API C64_enableIER(), in which the YYY bit is SET.
170     */
171     Hwi_enableInterrupt(ccErrorInt[edma3Id]);
172     Hwi_enableInterrupt(ccXferCompInt[edma3Id][dsp_num]);
173     numTc = 0;
174     while (numTc < numEdma3Tc[edma3Id])
175             {
176         Hwi_enableInterrupt(tcErrorInt[edma3Id][numTc]);
177         numTc++;
178         }
179                 
180 //      #endif
182     /* Restore interrupts */
183     Hwi_restore(cookie);
184     }
186 /**  To Unregister the ISRs with the underlying OS, if previously registered. */
187 void unregisterEdma3Interrupts (uint32_t edma3Id)
188     {
189         static UInt32 cookie = 0;
190     uint32_t numTc = 0;
192     /* Disabling the global interrupts */
193     cookie = Hwi_disable();
195     Hwi_delete(&hwiCCXferCompInt);
196     Hwi_delete(&hwiCCErrInt);
197     while (numTc < numEdma3Tc[edma3Id])
198             {
199         Hwi_delete(&hwiTCErrInt[numTc]);
200         numTc++;
201         }
202     /* Restore interrupts */
203     Hwi_restore(cookie);
204     }