iLLD_TC27xC  1.0
IfxSrc.h
Go to the documentation of this file.
1 /**
2  * \file IfxSrc.h
3  * \brief SRC basic functionality
4  * \ingroup IfxLld_Src
5  *
6  * \version iLLD_0_1_0_10
7  * \copyright Copyright (c) 2013 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  * \defgroup IfxLld_Src SRC
25  * \addtogroup IfxLld_Src
26  * \{
27  * \defgroup IfxLld_Src_Usage How to use Service Request Mechanism?
28  * \addtogroup IfxLld_Src_Usage
29  * \{
30  *
31  * For Aurix controller peripherals that can generate service requests is connected to one
32  * or more Service Request Nodes (SRNs) in the central Interrupt Router(IR) module. Refer to Controller User Manual for more details\n
33  *
34  * IfxSrc driver provides the APIs to configure and control service requests. Refer \ref IfxLld_Src_Usage for
35  * details of these APIs.
36  *
37  *
38  * \section Ifx_Src_UsageInit Initialize the Service Request Node
39  *
40  * Service request node is initialized to configure the following,\n
41  * 1) Route the interrupt trigger to service provider, which are:\n
42  * __a. One of the available CPUs or\n
43  * __b. DMA controller\n
44  *
45  * 2) Priority of CPU Interrupt or DMA Trigger.
46  *
47  * For Interrupt or DMA to be correctly triggered, following steps are to be done in the user code:
48  *
49  * \subsection Ifx_Src_UsageInitStep1 Step1: Configure the Node
50  *
51  * User must configure the service request node in the application / driver files.
52  *
53  * \subsection Ifx_Src_UsageInitStep2 Step2: Enable the Trigger
54  *
55  * Enable the service request node to connect the trigger event from the hardware to service provider.
56  *
57  * Example:
58  * Following example show the configuration for STM0 Service request 0 trigger configured to trigger
59  * CPU1 with the priority specified by IFX_INTPRIO_STM0 (from the example at IfxCpu_Irq)
60  *
61  * \code
62  * //file: myApplication.c
63  *
64  * #include "Ifx_IntPrioDef.h" // to get the priority numbers
65  *
66  * void myDriverInitFunction(void)
67  * {
68  * // driver init code
69  *
70  * // Step1: Call the function to route the trigger from for SRC_STM0_SR0 to CPU1
71  * // and priority specified at Ifx_IntPrioDef.h globally
72  * IfxSrc_init(&MODULE_SRC.STM.STM[0].SR[0], IfxSrc_Tos_cpu1, IFX_INTPRIO_STM0);
73  *
74  * // Step2: Enable the service request node
75  * IfxSrc_enable(&MODULE_SRC.STM.STM[0].SR[0]);
76  * }
77  * \endcode
78  *
79  * \}
80  * \}
81  *
82  * \defgroup IfxLld_Src SRC
83  * \ingroup IfxLld
84  * \defgroup IfxLld_Src_Std Standard Driver
85  * \ingroup IfxLld_Src
86  * \defgroup IfxLld_Src_Std_Service_Request Service Request Functions
87  * \ingroup IfxLld_Src_Std
88  * \defgroup IfxLld_Src_Std_Module Module Functions
89  * \ingroup IfxLld_Src_Std
90  */
91 
92 #ifndef IFXSRC_H
93 #define IFXSRC_H 1
94 
95 /******************************************************************************/
96 /*----------------------------------Includes----------------------------------*/
97 /******************************************************************************/
98 
99 #include "_Impl/IfxSrc_cfg.h"
100 /** \addtogroup IfxLld_Src_Std_Service_Request
101  * \{ */
102 
103 /******************************************************************************/
104 /*-------------------------Inline Function Prototypes-------------------------*/
105 /******************************************************************************/
106 
107 /** \brief Resets the overrun flag of the Service Request.
108  * \param src pointer to the Service Request Control register which the overrun flag should be cleared.
109  * \return None
110  *
111  * Usage example: see \ref IfxSrc_init
112  *
113  */
114 IFX_INLINE void IfxSrc_clearOverrun(volatile Ifx_SRC_SRCR *src);
115 
116 /** \brief Resets a specific interrupt service by software.
117  * \param src pointer to the Service Request Control register which the request should be cleared.
118  * \return None
119  *
120  * Usage example: see \ref IfxSrc_init
121  *
122  */
123 IFX_INLINE void IfxSrc_clearRequest(volatile Ifx_SRC_SRCR *src);
124 
125 /** \brief Gets the current overrun status.
126  * \param src pointer to the Service Request Control register for which the overrun status should be returned.
127  * \return current service request control overrun status.
128  *
129  * Usage example: see \ref IfxSrc_init
130  *
131  */
132 IFX_INLINE boolean IfxSrc_isOverrun(volatile Ifx_SRC_SRCR *src);
133 
134 /** \brief Gets the current request status.
135  * \param src pointer to the Service Request Control register for which the request status should be returned.
136  * \return current service request control request status.
137  *
138  * Usage example: see \ref IfxSrc_init
139  *
140  */
141 IFX_INLINE boolean IfxSrc_isRequested(volatile Ifx_SRC_SRCR *src);
142 
143 /** \brief Requests a specific interrupt service by software
144  * \param src pointer to the Service Request Control register which the interrupt has to be requested.
145  * \return None
146  *
147  * Usage example: see \ref IfxSrc_init
148  *
149  */
150 IFX_INLINE void IfxSrc_setRequest(volatile Ifx_SRC_SRCR *src);
151 
152 /** \} */
153 
154 /** \addtogroup IfxLld_Src_Std_Module
155  * \{ */
156 
157 /******************************************************************************/
158 /*-------------------------Inline Function Prototypes-------------------------*/
159 /******************************************************************************/
160 
161 /** \brief DeInitializes the service request control register.
162  * \param src pointer to the Service Request Control register which should be deinitialised.
163  * \return None
164  *
165  * Usage example: see \ref IfxSrc_init
166  *
167  */
168 IFX_INLINE void IfxSrc_deinit(volatile Ifx_SRC_SRCR *src);
169 
170 /** \brief Disables a specific interrupt service request.
171  * \param src pointer to the Service Request Control register for which the interrupt has to be disabled.
172  * \return None
173  *
174  * Usage example: see \ref IfxSrc_init
175  *
176  */
177 IFX_INLINE void IfxSrc_disable(volatile Ifx_SRC_SRCR *src);
178 
179 /** \brief Enables a specific interrupt service request.
180  * \param src pointer to the Service Request Control register for which the interrupt has to be enabled.
181  * \return None
182  *
183  * Usage example: see \ref IfxSrc_init
184  *
185  */
186 IFX_INLINE void IfxSrc_enable(volatile Ifx_SRC_SRCR *src);
187 
188 /** \brief Initializes the service request control register.
189  * \param src pointer to the Service Request Control register which should be initialised.
190  * \param typOfService type of interrupt service provider.
191  * \param priority Interrupt priority.
192  * \return None
193  *
194  * Get the peripheral service control register which request need to be serviced and assign this service to any of service providers.
195  * \code
196  * //define the interrupt priority
197  * #define IFXASCLIN0_TX_INTPRIO 2
198  * //get the service request
199  * volatile Ifx_SRC_SRCR *src = IfxAsclin_getSrcPointerRx( &MODULE_ASCLIN0 );
200  * //initlaise the service request
201  * IfxSrc_init( src, IfxSrc_Tos_cpu0, IFXASCLIN0_TX_INTPRIO );
202  * // enable the service
203  * IfxSrc_enable( src );
204  * //check for service request flags and clear if they occur
205  * if ( IfxSrc_isRequested( src ) == TRUE )
206  * {
207  * IfxSrc_clearRequest( src );
208  * }
209  * if ( IfxSrc_isOverrun( src ) == TRUE )
210  * {
211  * IfxSrc_clearOverrun( src );
212  * }
213  * // Atlast deinitialise the service control
214  * IfxSrc_deinit( src );
215  * \endcode
216  *
217  */
218 IFX_INLINE void IfxSrc_init(volatile Ifx_SRC_SRCR *src, IfxSrc_Tos typOfService, Ifx_Priority priority);
219 
220 /** \} */
221 
222 /******************************************************************************/
223 /*---------------------Inline Function Implementations------------------------*/
224 /******************************************************************************/
225 
226 IFX_INLINE void IfxSrc_clearOverrun(volatile Ifx_SRC_SRCR *src)
227 {
228  src->B.IOVCLR = 1;
229 }
230 
231 
232 IFX_INLINE void IfxSrc_clearRequest(volatile Ifx_SRC_SRCR *src)
233 {
234  src->B.CLRR = 1;
235 }
236 
237 
238 IFX_INLINE boolean IfxSrc_isOverrun(volatile Ifx_SRC_SRCR *src)
239 {
240  return src->B.IOV ? TRUE : FALSE;
241 }
242 
243 
244 IFX_INLINE boolean IfxSrc_isRequested(volatile Ifx_SRC_SRCR *src)
245 {
246  return src->B.SRR ? TRUE : FALSE;
247 }
248 
249 
250 IFX_INLINE void IfxSrc_setRequest(volatile Ifx_SRC_SRCR *src)
251 {
252  src->B.SETR = 1;
253 }
254 
255 
256 IFX_INLINE void IfxSrc_deinit(volatile Ifx_SRC_SRCR *src)
257 {
258  src->U = 0;
259 }
260 
261 
262 IFX_INLINE void IfxSrc_disable(volatile Ifx_SRC_SRCR *src)
263 {
264  src->B.SRE = 0;
265 }
266 
267 
268 IFX_INLINE void IfxSrc_enable(volatile Ifx_SRC_SRCR *src)
269 {
270  src->B.SRE = 1;
271 }
272 
273 
274 IFX_INLINE void IfxSrc_init(volatile Ifx_SRC_SRCR *src, IfxSrc_Tos typOfService, Ifx_Priority priority)
275 {
276  src->B.SRPN = priority;
277  src->B.TOS = typOfService;
278  IfxSrc_clearRequest(src);
279 }
280 
281 
282 #endif /* IFXSRC_H */