Skip to content

Commit f6c71c7

Browse files
committed
auto stop bit
1 parent 1355dc8 commit f6c71c7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/gamecube.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ void GameCubeController::sendBits(uint32_t data, uint8_t bits) {
5151
bits--;
5252
while (DWT->CYCCNT < timerEnd) ;
5353
} while (bits);
54+
DWT->CYCCNT = 0;
55+
gpio_write_bit(port.device, port.pinNumber, 0);
56+
while (DWT->CYCCNT < quarterBitSendingCycles) ;
57+
DWT->CYCCNT = 0;
58+
gpio_write_bit(port.device, port.pinNumber, 1);
59+
while (DWT->CYCCNT < 2*quarterBitSendingCycles) ;
5460
}
5561

5662

@@ -170,13 +176,13 @@ bool GameCubeController::receiveBits(void* data0, uint32_t bits) {
170176
bool GameCubeController::readWithRumble(GameCubeData_t* data, bool rumble) {
171177
if (fails >= maxFails) {
172178
nvic_globalirq_disable();
173-
sendBits(0b000000001l, 9);
179+
sendBits(0b00000000l, 8);
174180
nvic_globalirq_enable();
175181
delayMicroseconds(410);
176182
fails = 0;
177183
}
178184
nvic_globalirq_disable();
179-
sendBits(rumble ? 0b0100000000000011000000011l : 0b0100000000000011000000001l, 25);
185+
sendBits(rumble ? 0b010000000000001100000001l : 0b010000000000001100000000l, 24);
180186
bool success = receiveBits(data, 64);
181187
nvic_globalirq_enable();
182188
return success;

0 commit comments

Comments
 (0)