source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/icp/7552/bicp.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 16.3 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: bicp.h $
11 * $brcm_Revision: Hydra_Software_Devel/9 $
12 * $brcm_Date: 2/4/05 11:25a $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/icp/7038/bicp.h $
19 *
20 * Hydra_Software_Devel/9   2/4/05 11:25a agin
21 * PR13212:  added callback for RC6 processing.
22 *
23 * Hydra_Software_Devel/8   2/3/05 11:36a agin
24 * PR13212: RC6 support
25 *
26 * Hydra_Software_Devel/7   10/24/03 9:46a brianlee
27 * Added #define for maximum number of ICAP channels.
28 *
29 * Hydra_Software_Devel/6   9/25/03 11:46a brianlee
30 * Fixed tags for Midas service generator.
31 *
32 * Hydra_Software_Devel/5   9/16/03 7:02p brianlee
33 * Added int mode option.
34 *
35 * Hydra_Software_Devel/4   7/31/03 2:00p brianlee
36 * Removed get/set reject count functions.
37 *
38 * Hydra_Software_Devel/3   7/31/03 10:38a brianlee
39 * Removed some private functions.  Added GetEventHandle() function.
40 *
41 * Hydra_Software_Devel/2   7/24/03 10:35a brianlee
42 * Fixed syntax error.
43 *
44 * Hydra_Software_Devel/1   7/23/03 5:33p brianlee
45 * Initial version.
46 *
47 ***************************************************************************/
48
49
50/*= Module Overview *********************************************************
51<verbatim>
52
53Overview
54The ICP PI module controls the Input Capture core within the BCM7038. 
55The ICP core supports up to 4 separate capture pins.  Each pin is individually
56configurable as positive or negative edge triggered.  When a pin is triggered,
57the count is captured and can be read.
58
59Design
60The design for BICP PI API is broken into two parts.
61  Part 1 (open/close/configuration):
62    These APIs are used for opening and closing BICP device/device channel.
63    When a device channel is opened, the glitch rejector count for
64        that channel can be programmed.
65   
66  Part 2 (command):
67    These APIs are used to configure and arm the trigger.
68
69Usage
70The usage of BICP involves the following:
71   * Configure/Open of BICP
72      * Configure BICP device for the target system
73      * Open BICP device
74      * Configure BICP device channel for the target system
75      * Open BICP device channel
76   * Configure and arm the trigger
77      * Configure edge triggerring
78   * Get count after trigger
79      * Read counter after edge is triggered
80
81Sample Code
82void main( void )
83{
84    BICP_Handle       hIcp;
85    BICP_ChannelHandle   hIcpChan;
86    BREG_Handle       hReg;
87    BCHP_Handle       hChip;
88    BINT_Handle       hInt;
89    BICP_ChannelSettings defChnSettings;
90    unsigned int ChanNo;
91    bool triggered = FALSE;
92    uint16_t cnt;
93
94    // Do other initialization, i.e. for BREG, BCHP, etc
95    BICP_Open( &hIcp, hChip, hReg, hInt, (BICP_Settings *)NULL );
96   
97    ChanNo = 0; // example for channel 0
98    BICP_GetChannelDefaultSettings( hIcp, ChanNo, &defChnSettings );
99
100    // Make any changes required from the default values
101    defChnSettings.rejectCnt = 8;
102    BICP_OpenChannel( hIcp, &hIcpChan, ChanNo, &defChnSettings );
103
104    // Set pin to negative edge trigger
105    BICP_EnableEdge (hIcpChan, BICP_EdgeConfig_eNegative);
106
107    // Wait until the pin is triggered
108    do
109    {
110        BICP_PollTimer (hIcpChan, &triggered, &cnt);
111    } while (!triggered);
112}
113
114</verbatim>
115***************************************************************************/
116
117
118#ifndef BICP_H__
119#define BICP_H__
120
121#include "bchp.h"
122#include "breg_mem.h"
123#include "bint.h"
124#include "bkni.h"
125#include "berr_ids.h"
126
127#ifdef __cplusplus
128extern "C" {
129#endif
130
131/***************************************************************************
132Summary:
133        Maximum number of PWM channels supported
134
135Description:
136
137See Also:
138
139****************************************************************************/
140#define MAX_ICP_CHANNELS                        4
141
142/***************************************************************************
143Summary:
144        Error Codes specific to BICP
145
146Description:
147
148See Also:
149
150****************************************************************************/
151#define BICP_ERR_NOTAVAIL_CHN_NO                        BERR_MAKE_CODE(BERR_ICP_ID, 0)
152
153/***************************************************************************
154Summary:
155        The handles for icp module.
156
157Description:
158        Since BICP is a device channel, it has main device handle as well
159        as a device channel handle.
160
161See Also:
162        BICP_Open(), BICP_OpenChannel()
163
164****************************************************************************/
165typedef struct BICP_P_Handle                            *BICP_Handle;
166typedef struct BICP_P_ChannelHandle                     *BICP_ChannelHandle;
167
168/***************************************************************************
169Summary:
170        Enumeration for edge configuration
171
172Description:
173        This enumeration defines edge trigger configuration for each ICP pin
174
175See Also:
176        None.
177
178****************************************************************************/
179typedef enum
180{
181   BICP_EdgeConfig_eNegative,
182   BICP_EdgeConfig_ePositive,
183   BICP_EdgeConfig_eBoth
184} BICP_EdgeConfig;
185
186/***************************************************************************
187Summary:
188        Required default settings structure for ICP module.
189
190Description:
191        The default setting structure defines the default configure of
192        ICP when the device is opened.  Since BICP is a device
193        channel, it also has default settings for a device channel.
194        Currently there are no parameters for device setting.
195
196See Also:
197        BICP_Open(), BICP_OpenChannel()
198
199****************************************************************************/
200typedef void *BICP_Settings;
201
202typedef struct BICP_ChannelSettings
203{
204   uint8_t      rejectCnt;                                      /* glitch reject count */
205   bool         intMode;                                        /* interrupt mode flag */
206} BICP_ChannelSettings;
207
208/***************************************************************************
209Summary:
210        Callback used for event notification.
211
212Description:
213        When this PI wants to notify an application, it will call this callback
214        function the callback function is registered.
215
216See Also:
217        None.
218
219****************************************************************************/
220typedef void (*BICP_Callback)(uint16_t ctrl, uint8_t mode, uint16_t data);
221
222/***************************************************************************
223Summary:
224        This function opens ICP module.
225
226Description:
227        This function is responsible for opening BICP module. When BICP is
228        opened, it will create a module handle and configure the module based
229        on the default settings. Once the device is opened, it must be closed
230        before it can be opened again.
231
232Returns:
233        TODO:
234
235See Also:
236        BICP_Close(), BICP_OpenChannel(), BICP_CloseChannel(),
237        BICP_GetDefaultSettings()
238
239****************************************************************************/
240BERR_Code BICP_Open(
241        BICP_Handle *pICP,                                      /* [out] Returns handle */
242        BCHP_Handle hChip,                                      /* [in] Chip handle */
243        BREG_Handle hRegister,                          /* [in] Register handle */
244        BINT_Handle hInterrupt,                         /* [in] Interrupt handle */
245        const BICP_Settings *pDefSettings       /* [in] Default settings */
246        );
247
248/***************************************************************************
249Summary:
250        This function closes ICP module.
251
252Description:
253        This function is responsible for closing BICP module. Closing BICP
254        will free main BICP handle. It is required that all opened
255        BICP channels must be closed before calling this function. If this
256        is not done, the results will be unpredicable.
257
258Returns:
259        TODO:
260
261See Also:
262        BICP_Open(), BICP_CloseChannel()
263
264****************************************************************************/
265BERR_Code BICP_Close(
266        BICP_Handle hDev                                        /* [in] Device handle */
267        );
268
269/***************************************************************************
270Summary:
271        This function returns the default settings for ICP module.
272
273Description:
274        This function is responsible for returns the default setting for
275        BICP module. The returning default setting should be when
276        opening the device.
277
278Returns:
279        TODO:
280
281See Also:
282        BICP_Open()
283
284****************************************************************************/
285BERR_Code BICP_GetDefaultSettings(
286        BICP_Settings *pDefSettings,            /* [out] Returns default setting */
287        BCHP_Handle hChip                                       /* [in] Chip handle */
288        );
289
290/***************************************************************************
291Summary:
292        This function returns the total number of channels supported by
293        ICP module.
294
295Description:
296        This function is responsible for getting total number of channels
297        supported by BICP module, since BICP device is implemented as a
298        device channel.
299
300Returns:
301        TODO:
302
303See Also:
304        BICP_OpenChannel(), BICP_ChannelDefaultSettings()
305
306****************************************************************************/
307BERR_Code BICP_GetTotalChannels(
308        BICP_Handle hDev,                                       /* [in] Device handle */
309        unsigned int *totalChannels                     /* [out] Returns total number downstream channels supported */
310        );
311
312/***************************************************************************
313Summary:
314        This function gets default setting for a ICP module channel.
315
316Description:
317        This function is responsible for returning the default setting for
318        channel of BICP. The return default setting is used when opening
319        a channel.
320
321Returns:
322        TODO:
323
324See Also:
325        BICP_OpenChannel()
326
327****************************************************************************/
328BERR_Code BICP_GetChannelDefaultSettings(
329        BICP_Handle hDev,                                       /* [in] Device handle */
330        unsigned int channelNo,                         /* [in] Channel number to default setting for */
331    BICP_ChannelSettings *pChnDefSettings /* [out] Returns channel default setting */
332    );
333
334/***************************************************************************
335Summary:
336        This function opens ICP module channel.
337
338Description:
339        This function is responsible for opening BICP module channel. When a
340        BICP channel is opened, it will create a module channel handle and
341        configure the module based on the channel default settings. Once a
342        channel is opened, it must be closed before it can be opened again.
343
344Returns:
345        TODO:
346
347See Also:
348        BICP_CloseChannel(), BICP_GetChannelDefaultSettings()
349
350****************************************************************************/
351BERR_Code BICP_OpenChannel(
352        BICP_Handle hDev,                                       /* [in] Device handle */
353        BICP_ChannelHandle *phChn,                      /* [out] Returns channel handle */
354        unsigned int channelNo,                         /* [in] Channel number to open */
355        const BICP_ChannelSettings *pChnDefSettings /* [in] Channel default setting */
356        );
357
358/***************************************************************************
359Summary:
360        This function closes ICP module channel.
361
362Description:
363        This function is responsible for closing BICP module channel. Closing
364        BICP channel it will free BICP channel handle. It is required that all
365        opened BICP channels must be closed before closing BICP.
366
367Returns:
368        TODO:
369
370See Also:
371        BICP_OpenChannel(), BICP_CloseChannel()
372
373****************************************************************************/
374BERR_Code BICP_CloseChannel(
375        BICP_ChannelHandle hChn                         /* [in] Device channel handle */
376        );
377
378/***************************************************************************
379Summary:
380        This function gets ICP module device handle based on
381        the device channel handle.
382
383Description:
384        This function is responsible returning BICP module handle based on the
385        BICP module channel.
386
387Returns:
388        TODO:
389
390See Also:
391
392****************************************************************************/
393BERR_Code BICP_GetDevice(
394        BICP_ChannelHandle hChn,                        /* [in] Device channel handle */
395        BICP_Handle *pICP                                       /* [out] Returns Device handle */
396        );
397
398/***************************************************************************
399Summary:
400        This function enables an edge trigger
401
402Description:
403        This function is used to configure an edge and arm the trigger.
404               
405Returns:
406        TODO:
407
408See Also:
409       
410
411****************************************************************************/
412BERR_Code BICP_EnableEdge( 
413        BICP_ChannelHandle      hChn,                   /* [in] Device channel handle */
414        BICP_EdgeConfig         edge                    /* [in] edge config */
415        );
416
417/***************************************************************************
418Summary:
419        This function disables an edge trigger
420
421Description:
422        This function is used to configure an edge to disable triggering
423               
424Returns:
425        TODO:
426
427See Also:
428       
429
430****************************************************************************/
431BERR_Code BICP_DisableEdge( 
432        BICP_ChannelHandle      hChn,                   /* [in] Device channel handle */
433        BICP_EdgeConfig         edge                    /* [in] edge config */
434        );
435
436/***************************************************************************
437Summary:
438        This function gets the timer count for a channel.
439
440Description:
441        This function is used to read the counter of an ICP channel after a trigger
442        happens.
443               
444Returns:
445        TODO:
446
447See Also:
448       
449
450****************************************************************************/
451BERR_Code BICP_GetTimerCnt( 
452        BICP_ChannelHandle      hChn,                   /* [in] Device channel handle */
453        uint16_t                        *timerCnt               /* [out] pointer to count */
454        );
455
456/***************************************************************************
457Summary:
458        This function checks to see if a trigger has happened.
459
460Description:
461        This function is used to poll the status of a trigger.  If a trigger
462        happens, it reads and outputs the counter.
463               
464Returns:
465        TODO:
466
467See Also:
468       
469
470****************************************************************************/
471BERR_Code BICP_PollTimer( 
472        BICP_ChannelHandle      hChn,                   /* [in] Device channel handle */
473        bool                            *triggered,             /* [out] status of trigger */
474        uint16_t                        *timerCnt               /* [out] pointer to count */
475        );
476
477/***************************************************************************
478Summary:
479        This function gets the event handle for BICP module channel.
480
481Description:
482        This function is responsible for getting the event handle. The
483        application code should use this function get BICP's event handle,
484        which the application should use to pend on.  The ICP ISR will
485        set the event.
486       
487Returns:
488        TODO:
489
490See Also:
491
492****************************************************************************/
493BERR_Code BICP_GetEventHandle(
494        BICP_ChannelHandle hChn,                        /* [in] Device channel handle */
495        BKNI_EventHandle *phEvent                       /* [out] Returns event handle */
496        );
497
498/***************************************************************************
499Summary:
500        This function enables the icap interrupt..
501
502Description:
503       
504Returns:
505        TODO:
506
507See Also:
508
509****************************************************************************/
510void BICP_EnableInt(
511        BICP_ChannelHandle hChn                         /* [in] Device channel handle */
512        );
513
514/***************************************************************************
515Summary:
516        This function disables the icap interrupt..
517
518Description:
519       
520Returns:
521        TODO:
522
523See Also:
524
525****************************************************************************/
526void BICP_DisableInt(
527        BICP_ChannelHandle hChn                         /* [in] Device channel handle */
528        );
529       
530/***************************************************************************
531Summary:
532        This function resets the interrupt count.
533
534Description:
535       
536Returns:
537        TODO:
538
539See Also:
540
541****************************************************************************/
542void BICP_ResetIntCount(
543        BICP_ChannelHandle hChn                         /* [in] Device channel handle */
544        );
545       
546/***************************************************************************
547Summary:
548        This function gets the interrupt count.
549
550Description:
551       
552Returns:
553        TODO:
554
555See Also:
556
557****************************************************************************/
558void BICP_GetIntCount(
559        BICP_ChannelHandle hChn,                        /* [in] Device channel handle */
560        uint32_t *data
561        );
562       
563/***************************************************************************
564Summary:
565        This function enables the handling of the RC6 protocol
566
567Description:
568       
569Returns:
570        TODO:
571
572See Also:
573
574****************************************************************************/
575void BICP_EnableRC6(
576        BICP_ChannelHandle hChn,                        /* [in] Device channel handle */
577        BICP_Callback pCallback                 /* Pointer to completion callback. */
578        );
579
580/***************************************************************************
581Summary:
582        This function disables the handling of the RC6 protocol
583
584Description:
585       
586Returns:
587        TODO:
588
589See Also:
590
591****************************************************************************/
592void BICP_DisableRC6(
593        BICP_ChannelHandle hChn                         /* [in] Device channel handle */
594        );
595
596#ifdef __cplusplus
597}
598#endif
599 
600#endif
Note: See TracBrowser for help on using the repository browser.