File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -68,26 +68,26 @@ static void nunchuk_init() {
68
68
// Change TWI speed for nuchuk, which uses Fast-TWI (400kHz)
69
69
// Normally this will be set in twi_init(), but this hack works without modifying the original source
70
70
Wire .setClock (400000 );
71
-
71
+
72
72
// delay(1);
73
73
74
74
#ifdef NUNCHUK_DISABLE_ENCRYPTION
75
75
I2C_START (NUNCHUK_ADDRESS );
76
76
I2C_WRITE (0xF0 );
77
77
I2C_WRITE (0x55 );
78
78
I2C_STOP ();
79
- // delay(1)
79
+ // delay(1);
80
80
I2C_START (NUNCHUK_ADDRESS );
81
81
I2C_WRITE (0xFB );
82
82
I2C_WRITE (0x00 );
83
83
I2C_STOP ();
84
- // delay(1)
84
+ // delay(1);
85
85
#else
86
86
I2C_START (NUNCHUK_ADDRESS );
87
87
I2C_WRITE (0x40 );
88
88
I2C_WRITE (0x00 );
89
89
I2C_STOP ();
90
- // delay(1)
90
+ // delay(1);
91
91
#endif
92
92
93
93
#ifdef NUNCHUK_DEBUG
@@ -132,19 +132,18 @@ static inline uint8_t nunchuk_decode_byte(uint8_t x) {
132
132
*/
133
133
static uint8_t nunchuk_read () {
134
134
135
- I2C_START (NUNCHUK_ADDRESS );
136
- I2C_WRITE (0x00 );
137
- #ifdef NUNCHUK_DELAY
138
- delayMicroseconds (100 );
139
- #endif
140
- I2C_STOP ();
141
-
142
135
uint8_t i ;
143
136
Wire .requestFrom (NUNCHUK_ADDRESS , 6 );
144
137
//delayMicroseconds(10);
145
138
for (i = 0 ; i < 6 && Wire .available (); i ++ ) {
146
139
nunchuk_data [i ] = nunchuk_decode_byte (I2C_READ ());
147
140
}
141
+ I2C_START (NUNCHUK_ADDRESS );
142
+ I2C_WRITE (0x00 );
143
+ #ifdef NUNCHUK_DELAY
144
+ delayMicroseconds (100 );
145
+ #endif
146
+ I2C_STOP ();
148
147
return i == 6 ;
149
148
}
150
149
You can’t perform that action at this time.
0 commit comments