Skip to content

Commit

Permalink
Gotek: No longer support physical button connection at A3-A5.
Browse files Browse the repository at this point in the history
Hold A3-A5 LOW to force users to disconnect these legacy pins.
  • Loading branch information
keirf committed Oct 9, 2019
1 parent b0e4924 commit 07f1aa7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- I2C: Bidirectional communications to Gotek
- Next FF release (v3.5a) will **REQUIRE** this firmware!
- PLEASE UPDATE!!
- Amiga: Hotkeys control Gotek buttons via I2C
- The physical connection via A3-A5 **no longer works**
- A3-A5 are held LOW to force disconnection from Gotek
- A3-A5 may be repurposed in future
- Bug fixes:
- Fixed screen corruption after saving config to Flash
- Fixed I2C corruption after saving config to Flash
Expand Down
6 changes: 3 additions & 3 deletions attic/pins.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
| 0 | | Rotary CLK | | |
| 1 | | Rotary DAT | | |
| 2 | | Rotary SW | Y | **NA** (BOOT1) |
| 3 | | Gotek Prev | Y | Amiga KB_DAT |
| 4 | | Gotek Next | Y | Amiga KB_CLK |
| 5 | | Gotek Select | | |
| 3 | | | Y | Amiga KB_DAT |
| 4 | | | Y | Amiga KB_CLK |
| 5 | | | | |
| 6 | | | Y | I2C SCL |
| 7 | | | Y | I2C SDA |
| 8 | Y | CSYNC/HSYNC | Y | User Out (U0) |
Expand Down
29 changes: 11 additions & 18 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
* B6: CLK
* B7: DAT
*
* Buttons (Gotek):
* A3: PREV/LEFT/DOWN
* A4: NEXT/RIGHT/UP
* A5: SELECT/EJECT
*
* Display:
* A8: CSYNC or HSYNC
* B14: VSYNC (only needed with HSYNC)
Expand Down Expand Up @@ -507,18 +502,16 @@ struct gotek_button {
static bool_t gotek_active;

static void emulate_gotek_button(
uint8_t keycode, struct gotek_button *button, int pin)
uint8_t keycode, struct gotek_button *button)
{
bool_t pressed = (keys & keycode) && gotek_active;
if (!(pressed ^ button->pressed))
return; /* no change */
if (pressed) {
if (!(pressed ^ button->pressed)) {
/* No change */
} else if (pressed) {
button->t = time_now();
button->pressed = TRUE;
gpio_write_pin(gpioa, pin, LOW);
} else if (time_diff(button->t, time_now()) > time_ms(200)) {
button->pressed = FALSE;
gpio_write_pin(gpioa, pin, HIGH);
}
}

Expand All @@ -529,9 +522,9 @@ static void emulate_gotek_buttons(void)
gotek_active = FALSE;
else if (!gotek_active && !keys)
gotek_active = TRUE; /* only after keys are released */
emulate_gotek_button(K_LEFT, &gl, 3);
emulate_gotek_button(K_RIGHT, &gr, 4);
emulate_gotek_button(K_SELECT, &gs, 5);
emulate_gotek_button(K_LEFT, &gl);
emulate_gotek_button(K_RIGHT, &gr);
emulate_gotek_button(K_SELECT, &gs);
if (gl.pressed) b |= B_LEFT;
if (gr.pressed) b |= B_RIGHT;
if (gs.pressed) b |= B_SELECT;
Expand Down Expand Up @@ -580,10 +573,10 @@ int main(void)
/* PB14 = VSYNC input */
gpio_configure_pin(gpio_vsync, pin_vsync, GPI_pull_up);

/* PA3,4,5: Gotek buttons */
gpio_configure_pin(gpioa, 3, GPO_opendrain(_2MHz, HIGH));
gpio_configure_pin(gpioa, 4, GPO_opendrain(_2MHz, HIGH));
gpio_configure_pin(gpioa, 5, GPO_opendrain(_2MHz, HIGH));
/* PA3,4,5: Used to be Gotek buttons. Hold LOW to force disconnection. */
gpio_configure_pin(gpioa, 3, GPO_opendrain(_2MHz, LOW));
gpio_configure_pin(gpioa, 4, GPO_opendrain(_2MHz, LOW));
gpio_configure_pin(gpioa, 5, GPO_opendrain(_2MHz, LOW));

/* Turn on the clocks. */
rcc->apb1enr |= (RCC_APB1ENR_SPI2EN
Expand Down

0 comments on commit 07f1aa7

Please sign in to comment.