1 /*---------------------------------------------------------------------------*
2   Project:  Revolution OS - WPAD
3   File:     wpadBalance.h
4 
5   Copyright 2007 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Log: wpadBalance.h,v $
14   Revision 1.4.4.4  2008/02/01 08:18:25  tojo
15   Added WPADRegisterBLCWorkarea.
16 
17   Revision 1.4.4.3  2007/12/11 07:19:12  tojo
18   Added WPADIsRegisteredBLC.
19 
20   Revision 1.4.4.2  2007/11/14 07:51:00  tojo
21   Removed some functions because they are obsolete.
22 
23   Revision 1.4.4.1  2007/09/11 08:02:00  tojo
24   Changed WPAD_BLCMD_BAT to WPAD_BLCMD_UPDATE_TEMP.
25 
26   Revision 1.4  2007/05/31 09:30:12  tojo
27   Added WPAD_BLCMD_BAT.
28 
29   Revision 1.3  2007/05/30 08:01:43  tojo
30   Changed the api spec of WPADSet/GetBLCalibration().
31 
32   Revision 1.2  2007/05/30 02:03:52  tojo
33   Redesigned the whole balance checker code according to changing the spec.
34 
35   Revision 1.1  2007/03/30 06:42:20  tojo
36   initial check-in.
37 
38   $NoKeywords: $
39  *---------------------------------------------------------------------------*/
40 
41 #ifndef __WPAD_BALANCE_H__
42 #define __WPAD_BALANCE_H__
43 
44 #include <revolution/wpad.h>
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #define WPAD_PRESS_UNITS            4
51 #define WPAD_DEV_BALANCE_CHECKER    3
52 #define WPAD_FMT_BALANCE_CHECKER    12      // buttons + balance checker
53 
54 typedef struct WPADBLStatus
55 {
56     u16       button;                       // Or-ed WPAD_BUTTON_* bits
57     s16       accX;                         // -WPAD_ACC_RESO/2 <= accX < WPAD_ACC_RESO/2
58     s16       accY;                         // -WPAD_ACC_RESO/2 <= accY < WPAD_ACC_RESO/2
59     s16       accZ;                         // -WPAD_ACC_RESO/2 <= accZ < WPAD_ACC_RESO/2
60     DPDObject obj[WPAD_DPD_MAX_OBJECTS];
61 
62     u8        dev;                          // one of WPAD_DEV_* number
63     s8        err;                          // one of WPAD_ERR_* number
64 
65     u16       press[WPAD_PRESS_UNITS];
66     s8        temp;                         // temperature
67     u8        battery;                      // battery
68 
69 } WPADBLStatus;
70 
71 #define WPAD_BLCMD_ON               0xaa
72 #define WPAD_BLCMD_OFF              0x55
73 #define WPAD_BLCMD_UPDATE_TEMP      0x00
74 
75 extern s32  WPADControlBLC( s32 chan, u8  command, WPADCallback callback );
76 
77 #define WPAD_BLCLB_BLK1_ADDR        0x0024
78 #define WPAD_BLCLB_BLK1_LEN         16
79 #define WPAD_BLCLB_BLK2_ADDR        0x0034
80 #define WPAD_BLCLB_BLK2_LEN         8
81 #define WPAD_BLCLB_BLK3_ADDR        0x003c
82 #define WPAD_BLCLB_BLK3_LEN         4
83 #define WPAD_BLCLB_BLK4_ADDR        0x0050
84 #define WPAD_BLCLB_BLK4_LEN         16
85 #define WPAD_BLCLB_BLK5_ADDR        0x0060
86 #define WPAD_BLCLB_BLK5_LEN         16
87 
88 extern s32  WPADGetBLCalibration( s32 chan, u8 *data, u16 addr, u16 len, WPADCallback callback );
89 
90 extern BOOL WPADIsRegisteredBLC( void );
91 
92 #define WPAD_BLCINT_WORK_LEN        307200
93 
94 extern void WPADRegisterBLCWorkarea( void *workarea );
95 
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 #endif // __WPAD_BALANCE_H__