Skip to content

Commit

Permalink
No longer fails, did not change anything
Browse files Browse the repository at this point in the history
probably the probleme was the wire connecting gpoi17 to gnd ?
  • Loading branch information
FabienTregan committed Jan 3, 2025
1 parent a46f8ac commit 0244211
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/addons/psx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ void PsxAddon::setup() {

// Called after the gamepad is read, but before the read values are processed
void PsxAddon::preprocess() {
Gamepad *gamepad = Storage::getInstance().GetGamepad();

// Blinks the LED on pin 25 to check that the Addon is still alive.
/*
gpio_init(25);
gpio_disable_pulls(25);
gpio_set_dir(25, GPIO_OUT);
gpio_put(25, !(to_ms_since_boot(get_absolute_time()) & (256 | 64)));
*/

takeAttention();

Expand All @@ -84,6 +91,8 @@ void PsxAddon::preprocess() {
uint8_t answer1 = readwrite(0x00); // MSB [LEFT] [DOWN] [RGHT] [ UP ] [STRT] [ ] [ ] [SLCT] LSB
uint8_t answer2 = readwrite(0x00); // MSB [ [] ] [ X ] [ O ] [ /\ ] [ R1 ] [ L1 ] [ R2 ] [ L2 ] LSB (bits are sent LSB first on protocol but read MSB first by the function)

Gamepad *gamepad = Storage::getInstance().GetGamepad();

gamepad->state.buttons =
0
| ((answer2 & 0b01000000) ? 0 : GAMEPAD_MASK_B1)
Expand Down Expand Up @@ -135,15 +144,15 @@ uint8_t PsxAddon::readwrite(uint8_t sent) {
sent = sent >> 1;

gpio_put(clockPin, 0);
sleep_us(2);
sleep_us(1);
gpio_put(clockPin, 1);

sleep_us(1);

// instead of reading on rising edge of clock, we read as late as possible, just before setting clock low again
// because on some controllers, signal needs time to raise from 0V.
received = received >> 1;
received |= gpio_get(dataPin) ? 0b10000000 : 0;
sleep_us(1);

}

return received;
}
}

0 comments on commit 0244211

Please sign in to comment.