source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/irb/7552/birb.h

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

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 17.4 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2008, 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: birb.h $
11 * $brcm_Revision: Hydra_Software_Devel/14 $
12 * $brcm_Date: 4/18/08 11:23a $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/irb/7405/birb.h $
19 *
20 * Hydra_Software_Devel/14   4/18/08 11:23a jkim
21 * PR37963: fixed compiler warning
22 *
23 * Hydra_Software_Devel/13   2/20/08 1:57p jkim
24 * PR37963: Add XMP-2 support
25 *
26 * Hydra_Software_Devel/12   10/7/04 6:35p brianlee
27 * PR11333: Modified multiple sequence blast functions to accommodate
28 * another case.
29 *
30 * Hydra_Software_Devel/11   9/22/04 5:59p brianlee
31 * PR11333: Fixed various multiple sequence sending functions.
32 *
33 * Hydra_Software_Devel/10   7/23/04 4:04p brianlee
34 * PR11333: Added another type of multiple blast sequences.
35 *
36 * Hydra_Software_Devel/9   6/7/04 4:13p brianlee
37 * PR11386: Make configregisters function public so it can be called by
38 * test routines.
39 *
40 * Hydra_Software_Devel/8   6/3/04 11:18a brianlee
41 * PR11333: Added support for sending multiple blast sequences.
42 *
43 * Hydra_Software_Devel/7   3/9/04 5:01p brianlee
44 * PR9958: Added comments describing IRB configuration fields.
45 *
46 * Hydra_Software_Devel/6   3/4/04 5:34p brianlee
47 * PR9958: Added BIRB_Device_eCustom type and the function
48 * BIRB_ConfigCustom() to allow user to configure custom IR blaster
49 * setting.
50 *
51 * Hydra_Software_Devel/5   10/3/03 9:53a brianlee
52 * Added test configuration.
53 *
54 * Hydra_Software_Devel/4   9/25/03 11:52a brianlee
55 * Fixed tags for Midas service generator.
56 *
57 * Hydra_Software_Devel/3   9/18/03 4:14p brianlee
58 * Added IRB settings and additional API functions.
59 *
60 * Hydra_Software_Devel/2   7/31/03 1:40p brianlee
61 * Removed 64-bit test configuration.
62 *
63 * Hydra_Software_Devel/1   7/24/03 11:31a brianlee
64 * Initial version.
65 *
66 ***************************************************************************/
67
68
69/*= Module Overview *********************************************************
70<verbatim>
71
72Overview
73The IRB PI module controls the IR Blaster core within the BCM7038.  The IR
74blaster within the BCM7038 supports up to 160 pulse seuqences.
75
76
77Design
78The design for BIRB PI API is broken into three parts.
79  Part 1 (open/close/configuration):
80    These APIs are used for opening and closing BIRB device.
81   
82  Part 2 (sequence configuration):
83    These APIs are used to configure IR blast sequence.
84
85  Part 3 (send IR blast):
86    These APIs are used to send the IR blast.
87
88Usage
89The usage of BIRB involves the following:
90   * Configure/Open of BIRB
91      * Configure BIRB device for the target system
92      * Open BIRB device
93   * Configure blast sequence
94      * Configure blast sequence registers for target device.
95   * Send blast
96      * Start the IR blast sequence.
97
98Sample Code
99void main( void )
100{
101    BIRB_Handle       hIrb;
102    BIRB_Settings     defSettings;
103    BREG_Handle       hReg;
104    BCHP_Handle       hChip;
105        BINT_Handle               hInterrupt;
106        BKNI_EventHandle  hEvent;
107        uint32_t          data;
108
109    // Do other initialization, i.e. for BREG, BCHP, etc.
110
111    BIRB_Open (&hIrb, hChip, hReg, hInterrupt, (BIRB_Settings *)NULL);
112        BIRB_GetEventHandle (hIrb, &hEvent);
113
114    // Blast to a Sony TV
115    BIRB_Config (hIrb, BIRB_Device_eSony);
116
117    // Sony POWER code is 0x95, 12 bits
118        data = 0x95;
119    BIRB_Send (hIrb, &data, 12);
120
121        // Wait to IR blast to finish
122        BKNI_WaitForEvent(hEvent, BKNI_INFINITE);
123}
124
125</verbatim>
126***************************************************************************/
127
128
129#ifndef BIRB_H__
130#define BIRB_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 BIRB
145
146Description:
147
148See Also:
149
150****************************************************************************/
151#define BIRB_ERR_TOO_MANY_SEQ                   BERR_MAKE_CODE(BERR_IRB_ID, 0)
152
153/***************************************************************************
154Summary:
155        The handle for irb module.
156
157Description:
158
159See Also:
160        BIRB_Open()
161
162****************************************************************************/
163typedef struct BIRB_P_Handle                            *BIRB_Handle;
164
165/***************************************************************************
166Summary:
167        Enumeration for supported devices
168                                                                       
169Description:
170        This enumeration lists the device supported by this IRB PI.
171        New device types can be added as needed..
172
173See Also:
174        None.
175
176****************************************************************************/
177typedef enum
178{
179   BIRB_Device_eSony,
180   BIRB_Device_eGI,
181   BIRB_Device_ePioneer,
182   BIRB_Device_ePioneerAAAA,
183   BIRB_Device_eCustom,
184   BIRB_Device_eXmp2,
185   BIRB_Device_eTest
186} BIRB_Device;
187
188/***************************************************************************
189Summary:
190        IR blaster configuration
191
192Description:
193        This structure type contains IR blast information for a particular IR
194        protocol.
195
196See Also:
197
198****************************************************************************/
199#define MASTER_DIVISOR                  (27)    /* masterDivisor (1..256) */
200#define CARRIER_CLOCK_DIVISOR   (1)             /* carrierClockDivisor (1..16) */
201#define INDEX_CLOCK_DIVISOR     (10)    /* indexClockDivisor (1..16) */
202#define INDEX_PERIOD                    (10)    /* index clock period in us */
203#define CARRIER_PERIOD                  (1)             /* carrier clock period in us */
204
205#define FRAME_PERIOD                    (45000) /* frame period in us */
206#define FRAME_PERIOD_64_BIT     (145000)/* frame period in us */
207
208#define FRAME_PERIOD_PIONEER_ABBB_1     (108026)        /* frame period in us */
209#define FRAME_PERIOD_PIONEER_ABBB_2     (108026)        /* frame period in us */
210#define FRAME_PERIOD_PIONEER_ABBB_3     (46420)         /* frame period in us */
211#define FRAME_PERIOD_PIONEER_ABBB_4     (59080)         /* frame period in us */
212
213#define CASE2_DURATION_INDEX            8
214
215#define FRAME_PERIOD_PIONEER_AAAA_4     (115000)        /* frame period in us */
216
217#define irb_sequenceIndexMemLength      161
218#define irb_durationMemLength           14
219
220/* defins for XMP-2 configuration */
221#define BLAST_INTRENABLE_ALTMODCNT (0x20)
222#define DELTA1        1
223#define DATA0         3
224#define DATA2         4
225#define DATA4         5
226#define DATA6         6
227#define DATA8         7
228#define DATA10        8
229#define DATA12        9
230#define DATA14        10
231#define DATA_PULSE    11
232#define TRAILER_PULSE 12
233#define ZERO          13
234typedef struct irb_IndexPair
235{
236        uint16_t on;            /* index of on duration */
237        uint16_t off;           /* index of off duration */
238} irb_IndexPair;
239
240typedef struct irb_Configuration
241{
242        char            *name;                                                  /* name of configuration */
243        uint8_t         masterClockDivisor;                             /* pre-scaler for the primary IRB clock */
244        uint8_t         carrierClockDivisor;                    /* pre-scaler for carrier counter clock */
245        uint8_t         indexClockDivisor;                              /* pre-scaler for modulation counter clock */
246        uint8_t         noCarrier;                                              /* 0=output w/ carrier, 1=output w/out carrier */
247        uint8_t         carrierHighCount;                               /* high time for the carrier frequency */
248        uint8_t         carrierLowCount;                                /* low time for the carrier frequency */
249        uint8_t         numberSequences;                                /* number of modulation on/off sequences */
250        irb_IndexPair logic0IndexPair;                          /* pointer to mod_reg_file with logic0 */
251        irb_IndexPair logic1IndexPair;                          /* pointer to mod_reg_file with logic1 */
252        irb_IndexPair sequenceIndex[irb_sequenceIndexMemLength];        /* blast_seq_regfile */
253        uint32_t        duration[irb_durationMemLength];                                /* blast_mod_regfile */
254        uint32_t        framePeriod;                                    /* IR packet frame period A */
255        uint32_t        framePeriodB;                                   /* IR packet frame period B */
256        uint16_t        lastSequenceOffIndex;                   /* index to the last sequence off duration */
257        uint8_t         repeatCount;                                    /* IR blaster repeat number */
258        uint8_t         repeatStartIndex;                               /* IR blaster repeat index */
259        int             altModCnt;
260} SIrbConfiguration;
261
262/***************************************************************************
263Summary:
264        Required default settings structure for IRB module.
265
266Description:
267        The default setting structure defines the default configure of
268        IRB when the device is opened. 
269
270See Also:
271        BIRB_Open()
272
273****************************************************************************/
274typedef struct BIRB_Settings
275{
276        BIRB_Device             irbDev;                         /* IR Blaster device type */
277        bool                    intMode;                        /* interrupt enable flag */
278} BIRB_Settings;
279
280
281/***************************************************************************
282Summary:
283        This function opens IRB module.
284
285Description:
286        This function is responsible for opening BIRB module. When BIRB is
287        opened, it will create a module handle and configure the module based
288        on the default settings. Once the device is opened, it must be closed
289        before it can be opened again.
290
291Returns:
292        TODO:
293
294See Also:
295        BIRB_Close()
296        BIRB_GetDefaultSettings()
297
298****************************************************************************/
299BERR_Code BIRB_Open(
300        BIRB_Handle *pIRB,                                      /* [out] Returns handle */
301        BCHP_Handle hChip,                                      /* [in] Chip handle */
302        BREG_Handle hRegister,                          /* [in] Register handle */
303        BINT_Handle hInterrupt,                         /* [in] Interrupt handle */
304        const BIRB_Settings *pDefSettings       /* [in] Default settings */
305        );
306
307/***************************************************************************
308Summary:
309        This function closes IRB module.
310
311Description:
312        This function is responsible for closing BIRB module. Closing BIRB
313        will free main BIRB handle.
314
315Returns:
316        TODO:
317
318See Also:
319        BIRB_Open()
320
321****************************************************************************/
322BERR_Code BIRB_Close(
323        BIRB_Handle hDev                                        /* [in] Device handle */
324        );
325
326/***************************************************************************
327Summary:
328        This function returns the default settings for IRB module.
329
330Description:
331        This function is responsible for returns the default setting for
332        BIRB module. The returning default setting should be when
333        opening the device.
334
335Returns:
336        TODO:
337
338See Also:
339        BIRB_Open()
340
341****************************************************************************/
342BERR_Code BIRB_GetDefaultSettings(
343        BIRB_Settings *pDefSettings,            /* [out] Returns default setting */
344        BCHP_Handle hChip                                       /* [in] Chip handle */
345        );
346
347/***************************************************************************
348Summary:
349        This function gets the event handle for IRB module channel.
350
351Description:
352        This function is responsible for getting the event handle. The
353        application code should use this function to get the IRB event handle,
354        and pend on the event.  The IRB ISR will set the event.
355
356Returns:
357        TODO:
358
359See Also:
360
361****************************************************************************/
362BERR_Code BIRB_GetEventHandle(
363        BIRB_Handle             hDev,                           /* [in] Device handle */
364        BKNI_EventHandle *phEvent                       /* [out] Returns event handle */
365        );
366
367/***************************************************************************
368Summary:
369        This function sets the custom IRB parameters
370
371Description:
372        This function sets the custom-type IRB parameters to what the user
373        requests.  This allows the user to change IRB parameters on the fly.
374               
375Returns:
376        TODO:
377
378See Also:
379       
380
381****************************************************************************/
382void BIRB_ConfigCustom (
383        BIRB_Handle             hIrb,                   /* [in] Device handle */
384        SIrbConfiguration       *pConfig                /* [in] Pointer to custom config */
385);
386
387/***************************************************************************
388Summary:
389        This function configures the IR blaster sequence type.
390
391Description:
392        This function is used to configure the IR blaster prior to blasting.
393               
394Returns:
395        TODO:
396
397See Also:
398       
399
400****************************************************************************/
401BERR_Code BIRB_Config ( 
402        BIRB_Handle             hIrb,                   /* [in] Device handle */
403        BIRB_Device             irbDev                  /* [in] IR device type */
404        );
405
406/***************************************************************************
407Summary:
408        This function resets the IR blaster
409
410Description:
411        This function is used to reset the IR blaster or to abort a blast sequence.
412               
413Returns:
414        TODO:
415
416See Also:
417       
418
419****************************************************************************/
420void BIRB_Reset(
421        BIRB_Handle     hDev                            /* [in] Device handle */
422);
423
424/***************************************************************************
425Summary:
426        This function starts the blast without reconfiguring sequence.
427
428Description:
429        This function is used to re-send the previously configured sequence
430        without having to reconfigure it again.
431               
432Returns:
433        TODO:
434
435See Also:
436       
437
438****************************************************************************/
439BERR_Code BIRB_Blast ( 
440        BIRB_Handle             hIrb                    /* [in] Device handle */
441        );
442
443/***************************************************************************
444Summary:
445        This function checks to see if IR blast is finished
446
447Description:
448        This function is used to poll the status of IR blaster.  If a blast is
449        in progress, it returns false.  If no blast is in progress, it returns true.
450               
451Returns:
452        TODO:
453
454See Also:
455       
456
457****************************************************************************/
458bool BIRB_IsIrbFinished(
459        BIRB_Handle     hDev                            /* [in] Device handle */
460);
461
462/***************************************************************************
463Summary:
464        This function sends the IR blaster sequence.
465
466Description:
467        This function is used to send an IR blast sequence.
468        This function always sends the header pulse.
469               
470Returns:
471        TODO:
472
473See Also:
474       
475
476****************************************************************************/
477BERR_Code BIRB_Send ( 
478        BIRB_Handle             hDev,                   /* [in] Device handle */
479        uint32_t                        *pData,                 /* [in] pointer to data to blast */
480        uint8_t                         bits                    /* [in] number of bits to blast */
481        );
482
483/***************************************************************************
484Summary:
485        This function sends the IR blaster sequence.
486
487Description:
488        This function is used to send an IR blast sequence with option to disable
489        header pulse
490               
491Returns:
492        TODO:
493
494See Also:
495       
496
497****************************************************************************/
498BERR_Code BIRB_SendWithHeaderOption ( 
499        BIRB_Handle             hDev,                   /* [in] Device handle */
500        uint32_t                        *pData,                 /* [in] pointer to data to blast */
501        uint8_t                         bits,                   /* [in] number of bits to blast */
502        bool                            headerPulse             /* [in] header flag */
503        );
504
505/***************************************************************************
506Summary:
507        This function sends multiple IR blaster packets.
508
509Description:
510        This function is used to multiple blaster packets.
511               
512Returns:
513        TODO:
514
515See Also:
516       
517
518****************************************************************************/
519BERR_Code BIRB_SendABBB ( 
520        BIRB_Handle             hDev,                   /* [in] Device handle */
521        uint32_t                        *pDataA,                /* [in] pointer to data A to blast */
522        uint8_t                         bitsA,                  /* [in] number of bits in A to blast */
523        uint32_t                        *pDataB,                /* [in] pointer to data B to blast */
524        uint8_t                         bitsB,                  /* [in] number of bits in B to blast */
525        bool                            headerA,                /* [in] flag to send header A pulse */
526        bool                            headerB,                /* [in] flag to send header B pulse */
527        bool                            fixedFlag               /* [in] flag to indicate fixed frame length */
528);
529
530/***************************************************************************
531Summary:
532        This function sends multiple IR blaster packets.
533
534Description:
535        This function is used to multiple blaster packets.
536               
537Returns:
538        TODO:
539
540See Also:
541       
542
543****************************************************************************/
544BERR_Code BIRB_SendAAAA ( 
545        BIRB_Handle             hDev,                   /* [in] Device handle */
546        uint32_t                        *pDataA,                /* [in] pointer to data A to blast */
547        uint8_t                         bitsA,                  /* [in] number of bits in A to blast */
548        bool                            headerPulse,    /* [in] flag to send header pulse */
549        bool                            fixedFlag               /* [in] flag to indicate fixed frame length */
550);
551
552
553/***************************************************************************
554Summary:
555        This function configures IR blaster registers
556
557Description:
558        This function is used to write a pre-configured IR blast sequence to
559        hardware.
560               
561Returns:
562        TODO:
563
564See Also:
565       
566
567****************************************************************************/
568void BIRB_ConfigRegisters(
569        BIRB_Handle     hDev                            /* [in] Device handle */
570);
571
572/***************************************************************************
573Summary:
574        This function sends XMP2 ACK packet.
575
576Description:
577        This function is used to send XMP2 ACK packet.
578               
579Returns:
580        TODO:
581
582See Also:
583       
584
585****************************************************************************/
586BERR_Code BIRB_SendXmp2Ack ( 
587    BIRB_Handle         hDev           /* Device handle */
588);
589
590/***************************************************************************
591Summary:
592        This function sends XMP2 NACK packet.
593
594Description:
595        This function is used to send XMP2 NACK packet.
596               
597Returns:
598        TODO:
599
600See Also:
601       
602
603****************************************************************************/
604BERR_Code BIRB_SendXmp2Nack ( 
605    BIRB_Handle         hDev           /* Device handle */
606);
607
608/***************************************************************************
609Summary:
610        This function sends XMP2 packet.
611
612Description:
613        This function is used to send XMP2 packet.
614               
615Returns:
616        TODO:
617
618See Also:
619       
620
621****************************************************************************/
622BERR_Code BIRB_SendXmp2Bytes ( 
623    BIRB_Handle         hDev,           /* Device handle */
624    uint8_t             *pByte,         /* date to send */
625    uint8_t             numByte         /* 1 or 4 bye */
626);
627
628#ifdef __cplusplus
629}
630#endif
631 
632#endif
633
634
635
Note: See TracBrowser for help on using the repository browser.