1 /******************************************************************************
2 ** File Name: gpio_drvapi.h *
3 ** Author: Xueliang.Wang *
5 ** Copyright: 2003 Spreatrum, Incoporated. All Rights Reserved. *
6 ** Description: This file defines the basic operation interfaces of *
8 ******************************************************************************
10 ******************************************************************************
12 ** ------------------------------------------------------------------------- *
13 ** DATE NAME DESCRIPTION *
14 ** 03/18/2003 Xueliang.Wang Create. *
15 ** 09/05/2003 Zhemin.Lin Added functions for SM5100B EVB1.0 *
16 ** 22/11/2004 Benjamin.Wang Modified according CR16760 *
17 ** 08/01/2008 Yiyue.He modified the code for more generic adptation
18 ******************************************************************************/
20 #ifndef _GPIO_DRVAPI_H_
21 #define _GPIO_DRVAPI_H_
23 /**---------------------------------------------------------------------------*
25 **---------------------------------------------------------------------------*/
31 typedef enum GPIO_INT_tag
33 GPIO_INT_DISABLE = 0, // Disable the relative gpio interrupt.
34 GPIO_INT_LEVEL_HIGH, // detect high level.
35 GPIO_INT_LEVEL_LOW, // detect low level.
36 GPIO_INT_EDGES_BOTH, // detect the rising edges and falling edges.
37 GPIO_INT_EDGES_RISING, // detect the rising edges.
38 GPIO_INT_EDGES_FALLING // detect the falling edges.
42 #define GPIO_DEFAULT_SHAKING_TIME 50
44 // CallBack function pointer prototype.
45 typedef void (* GPIO_CALLBACK) (uint32 gpio_id, uint32 gpio_state);
47 /*****************************************************************************/
48 // Description: This function initialize GPIO function.
49 // Author: Xueliang.Wang
51 /*****************************************************************************/
52 PUBLIC uint32 GPIO_Init (void);
54 /*****************************************************************************/
55 // Description: This function used to get the direction of a gpio pin
56 // Author: Benjamin.Wang
57 // retread by: Yiyue.He
60 /*****************************************************************************/
61 PUBLIC BOOLEAN GPIO_GetDirection (uint32 gpio_id);
63 /*****************************************************************************/
64 // Description: This function used to set the direction of a gpio pin
65 // Author: Benjamin.Wang
66 // retread by: Yiyue.He
69 /*****************************************************************************/
70 PUBLIC void GPIO_SetDirection (uint32 gpio_id, BOOLEAN directions);
72 /*****************************************************************************/
73 // Description: This function used to enable data w/r mask the given gpio port.
74 // Author: Benjamin.Wang
75 // retread by : Yiyue.He
77 /*****************************************************************************/
78 PUBLIC void GPIO_Enable (uint32 gpio_id);
80 /*****************************************************************************/
81 // Description: This function used to disable the given gpio port.
82 // Author: Benjamin.Wang
83 // retread by : Yiyue.He
85 /*****************************************************************************/
86 PUBLIC void GPIO_Disable (uint32 gpio_id);
89 /*****************************************************************************/
90 // Description: This function used to get the value of a gpio pin
93 /*****************************************************************************/
94 PUBLIC BOOLEAN GPIO_GetValue (uint32 gpio_id);
96 /*****************************************************************************/
97 // Description: This function used to set the value of a gpio pin
100 /*****************************************************************************/
101 PUBLIC void GPIO_SetValue (uint32 gpio_id, BOOLEAN b_on);
103 /*****************************************************************************/
104 // Description: This function used to Deshaking 0 interrupt
107 /*****************************************************************************/
109 void GPIO_ZeroIntDeShaking (uint32 state);
111 /*****************************************************************************/
112 // Description: This function use timer to fix 0 interrpt issue
113 // Author: Zhemin.Lin
115 /*****************************************************************************/
117 void GPIO_ZeroIntHandler (uint32 int_num);
119 /*****************************************************************************/
120 // Description: This function used to enable gpio IRQ Interrupt.
121 // Author: Benjamin.Wang
123 /*****************************************************************************/
124 PUBLIC void GPIO_EnableInt (void);
126 /*****************************************************************************/
127 // Description: This function used to disable gpio IRQ Interrupt.
128 // Author: Benjamin.Wang
130 /*****************************************************************************/
131 PUBLIC void GPIO_DisableInt (void);
134 /*****************************************************************************/
135 // Description: This function used to enable gpio IRQ Interrupt.
136 // Author: Benjamin.Wang
138 /*****************************************************************************/
139 PUBLIC void GPIO_EnableInt (void);
141 /*****************************************************************************/
142 // Description: This function used to disable gpio IRQ Interrupt.
143 // Author: Benjamin.Wang
145 /*****************************************************************************/
146 PUBLIC void GPIO_DisableInt (void);
148 /*****************************************************************************/
149 // Description: This function used to enable the given gpio port's interrupt.
150 // Author: Benjamin.Wang
151 // retread by: Yiyue.He
153 /*****************************************************************************/
154 PUBLIC void GPIO_EnableIntCtl (uint32 gpio_id);
156 /*****************************************************************************/
157 // Description: This function used to disable the given gpio port's interrupt.
158 // Author: Benjamin.Wang
159 // retread by: Yiyue.He
161 /*****************************************************************************/
162 PUBLIC void GPIO_DisableIntCtl (uint32 gpio_id);
164 /*****************************************************************************/
165 // Description: This function used to get the intr state of a gpio pin
166 // Author: Zhemin.Lin
167 // retread by: Yiyue.He
169 /*****************************************************************************/
170 PUBLIC BOOLEAN GPIO_GetIntState (uint32 gpio_id);
172 /*****************************************************************************/
173 // Description: This function used to clear the given interrupt status bit.
174 // Author: Benjamin.Wang
175 // retread by: Yiyue.He
177 /*****************************************************************************/
178 PUBLIC void GPIO_ClearIntStatus (uint32 gpio_id);
180 /*****************************************************************************/
181 // Description: This function used to set gpio Interrupt sense type.
182 // Author: Benjamin.Wang
184 /*****************************************************************************/
185 PUBLIC void GPIO_SetInterruptSense (uint32 gpio_id, GPIO_INT_TYPE sensetype);
187 /*****************************************************************************/
188 // Description: This function GPIO input state
189 // Author: Zhemin.Lin
190 // Retread by : Yiyue.He
192 /*****************************************************************************/
193 PUBLIC BOOLEAN GPIO_GetGPIOState (uint32 gpio_id);
195 /*****************************************************************************/
196 // Description: This function add an callback function to gpio_int_table
198 // Retread by: Yiyue.He
199 // Note: This function and GPIO_AddToIntTable() can't be called simultaneously.
200 /*****************************************************************************/
201 PUBLIC uint32 GPIO_AddCallbackToIntTable (
202 uint32 gpio_id, // GPIO ID
203 BOOLEAN de_shaking, // if SCI_TRUE, need de shaking, else needn't
204 uint32 shaking_interval, // interval for de shaking
205 GPIO_CALLBACK gpio_callback_fun // Callback function
208 /*****************************************************************************/
209 // Description: This function deletes an int from gpio_int_table
210 // Author: Benjamin.Wang
211 // Retread by: Yiyue.He
212 // Note: If the GPIO INT is triggered by LEVEL, you have to delete it from int table in
213 // interrupt callback functions. Otherwise, the interrupt will be triggered ceaselessly.
214 /*****************************************************************************/
215 PUBLIC uint32 GPIO_DeleteFromIntTable (uint32 gpio_id);
217 /*****************************************************************************/
218 // Description: This function used to know whether the gpio port is enabled.
221 /*****************************************************************************/
222 PUBLIC BOOLEAN GPIO_GetDataMask (uint32 gpio_id);
224 /*****************************************************************************/
225 // Description: This function used to set the gpio port to enabled or not
228 /*****************************************************************************/
229 PUBLIC void GPIO_SetDataMask (uint32 gpio_id, BOOLEAN b_on);
231 /*****************************************************************************/
232 // Description: This function retrun the max number of gpio
233 // Author: Zhemin.Lin
235 /*****************************************************************************/
236 PUBLIC uint32 GPIO_GetMaxNumber (void);
238 PUBLIC void GPIO_SetInitState (uint32 gpio_id, uint32 state);
240 PUBLIC uint32 GPIO_GetInitState (uint32 gpio_id);
242 PUBLIC uint32 GPIO_GetShakeInterval (uint32 gpio_id);
244 PUBLIC void GPIO_GetCallBack (uint32 gpio_id, uint32 gpio_state);
251 #endif // _GPIO_DRVAPI_H_
253 // End of gpio_drvapi.h