diff --git a/examples/FF.CFG b/examples/FF.CFG index 29d21747..7c73c772 100644 --- a/examples/FF.CFG +++ b/examples/FF.CFG @@ -51,7 +51,9 @@ host = unspecified # ndens: Logical complement of above # chg: Disk changed (Changed = 0v) # nchg: Logical complement of above -# Values: auto, nc, low, high, rdy, nrdy, dens, ndens, chg, nchg +# in: Disk inserted (Inserted = 0v), ignores drive-select +# nin: Logical complement of above +# Values: auto, nc, low, high, rdy, nrdy, dens, ndens, chg, nchg, in, nin pin02 = auto pin34 = auto diff --git a/inc/config.h b/inc/config.h index d0f7f586..e0ecc642 100644 --- a/inc/config.h +++ b/inc/config.h @@ -131,11 +131,13 @@ struct packed ff_cfg { #define PIN_rdy (outp_rdy + 1) #define PIN_dens (outp_hden + 1) #define PIN_chg (outp_dskchg + 1) +#define PIN_in (outp_in + 1) #define PIN_invert 0x80 #define PIN_low (PIN_high | PIN_invert) #define PIN_nrdy (PIN_rdy | PIN_invert) #define PIN_ndens (PIN_dens | PIN_invert) #define PIN_nchg (PIN_chg | PIN_invert) +#define PIN_nin (PIN_in | PIN_invert) uint8_t pin02, pin34; uint8_t head_settle_ms; uint8_t oled_contrast; diff --git a/inc/floppy.h b/inc/floppy.h index 4260fe0e..4613616e 100644 --- a/inc/floppy.h +++ b/inc/floppy.h @@ -35,7 +35,8 @@ #define outp_wrprot 3 #define outp_rdy 4 #define outp_hden 5 -#define outp_nr 6 +#define outp_in 6 +#define outp_nr 7 #define outp_unused outp_nr #define verbose_image_log FALSE diff --git a/src/floppy.c b/src/floppy.c index 846113f5..bc3fced4 100644 --- a/src/floppy.c +++ b/src/floppy.c @@ -38,6 +38,7 @@ static always_inline void drive_change_pin( struct drive *drv, uint8_t pin, bool_t assert); static always_inline void drive_change_output( struct drive *drv, uint8_t outp, bool_t assert); +static void disk_inserted_output(uint8_t outp, bool_t assert); #include "floppy_generic.c" @@ -130,6 +131,18 @@ static void drive_change_output( drive_change_pin(drv, pin, assert); } +static void disk_inserted_output(uint8_t outp, bool_t assert) +{ + if (pin02 == outp) { + GPIO gpio = pin_02 < 16 ? gpiob : gpioa; + gpio_write_pin(gpio, pin_02 & 15, assert ^ pin02_inverted); + } + if (pin34 == outp) { + GPIO gpio = pin_34 < 16 ? gpiob : gpioa; + gpio_write_pin(gpio, pin_34 & 15, assert ^ pin34_inverted); + } +} + static void update_amiga_id(struct drive *drv, bool_t amiga_hd_id) { /* JC and pin 34 are overridden only for the Amiga interface. */ @@ -210,6 +223,7 @@ void floppy_cancel(void) barrier(); drive_change_output(drv, outp_index, FALSE); drive_change_output(drv, outp_dskchg, TRUE); + disk_inserted_output(outp_in, TRUE); } void floppy_set_fintf_mode(void) @@ -223,6 +237,7 @@ void floppy_set_fintf_mode(void) [FINTF_AMIGA] = "Amiga" }; static const char *const outp_name[] = { + [outp_in] = "in", [outp_dskchg] = "chg", [outp_rdy] = "rdy", [outp_hden] = "dens", @@ -320,6 +335,7 @@ void floppy_init(void) drive_change_output(drv, outp_dskchg, TRUE); drive_change_output(drv, outp_wrprot, TRUE); drive_change_output(drv, outp_trk0, TRUE); + disk_inserted_output(outp_in, TRUE); floppy_init_irqs(); @@ -352,6 +368,7 @@ void floppy_insert(unsigned int unit, struct slot *slot) update_amiga_id(drv, im->stk_per_rev > stk_ms(300)); if (!(slot->attributes & AM_RDO)) drive_change_output(drv, outp_wrprot, FALSE); + disk_inserted_output(outp_in, FALSE); barrier(); drv->inserted = TRUE; motor_chgrst_update_status(drv); /* update RDY + motor state */ diff --git a/src/gotek/floppy.c b/src/gotek/floppy.c index 68562871..88779f7e 100644 --- a/src/gotek/floppy.c +++ b/src/gotek/floppy.c @@ -305,8 +305,9 @@ static void IRQ_STEP_changed(void) /* Deassert DSKCHG if a disk is inserted. */ if ((drv->outp & m(outp_dskchg)) && drv->inserted - && (ff_cfg.chgrst == CHGRST_step)) + && (ff_cfg.chgrst == CHGRST_step)) { drive_change_output(drv, outp_dskchg, FALSE); + } /* Do we accept this STEP command? */ if ((drv->step.state & STEP_active) /* Already mid-step? */ diff --git a/src/main.c b/src/main.c index 433bc922..23508376 100644 --- a/src/main.c +++ b/src/main.c @@ -911,6 +911,7 @@ static uint8_t parse_pin_str(const char *s) : !strcmp(s, "rdy") ? PIN_rdy : !strcmp(s, "dens") ? PIN_dens : !strcmp(s, "chg") ? PIN_chg + : !strcmp(s, "in") ? PIN_in : PIN_auto; return pin; }