source: svn/newcon3bcm2_21bu/magnum/portinginterface/kpd/7552/bkpd.h @ 43

Last change on this file since 43 was 43, checked in by megakiss, 11 years ago

광주방송 OTC 주파수 369Mhz로 변경

  • Property svn:executable set to *
File size: 10.0 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bkpd.h $
11 * $brcm_Revision: Hydra_Software_Devel/8 $
12 * $brcm_Date: 9/15/04 12:06p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/kpd/7038/bkpd.h $
19 *
20 * Hydra_Software_Devel/8   9/15/04 12:06p brianlee
21 * PR12504: Added function to allow user to install interrupt callback.
22 *
23 * Hydra_Software_Devel/8   9/15/04 11:51a brianlee
24 * PR12504: Added function to allow user to install interrupt callback.
25 *
26 * Hydra_Software_Devel/8   9/15/04 11:51a brianlee
27 * PR12504: Added function to allow user to install interrupt callback.
28 *
29 * Hydra_Software_Devel/8   9/15/04 11:50a brianlee
30 * PR12504: Added function to allow user to install interrupt callback.
31 *
32 * Hydra_Software_Devel/7   11/6/03 4:09p lseverin
33 * updated module overview for DocJet format
34 *
35 * Hydra_Software_Devel/6   10/1/03 11:41a brianlee
36 * Fixed sample code.
37 *
38 * Hydra_Software_Devel/5   9/25/03 12:05p brianlee
39 * Fixed tags for Midas service generator.
40 *
41 * Hydra_Software_Devel/4   9/23/03 11:40a brianlee
42 * Added polling option.
43 *
44 * Hydra_Software_Devel/3   8/20/03 5:13p brianlee
45 * Added error code for BKPD_Read if there's no key press.
46 *
47 * Hydra_Software_Devel/2   7/31/03 6:02p brianlee
48 * Added GetEventHandle() function.
49 *
50 * Hydra_Software_Devel/1   7/25/03 11:27a brianlee
51 * Initial version.
52 *
53 ***************************************************************************/
54
55
56/*= Module Overview *********************************************************
57<verbatim>
58
59Overview
60The KPD PI module controls the keypad controller within the BCM7038-B0.  The
61keypad controller (along with the LED controller) is not available in the
62BCM7038-A0 version.
63
64Design
65The design for BKPD PI API is broken into three parts.
66
67o Part 1 (open/close/configuration):
68
69  These APIs are used for opening and closing BKPD device.
70   
71o Part 2 (wait for key press):
72
73  These APIs are used to scan for key presses.
74
75o Part 3 (get the data):
76
77  These APIs are used to read the data from the keypad.
78
79Usage
80The usage of BKPD involves the following:
81
82  * Configure/Open of BKPD
83
84    * Configure BKPD device for the target system
85    * Open BKPD device
86
87  * Wait for key press
88
89  * Read the data
90
91Sample Code
92void main( void )
93{
94    BKPD_Handle                         hKPD;
95    BKPD_Settings                       defSettings;
96    BREG_Handle                         hReg;
97    BCHP_Handle                         hChip;
98    BINT_Handle                         hInt;
99    bool                                        keyReady = FALSE;
100    uint16_t                            key;
101
102    // Do other initialization, i.e. for BREG, BCHP, etc.
103
104    // Now, ready to setup the BKPD
105    BKPD_GetDefaultSettings( &defSettings, hChip );
106
107    // Make any changes required from the default values
108    defSettings.prescale = 0x60;
109    defSettings.debounce = 0x40;
110
111    BKPD_Open (&hKPD, hChip, hReg, hInt, &defSettings);
112
113    // Wait for a key to be hit
114    do
115    {
116        BKPD_IsDataReady (hKPD, &keyReady);
117    }   
118    while (keyReady == FALSE);
119
120    // key is now ready, go read it
121    BKPD_Read (hKPD, &key);
122
123}
124
125</verbatim>
126***************************************************************************/
127
128
129#ifndef BKPD_H__
130#define BKPD_H__
131
132#include "bchp.h"
133#include "breg_mem.h"
134#include "bint.h"
135#include "bkni.h"
136#include "berr_ids.h"
137
138#ifdef __cplusplus
139extern "C" {
140#endif
141
142/***************************************************************************
143Summary:
144        Error Codes specific to BKPD
145
146Description:
147
148See Also:
149
150****************************************************************************/
151#define BKPD_ERR_NO_KEY                         BERR_MAKE_CODE(BERR_KPD_ID, 0)  /* no key press */
152
153/***************************************************************************
154Summary:
155        The handle for kpd module.
156
157Description:
158
159See Also:
160        BKPD_Open()
161
162****************************************************************************/
163typedef struct BKPD_P_Handle                            *BKPD_Handle;
164
165/***************************************************************************
166Summary:
167        Required default settings structure for KPD module.
168
169Description:
170        The default setting structure defines the default configure of
171        KPD when the device is opened. 
172
173See Also:
174        BKPD_Open()
175
176****************************************************************************/
177typedef struct BKPD_Settings
178{
179   uint32_t                     prescale;               /* 27mhz clock prescale value */
180   uint8_t                      debounce;               /* debounce count */
181   bool                         intMode;                /* interrupt enable */
182} BKPD_Settings;
183
184
185/***************************************************************************
186Summary:
187        Callback function for BKPD
188
189Description:
190        The callback function is registered by the caller.  It gets called
191        when KPD interrupt happens.
192
193See Also:
194        BKPD_InstallInterruptCallback()
195
196****************************************************************************/
197typedef void (*BKPD_CallbackFunc)( void *pParm1, int parm2, void *pKPD_data);
198
199/***************************************************************************
200Summary:
201        Callback info structure
202
203Description:
204        This is the callback information structure.  Caller registers this
205        information with module to be called at interrupt time.
206
207See Also:
208        BKPD_InstallInterruptCallback()
209
210****************************************************************************/
211typedef struct BKPD_CallbackInfo
212{
213        BKPD_CallbackFunc cbFunc ;
214        void              *pParm1 ;
215        int               parm2 ;
216} BKPD_CallbackInfo;
217
218
219/***************************************************************************
220Summary:
221        This function opens KPD module.
222
223Description:
224        This function is responsible for opening BKPD module. When BKPD is
225        opened, it will create a module handle and configure the module based
226        on the default settings. Once the device is opened, it must be closed
227        before it can be opened again.
228
229Returns:
230        TODO:
231
232See Also:
233        BKPD_Close()
234        BKPD_GetDefaultSettings()
235
236****************************************************************************/
237BERR_Code BKPD_Open(
238        BKPD_Handle *pKPD,                                      /* [out] Returns handle */
239        BCHP_Handle hChip,                                      /* [in] Chip handle */
240        BREG_Handle hRegister,                          /* [in] Register handle */
241        BINT_Handle hInterrupt,                         /* [in] Interrupt handle */
242        const BKPD_Settings *pDefSettings       /* [in] Default settings */
243        );
244
245/***************************************************************************
246Summary:
247        This function closes KPD module.
248
249Description:
250        This function is responsible for closing BKPD module. Closing BKPD
251        will free main BKPD handle.
252
253Returns:
254        TODO:
255
256See Also:
257        BKPD_Open()
258
259****************************************************************************/
260BERR_Code BKPD_Close(
261        BKPD_Handle hDev                                        /* [in] Device handle */
262        );
263
264/***************************************************************************
265Summary:
266        This function returns the default settings for KPD module.
267
268Description:
269        This function is responsible for returns the default setting for
270        BKPD module. The returning default setting should be when
271        opening the device.
272
273Returns:
274        TODO:
275
276See Also:
277        BKPD_Open()
278
279****************************************************************************/
280BERR_Code BKPD_GetDefaultSettings(
281        BKPD_Settings *pDefSettings,            /* [out] Returns default setting */
282        BCHP_Handle hChip                                       /* [in] Chip handle */
283        );
284
285/***************************************************************************
286Summary:
287        This function checks for a key press
288
289Description:
290        This function is used to check for a key press.
291               
292Returns:
293        TODO:
294
295See Also:
296       
297
298****************************************************************************/
299BERR_Code BKPD_IsDataReady ( 
300        BKPD_Handle             hKpd,                   /* [in] Device handle */
301        bool                            *ready                  /* [out] flag indicating key is pressed */
302        );
303
304/***************************************************************************
305Summary:
306        This function reads the data from the keypad.
307
308Description:
309        This function is used to get the key that was pressed.
310               
311Returns:
312        BKPD_ERR_NO_KEY if there is no key press.
313
314See Also:
315       
316
317****************************************************************************/
318BERR_Code BKPD_Read ( 
319        BKPD_Handle             hKpd,                   /* [in] Device handle */
320        uint16_t                        *pData                  /* [out] pointer to data read from keypad */
321        );
322
323/***************************************************************************
324Summary:
325        This function installs user-specified interrupt callback function
326
327Description:
328        This function is used to install an interrupt callback function.
329               
330Returns:
331        BERR_SUCCESS
332
333See Also:
334       
335
336****************************************************************************/
337BERR_Code BKPD_InstallInterruptCallback (
338        BKPD_Handle             hKpd,                   /* [in] Device handle */
339        BKPD_CallbackFunc       callback,               /* [in] callback function */
340        void                            *pParm1,                /* [in] application specified parameter */
341        int                                     parm2                   /* [in] application specified parameter */
342);
343
344/***************************************************************************
345Summary:
346        This function uninstalls user-specified interrupt callback function
347
348Description:
349        This function is used to uninstall an interrupt callback function.
350               
351Returns:
352        BERR_SUCCESS
353
354See Also:
355       
356
357****************************************************************************/
358BERR_Code BKPD_UnInstallInterruptCallback (
359        BKPD_Handle             hKpd                    /* [in] Device handle */
360);
361
362/***************************************************************************
363Summary:
364        This function gets the event handle for BKPD module.
365
366Description:
367        This function is responsible for getting the event handle. The
368        application code should use this function get BKPD's event handle,
369        which the application should use to pend on.  The KPD ISR will
370        set the event.
371       
372Returns:
373        TODO:
374
375See Also:
376
377****************************************************************************/
378BERR_Code BKPD_GetEventHandle(
379        BKPD_Handle             hKpd,                   /* [in] Device handle */
380        BKNI_EventHandle        *phEvent                /* [out] Returns event handle */
381        );
382
383#ifdef __cplusplus
384}
385#endif
386 
387#endif
388
389
390
Note: See TracBrowser for help on using the repository browser.