Browse Source

floppy: Remove delayed-index option from WRITE_FLUX command.
We will deal with non-index write splice instead by writing more
than one full revolution, but starting at index always.

Keir Fraser 4 years ago
parent
commit
773e9933dd
5 changed files with 3 additions and 43 deletions
  1. 1 2
      inc/cdc_acm_protocol.h
  2. 1 1
      scripts/greaseweazle/usb.py
  3. 1 34
      src/floppy.c
  4. 0 3
      src/floppy_f1.c
  5. 0 3
      src/floppy_f7.c

+ 1 - 2
inc/cdc_acm_protocol.h

@@ -33,7 +33,7 @@
 /* CMD_READ_FLUX, length=2-3. Optionally include all or part of gw_read_flux.
  * Returns flux readings until EOStream. */
 #define CMD_READ_FLUX       7
-/* CMD_WRITE_FLUX, length=2-7. Optionally include all or part of gw_write_flux.
+/* CMD_WRITE_FLUX, length=2-3. Optionally include all or part of gw_write_flux.
  * Host follows with flux readings until EOStream. */
 #define CMD_WRITE_FLUX      8
 /* CMD_GET_FLUX_STATUS, length=2. Last read/write status returned in ACK. */
@@ -110,7 +110,6 @@ struct packed gw_read_flux {
 
 /* CMD_WRITE_FLUX */
 struct packed gw_write_flux {
-    uint32_t index_delay_ticks; /* default: 0 */
     uint8_t terminate_at_index; /* default: 0 */
 };
 

+ 1 - 1
scripts/greaseweazle/usb.py

@@ -355,7 +355,7 @@ class Unit:
         while True:
             try:
                 # Write the flux stream to the track via Greaseweazle.
-                self._send_cmd(struct.pack("<2BIB", Cmd.WriteFlux, 7, 0, 1))
+                self._send_cmd(struct.pack("3B", Cmd.WriteFlux, 3, 1))
                 self.ser.write(dat)
                 self.ser.read(1) # Sync with Greaseweazle
                 self._send_cmd(struct.pack("2B", Cmd.GetFluxStatus, 2))

+ 1 - 34
src/floppy.c

@@ -54,14 +54,8 @@ static struct index {
     volatile unsigned int count;
     /* For synchronising index pulse reporting to the RDATA flux stream. */
     volatile unsigned int rdata_cnt;
-    /* Following fields are for delayed-index writes. */
-    unsigned int delay;
-    struct timer delay_timer;
-    time_t timestamp;
 } index;
 
-static void index_delay_timer(void *unused);
-
 /* A DMA buffer for running a timer associated with a floppy-data I/O pin. */
 static struct dma_ring {
     /* Indexes into the buf[] ring buffer. */
@@ -237,9 +231,6 @@ void floppy_init(void)
     configure_pin(wrprot, GPI_bus);
 
     /* Configure INDEX-changed IRQs and timer. */
-    timer_init(&index.delay_timer, index_delay_timer, NULL);
-    IRQx_set_prio(irq_index_delay, TIMER_IRQ_PRI);
-    IRQx_enable(irq_index_delay);
     exti->rtsr = 0;
     exti->imr = exti->ftsr = m(pin_index);
     IRQx_set_prio(irq_index, INDEX_IRQ_PRI);
@@ -611,7 +602,6 @@ static uint8_t floppy_write_prep(struct gw_write_flux *wf)
     memset(&rw, 0, sizeof(rw));
     rw.status = ACK_OKAY;
 
-    index.delay = time_from_samples(wf->index_delay_ticks);
     rw.terminate_at_index = wf->terminate_at_index;
 
     return ACK_OKAY;
@@ -742,13 +732,6 @@ static void floppy_write_drain(void)
     u_buf[0] = rw.status;
     floppy_state = ST_command_wait;
     floppy_end_command(u_buf, 1);
-
-    /* Reset INDEX handling. */
-    IRQ_global_disable();
-    index.delay = 0;
-    IRQx_clear_pending(irq_index_delay);
-    timer_cancel(&index.delay_timer);
-    IRQ_global_enable();
 }
 
 static void process_command(void)
@@ -990,29 +973,13 @@ const struct usb_class_ops usb_cdc_acm_ops = {
  * INTERRUPT HANDLERS
  */
 
-static void index_delay_timer(void *unused)
-{
-    index.count++;
-}
-
-static void IRQ_INDEX_delay(void)
-{
-    timer_set(&index.delay_timer, index.timestamp + index.delay);
-}
-
 static void IRQ_INDEX_changed(void)
 {
     /* Clear INDEX-changed flag. */
     exti->pr = m(pin_index);
 
+    index.count++;
     index.rdata_cnt = tim_rdata->cnt;
-    index.timestamp = time_now();
-
-    if (index.delay != 0) {
-        IRQx_set_pending(irq_index_delay);
-    } else {
-        index.count++;
-    }
 }
 
 /*

+ 0 - 3
src/floppy_f1.c

@@ -57,9 +57,6 @@ typedef uint16_t timcnt_t;
 #define irq_index 23
 void IRQ_23(void) __attribute__((alias("IRQ_INDEX_changed"))); /* EXTI9_5 */
 
-#define irq_index_delay 31
-void IRQ_31(void) __attribute__((alias("IRQ_INDEX_delay")));
-
 static void floppy_mcu_init(void)
 {
     /* Determine whether input pins must be internally pulled down. */

+ 0 - 3
src/floppy_f7.c

@@ -61,9 +61,6 @@ typedef uint32_t timcnt_t;
 #define irq_index 8
 void IRQ_8(void) __attribute__((alias("IRQ_INDEX_changed"))); /* EXTI2 */
 
-#define irq_index_delay 31
-void IRQ_31(void) __attribute__((alias("IRQ_INDEX_delay")));
-
 static void floppy_mcu_init(void)
 {
     /* Enable clock for Timer 2. */