1 /******************************************************************************
2 ** File Name: isr_drvapi.h *
3 ** Author: Xuepeng.Zhang *
5 ** Copyright: 2010 Spreatrum, Incoporated. All Rights Reserved. *
6 ** Description: This file defines the related driver of Interrupt *
7 ******************************************************************************
9 ******************************************************************************
11 ** ------------------------------------------------------------------------- *
12 ** DATE NAME DESCRIPTION *
13 ** 08/08/2010 Xuepeng.Zhang Create *
14 ******************************************************************************/
15 #ifndef _ISR_DRVAPI_H_
16 #define _ISR_DRVAPI_H_
20 /**---------------------------------------------------------------------------*
22 **---------------------------------------------------------------------------*/
37 // ISR function pointer prototype.
38 typedef ISR_EXE_T (* TB_ISR) (uint32);
40 // CallBack function pointer prototype.
41 typedef void (* TB_CALLBACK) (TB_MSG *);
46 #define TB_SUCCESS 0x00
47 #define TB_ISR_NULL 0x01
48 #define TB_NO_CALLBACK 0x02
49 #define TB_CALLBACK_ASSIGNED 0x03
50 #define TB_ISR_ASSIGNED 0x0E
51 #define TB_PTR_ERROR 0x0F
52 #define TB_INT_ERROR 0x10
53 #define TB_PARAM_ERROR 0x20
58 CHIPDRV_HISR_PRIO_0 = SCI_PRIORITY_TIME_CRITICAL, //The highest priority
59 CHIPDRV_HISR_PRIO_1 = SCI_PRIORITY_HIGHEST,
64 typedef void hisr_func_t(uint32 count, void* data);
69 /**---------------------------------------------------------------------------*
71 **---------------------------------------------------------------------------*/
77 /**---------------------------------------------------------------------------*
78 ** Constant Variables *
79 **---------------------------------------------------------------------------*/
81 /*****************************************************************************/
82 // Description: This function should be called at the startup of the
83 // application. It initializes TBIOS interrupt resources.
84 // This must be called before installing an IRQ handler.
85 // Dependency: irq_isr_array
86 // Author: Richard.Yang
88 /*****************************************************************************/
91 /*****************************************************************************/
92 // Description: This function is called when an IRQ happens.
93 // Dependency: irq_isr_array
94 // Author: Richard.Yang
96 /*****************************************************************************/
97 //void ISR_Handler(void);
98 void ISR_HandlerAll (void);
100 /*****************************************************************************/
101 // Description: This function is called to register a new ISR.
102 // Dependency: irq_isr_array
103 // Author: Richard.Yang
104 // Note: If success, the function returns TB_SUCCESS;
105 // if isr_handler is NULL, returns TB_PTR_ERROR;
106 // if int_num is a invalid number, returns TB_INT_ERROR;
107 // if the isr_handler is installed before, returns
109 /*****************************************************************************/
110 uint32 ISR_RegHandler (
111 uint32 int_num, // Interrupt number
112 TB_ISR isr_handler // Interrupt service routine pointer.
115 /*****************************************************************************/
116 // Description: This function is called to register a new ISR and Hisr.
117 // Dependency: irq_isr_array
118 // Author: steve.zhan
119 // Note: If success, the function returns TB_SUCCESS;
120 // if isr_handler is NULL, returns TB_PTR_ERROR;
121 // if int_num is a invalid number, returns TB_INT_ERROR;
122 // if the isr_handler is installed before, returns
124 /*****************************************************************************/
125 uint32 ISR_RegHandler_Ex (
126 uint32 logic_num, // Interrupt number
127 TB_ISR isr_handler, // Interrupt service routine pointer.
128 hisr_func_t *pHisrFunc,
129 CHIPDRV_HISR_PRI_E hisrPri,
133 /*****************************************************************************/
134 // Description: This function is called to UnRegister an ISR.
135 // Dependency: irq_isr_array
136 // Author: Richard.Yang
137 // Note: If success, the function returns TB_SUCCESS;
138 // if int_num is a invalid number, returns TB_INT_ERROR;
139 // if the isr_handler is not installed before,
140 // returns TB_ISR_NULL.
141 /*****************************************************************************/
142 uint32 ISR_UnRegHandler (
143 uint32 int_num // Interrupt number
146 /*****************************************************************************/
147 // Description: This function is called to do works defined by upper layer.
148 // Dependency: irq_isr_array
149 // Author: Richard.Yang
150 // Note: If OK, Returns TB_SUCCESS;
151 // if int_num is an invalid number, returns TB_INT_ERROR;
152 // if msg is NULL, returns TB_PTR_ERROR ;
153 // if no callback function registered, returns TB_NO_CALLBACK
154 /*****************************************************************************/
155 uint32 ISR_Callback (
156 uint32 int_num, // Interrupt number
157 TB_MSG *msg // Message pointer
160 /*****************************************************************************/
161 // Description: This function is called to register a callback function
162 // called from lower layer.
163 // Dependency: irq_isr_array
164 // Author: Richard.Yang
165 // Note: If OK, returns TB_SUCCESS;
166 // if int_num is an invalid number, returns TB_INT_ERROR;
167 // if handler pointer is NULL, returns TB_PTR_ERROR;
168 // if callback function is already registered,
169 // returns TB_CALLBACK_ASSIGNED .
170 /*****************************************************************************/
171 uint32 ISR_RegCallback (
172 uint32 int_num, // Interrupt number
173 TB_CALLBACK handler // Callback handler
176 /*****************************************************************************/
177 // Description: This function is called to unregister a callback function
178 // called from lower layer.
179 // Dependency: irq_isr_array
180 // Author: Xueliang.Wang
181 // Note: Returns TB_SUCCESS if OK;
182 // returns TB_INT_ERROR if int_num is an invalid number;
183 // returns TB_NO_CALLBACK if no callback function registered.
184 /*****************************************************************************/
185 uint32 ISR_UnRegCallback (
186 uint32 int_num // Interrupt number
189 /**---------------------------------------------------------------------------*
190 ** Function Propertype *
191 **---------------------------------------------------------------------------*/
195 /**---------------------------------------------------------------------------*
197 **---------------------------------------------------------------------------*/
200 #endif // __cplusplus
202 #endif // End of _ISR_DRVAPI_H_