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.6  2008/03/25 02:23:23  tojo
15   Added WPADIsRegisteredBLC() and WPADRegisterBLCWorkarea().
16 
17   Revision 1.5  2007/09/11 08:17:41  tojo
18   Changed WPAD_BLCMD_BAT to WPAD_BLCMD_UPDATE_TEMP.
19 
20   Revision 1.4  2007/05/31 09:30:12  tojo
21   Added WPAD_BLCMD_BAT.
22 
23   Revision 1.3  2007/05/30 08:01:43  tojo
24   Changed the api spec of WPADSet/GetBLCalibration().
25 
26   Revision 1.2  2007/05/30 02:03:52  tojo
27   Redesigned the whole balance checker code according to changing the spec.
28 
29   Revision 1.1  2007/03/30 06:42:20  tojo
30   initial check-in.
31 
32   $NoKeywords: $
33  *---------------------------------------------------------------------------*/
34 
35 #ifndef __WPAD_BALANCE_H__
36 #define __WPAD_BALANCE_H__
37 
38 #include <revolution/wpad.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #define WPAD_PRESS_UNITS            4
45 #define WPAD_DEV_BALANCE_CHECKER    3
46 #define WPAD_FMT_BALANCE_CHECKER    12      // buttons + balance checker
47 
48 typedef struct WPADBLStatus
49 {
50     u16       button;                       // Or-ed WPAD_BUTTON_* bits
51     s16       accX;                         // -WPAD_ACC_RESO/2 <= accX < WPAD_ACC_RESO/2
52     s16       accY;                         // -WPAD_ACC_RESO/2 <= accY < WPAD_ACC_RESO/2
53     s16       accZ;                         // -WPAD_ACC_RESO/2 <= accZ < WPAD_ACC_RESO/2
54     DPDObject obj[WPAD_DPD_MAX_OBJECTS];
55 
56     u8        dev;                          // one of WPAD_DEV_* number
57     s8        err;                          // one of WPAD_ERR_* number
58 
59     u16       press[WPAD_PRESS_UNITS];
60     s8        temp;                         // temperature
61     u8        battery;                      // battery
62 
63 } WPADBLStatus;
64 
65 #define WPAD_BLCMD_ON               0xaa
66 #define WPAD_BLCMD_OFF              0x55
67 #define WPAD_BLCMD_UPDATE_TEMP      0x00
68 
69 extern s32  WPADControlBLC( s32 chan, u8  command, WPADCallback callback );
70 
71 #define WPAD_BLCLB_BLK1_ADDR        0x0024
72 #define WPAD_BLCLB_BLK1_LEN         16
73 #define WPAD_BLCLB_BLK2_ADDR        0x0034
74 #define WPAD_BLCLB_BLK2_LEN         8
75 #define WPAD_BLCLB_BLK3_ADDR        0x003c
76 #define WPAD_BLCLB_BLK3_LEN         4
77 #define WPAD_BLCLB_BLK4_ADDR        0x0050
78 #define WPAD_BLCLB_BLK4_LEN         16
79 #define WPAD_BLCLB_BLK5_ADDR        0x0060
80 #define WPAD_BLCLB_BLK5_LEN         16
81 
82 extern s32  WPADGetBLCalibration( s32 chan, u8 *data, u16 addr, u16 len, WPADCallback callback );
83 
84 extern BOOL WPADIsRegisteredBLC( void );
85 
86 #define WPAD_BLCINT_WORK_LEN        307200
87 
88 extern void WPADRegisterBLCWorkarea( void *workarea );
89 
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 #endif // __WPAD_BALANCE_H__