summaryrefslogtreecommitdiff
path: root/i2c/wii_nunchuk/README
blob: d2355549eb1a1e408a85d8115b623ee85b1f5bde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
-------------------------------------------------------------------------------
Nintendo Wii Nunchuk controller
-------------------------------------------------------------------------------

This is a collection of example captures of I2C traffic from/to a Nintendo
Wii Nunchuk game controller.

A Dangerous Prototypes Buspirate (v4) was used as I2C master to talk to the
Nunchuk controller.

Details:
https://en.wikipedia.org/wiki/Wiimote#Nunchuk
http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Nunchuck
http://dangerousprototypes.com/docs/Bus_Pirate
http://dangerousprototypes.com/2009/08/19/bus-pirate-wii-nunchuck-quick-guide/


Logic analyzer setup
--------------------

The logic analyzer used was a Saleae Logic (at 1MHz):

  Probe       I2C pin
  -------------------
  3 (red)     SCL
  7 (blue)    SDA


Buspirate setup
---------------

Connections:

  Buspirate   Nunchuk I2C breakout adapter
  ----------------------------------------
  GND         - (GND)
  +3.3        + (VCC)
  MOSI        d (SDA)
  CLK         c (SCL)

The basic setup after connecting to the Buspirate on /dev/ttyACM0
(115200, 8n1) via minicom was:

  HiZ>m (mode)
  (1)>4 (I2C)
  (1)>2 (I2C mode: hardware)
  (1)>1 (speed: 100kHz)
  I2C>W (enable Buspirate power supplies)

See below for further per-file I2C commands used.


sigrok
------

The sigrok command line used was:

  sigrok-cli -d fx2lafw:samplerate=1mhz --time <ms> \
             -p '3=SCL,7=SDA' -o <filename>

The <ms> and <filename> parameters vary depending on the file.


wii_nunchuk_init.sr
-------------------

I2C>[0xa4 0x40 0x00]
I2C START BIT
WRITE: 0xA4 ACK
WRITE: 0x40 ACK
WRITE: 0x00 ACK
I2C STOP BIT


wii_nunchuk_set_reg.sr
----------------------

I2C>[0xa4 0x00]
I2C START BIT
WRITE: 0xA4 ACK
WRITE: 0x00 ACK
I2C STOP BIT


wii_nunchuk_data_idle.sr
------------------------

No buttons were pressed, the analog stick was not moved.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x74  ACK 0x7F  ACK 0x7B  ACK 0x20  ACK 0x7D  ACK 0xC7
NACK


wii_nunchuk_data_left.sr
------------------------

No buttons were pressed, the analog stick was moved to the left.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x12  ACK 0x7C  ACK 0x48  ACK 0x2C  ACK 0x97  ACK 0x2F
NACK
I2C STOP BIT


wii_nunchuk_data_right.sr
-------------------------

No buttons were pressed, the analog stick was moved to the right.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0xD6  ACK 0x61  ACK 0x4E  ACK 0x28  ACK 0x93  ACK 0x2B
NACK
I2C STOP BIT


wii_nunchuk_data_top.sr
-----------------------

No buttons were pressed, the analog stick was moved to the top.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x74  ACK 0x7E  ACK 0x8E  ACK 0x70  ACK 0x48  ACK 0x97
NACK
I2C STOP BIT


wii_nunchuk_data_bottom.sr
--------------------------

No buttons were pressed, the analog stick was moved to the bottom.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x75  ACK 0x19  ACK 0x43  ACK 0x2F  ACK 0x65  ACK 0xA3
NACK
I2C STOP BIT


wii_nunchuk_button_c.sr
-----------------------

The C button was pressed.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x75  ACK 0x7F  ACK 0x70  ACK 0x56  ACK 0x9F  ACK 0xED
NACK
I2C STOP BIT


wii_nunchuk_button_z.sr
-----------------------

The Z button was pressed.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x75  ACK 0x7F  ACK 0x80  ACK 0x78  ACK 0x64  ACK 0x6C
NACK
I2C STOP BIT


wii_nunchuk_orientation_vertical_top.sr
---------------------------------------

The Nunchuk was in vertical ("normal") position.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x75  ACK 0x7F  ACK 0x81  ACK 0x78  ACK 0x63  ACK 0x5F
NACK
I2C STOP BIT


wii_nunchuk_orientation_vertical_bottom.sr
------------------------------------------

The Nunchuk was in vertical position, help upside-down.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x75  ACK 0x7F  ACK 0x71  ACK 0x83  ACK 0x5D  ACK 0xD3
NACK
I2C STOP BIT


wii_nunchuk_orientation_horizontal_left.sr
------------------------------------------

The Nunchuk was in horizontal position, pointing to the left.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x75  ACK 0x7F  ACK 0x25  ACK 0x7E  ACK 0x7B  ACK 0xEB
NACK
I2C STOP BIT


wii_nunchuk_orientation_horizontal_right.sr
-------------------------------------------

The Nunchuk was in horizontal position, pointing to the right.

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x75  ACK 0x7F  ACK 0x8F  ACK 0x7E  ACK 0x75  ACK 0x4B
NACK
I2C STOP BIT


wii_nunchuk_init_reg_3xdata.sr
------------------------------

I2C>[0xa4 0x40 0x00]
I2C START BIT
WRITE: 0xA4 ACK
WRITE: 0x40 ACK
WRITE: 0x00 ACK
I2C STOP BIT

I2C>[0xa4 0x00]
I2C START BIT
WRITE: 0xA4 ACK
WRITE: 0x00 ACK
I2C STOP BIT

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x75  ACK 0x7F  ACK 0x77  ACK 0x4F  ACK 0x82  ACK 0x3B
NACK
I2C STOP BIT

(for the above values, no button was pressed)

I2C>[0xa4 0x00]
I2C START BIT
WRITE: 0xA4 ACK
WRITE: 0x00 ACK
I2C STOP BIT

I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x75  ACK 0x7F  ACK 0x75  ACK 0x44  ACK 0x82  ACK 0x34
NACK
I2C STOP BIT

(for the above values, the Z button was pressed)

I2C>[0xa4 0x00]
I2C START BIT
WRITE: 0xA4 ACK
WRITE: 0x00 ACK
I2C STOP BIT
I2C>[0xa5 r:6]
I2C START BIT
WRITE: 0xA5 ACK
READ: 0x75  ACK 0x7F  ACK 0x77  ACK 0x43  ACK 0x83  ACK 0x5D
NACK
I2C STOP BIT

(for the above values, the C button was pressed)