1 /*---------------------------------------------------------------------------*
2   Project:  Dolphin Serial Interface API
3   File:     OSSerial.h
4 
5   Copyright 1998-2001 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: OSSerial.h,v $
14   Revision 1.2  2006/02/04 11:56:48  hashida
15   (none)
16 
17   Revision 1.1.1.1  2005/12/29 06:53:28  hiratsu
18   Initial import.
19 
20   Revision 1.1.1.1  2005/05/12 02:41:07  yasuh-to
21   Ported from dolphin source tree.
22 
23 
24     5     2001/11/22 10:25 Shiki
25     Added SISetSamplingRate(), etc.
26 
27     4     2001/11/21 14:26 Shiki
28     Added SI_CHAN_BIT(chan).
29 
30     3     2001/11/16 17:03 Shiki
31     Added SI_GC_STEERING.
32 
33     2     2001/10/19 13:47 Shiki
34     Added SI_GC_KEYBOARD.
35 
36     1    2001/09/03 14:39 Shiki
37     Initial check-in.
38   $NoKeywords: $
39  *---------------------------------------------------------------------------*/
40 
41 #ifndef __OS_SERIAL_H__
42 #define __OS_SERIAL_H__
43 
44 #include <revolution/types.h>
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #define SI_MAX_CHAN             4
51 #define SI_MAX_COMCSR_INLNGTH   128
52 #define SI_MAX_COMCSR_OUTLNGTH  128
53 
54 #define SI_ERROR_UNDER_RUN      0x0001
55 #define SI_ERROR_OVER_RUN       0x0002
56 #define SI_ERROR_COLLISION      0x0004
57 #define SI_ERROR_NO_RESPONSE    0x0008
58 #define SI_ERROR_WRST           0x0010
59 #define SI_ERROR_RDST           0x0020
60 
61 #define SI_ERROR_UNKNOWN        0x0040
62 #define SI_ERROR_BUSY           0x0080
63 
64 #define SI_CHAN0                0
65 #define SI_CHAN1                1
66 #define SI_CHAN2                2
67 #define SI_CHAN3                3
68 
69 #define SI_CHAN0_BIT            0x80000000
70 #define SI_CHAN1_BIT            0x40000000
71 #define SI_CHAN2_BIT            0x20000000
72 #define SI_CHAN3_BIT            0x10000000
73 #define SI_CHAN_BIT(chan)       (SI_CHAN0_BIT >> (chan))
74 
75 //
76 // CMD_TYPE_AND_STATUS response data
77 //
78 #define SI_TYPE_MASK            0x18000000u
79 #define SI_TYPE_N64             0x00000000u
80 #define SI_TYPE_DOLPHIN         0x08000000u
81 #define SI_TYPE_GC              SI_TYPE_DOLPHIN
82 
83 // Nintendo GameCube specific
84 #define SI_GC_WIRELESS          0x80000000u
85 #define SI_GC_NOMOTOR           0x20000000u // no rumble motor
86 #define SI_GC_STANDARD          0x01000000u // dolphin standard controller
87 
88 // WaveBird specific
89 #define SI_WIRELESS_RECEIVED    0x40000000u // 0: no wireless unit
90 #define SI_WIRELESS_IR          0x04000000u // 0: IR  1: RF
91 #define SI_WIRELESS_STATE       0x02000000u // 0: variable  1: fixed
92 #define SI_WIRELESS_ORIGIN      0x00200000u // 0: invalid  1: valid
93 #define SI_WIRELESS_FIX_ID      0x00100000u // 0: not fixed  1: fixed
94 #define SI_WIRELESS_TYPE        0x000f0000u
95 #define SI_WIRELESS_LITE_MASK   0x000c0000u // 0: normal 1: lite controller
96 #define SI_WIRELESS_LITE        0x00040000u // 0: normal 1: lite controller
97 #define SI_WIRELESS_CONT_MASK   0x00080000u // 0: non-controller 1: non-controller
98 #define SI_WIRELESS_CONT        0x00000000u
99 #define SI_WIRELESS_ID          0x00c0ff00u
100 #define SI_WIRELESS_TYPE_ID     (SI_WIRELESS_TYPE | SI_WIRELESS_ID)
101 
102 #define SI_N64_CONTROLLER       (SI_TYPE_N64 | 0x05000000)
103 #define SI_N64_MIC              (SI_TYPE_N64 | 0x00010000)
104 #define SI_N64_KEYBOARD         (SI_TYPE_N64 | 0x00020000)
105 #define SI_N64_MOUSE            (SI_TYPE_N64 | 0x02000000)
106 #define SI_GBA                  (SI_TYPE_N64 | 0x00040000)
107 #define SI_GC_CONTROLLER        (SI_TYPE_GC | SI_GC_STANDARD)
108 #define SI_GC_RECEIVER          (SI_TYPE_GC | SI_GC_WIRELESS)
109 #define SI_GC_WAVEBIRD          (SI_TYPE_GC | SI_GC_WIRELESS | SI_GC_STANDARD | SI_WIRELESS_STATE | SI_WIRELESS_FIX_ID)
110 #define SI_GC_KEYBOARD          (SI_TYPE_GC | 0x00200000)
111 #define SI_GC_STEERING          (SI_TYPE_GC | 0x00000000)
112 
113 u32   SIProbe              ( s32 chan );
114 char* SIGetTypeString      ( u32 type );
115 void  SIRefreshSamplingRate( void );
116 void  SISetSamplingRate    ( u32 msec );
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif  // __OS_SERIAL_H__
123