Per Mårtensson vor 8 Monaten
Ursprung
Commit
0259c8553c
5 geänderte Dateien mit 76 neuen und 4 gelöschten Zeilen
  1. 1 1
      inc/util.h
  2. 14 0
      src/board.c
  3. 47 3
      src/floppy.c
  4. 9 0
      src/mcu/stm32f7/board.c
  5. 5 0
      src/mcu/stm32f7/floppy.c

+ 1 - 1
inc/util.h

@@ -79,7 +79,7 @@ uint32_t udiv64(uint64_t dividend, uint32_t divisor);
 /* Board-specific callouts */
 void board_init(void);
 void act_led(bool_t on);
-
+void act_led2(bool_t on);
 #ifndef NDEBUG
 
 /* Serial console control */

+ 14 - 0
src/board.c

@@ -92,6 +92,9 @@ void board_init(void)
 
     /* Activity LED is active low. */
     gpio_configure_pin(gpio_led, pin_led, GPO_pushpull(IOSPD_LOW, HIGH));
+#if MCU == STM32F7
+    gpio_configure_pin(gpio_led2, pin_led2, GPO_pushpull(IOSPD_LOW, HIGH));
+#endif
 #if defined(NDEBUG) && MCU == AT32F4
     if ((gw_info.hw_submodel == F4SM_v4) && (at32f4_series != AT32F415)) {
         /* GW V4 with 403(A) MCU duplicates Activity LED signal on pin TXO. */
@@ -109,6 +112,17 @@ void act_led(bool_t on)
         gpio_write_pin(gpioa, 9, on ? LOW : HIGH);
 #endif
 }
+#if MCU == STM32F7
+/* Set the activity LED status. */
+void act_led2(bool_t on)
+{
+    gpio_write_pin(gpio_led2, pin_led2, on ? LOW : HIGH);
+#if defined(NDEBUG) && MCU == AT32F4
+    if (at32f4_series != AT32F415)
+        gpio_write_pin(gpioa, 9, on ? LOW : HIGH);
+#endif
+}
+#endif 
 
 /*
  * Local variables:

+ 47 - 3
src/floppy.c

@@ -14,7 +14,11 @@
 #define get_index()   gpio_read_pin(gpio_index, pin_index)
 #define get_trk0()    gpio_read_pin(gpio_trk0, pin_trk0)
 #define get_wrprot()  gpio_read_pin(gpio_wrprot, pin_wrprot)
-
+#if MCU == STM32F7
+#define get_tg43_0()  gpio_read_pin(gpio_tr43, pin_tr43_0)
+#define get_tg43_1()  gpio_read_pin(gpio_tr43, pin_tr43_1)
+#define get_wgate()  gpio_read_pin(gpio_wgate, pin_wgate)
+#endif
 #define configure_pin(pin, type) \
     gpio_configure_pin(gpio_##pin, pin_##pin, type)
 
@@ -29,6 +33,7 @@
 
 static int bus_type = -1;
 static int unit_nr = -1;
+
 static struct unit {
     int cyl;
     bool_t initialised;
@@ -337,12 +342,44 @@ static void step_dir_set(bool_t assert)
 }
 #define step_dir_out() step_dir_set(FALSE)
 #define step_dir_in() step_dir_set(TRUE)
+#if MCU == STM32F7
+static void get_tg43_info(void){
+    struct unit *u;
+    int active=0;
+    int writing = 0;
+
+    if (unit_nr==0){
+        active= get_tg43_0();
+    }else{
+        active= get_tg43_1();
+    }
+    writing=get_wgate();
+    u = &unit[unit_nr];
+        if (u->cyl>=43 && !active && !writing){ /* Check TR43*/
+            act_led2(TRUE);
+            gpio_write_pin(gpio_dsel, pin_dsel, HIGH);
+        }else{
+            act_led2(FALSE);
+            gpio_write_pin(gpio_dsel, pin_dsel, LOW);
+        }
+        if (u->cyl>=60 && !active && writing){ /* Check TR43*/
+            act_led2(TRUE);
+            gpio_write_pin(gpio_dsel, pin_dsel, HIGH);
+        }else{
+            act_led2(FALSE);
+            gpio_write_pin(gpio_dsel, pin_dsel, LOW);
+        }
 
+}
+#endif
 static void step_once(void)
 {
     write_pin(step, TRUE);
     delay_us(15);
     write_pin(step, FALSE);
+#if MCU == STM32F7
+    get_tg43_info();
+#endif
     delay_us(delay_params.step_delay);
 }
 
@@ -354,8 +391,9 @@ static uint8_t floppy_seek_initialise(struct unit *u)
     /* Synchronise to cylinder 0. */
     step_dir_out();
     for (nr = 0; nr < 256; nr++) {
-        if (get_trk0() == LOW)
+        if (get_trk0() == LOW){
             goto found_cyl0;
+        }
         step_once();
     }
 
@@ -425,6 +463,10 @@ static uint8_t floppy_seek(int cyl)
         nr = u->cyl - cyl;
         step_dir_out();
     } else /* u->cyl == cyl */ {
+#if MCU == STM32F7
+        u->cyl = cyl;
+        get_tg43_info();
+#endif
         return ACK_OKAY;
     }
 
@@ -435,7 +477,9 @@ static uint8_t floppy_seek(int cyl)
 
     delay_ms(delay_params.seek_settle);
     u->cyl = cyl;
-
+#if MCU == STM32F7
+    get_tg43_info();
+#endif
     return ACK_OKAY;
 }
 

+ 9 - 0
src/mcu/stm32f7/board.c

@@ -11,6 +11,11 @@
 
 #define gpio_led gpiob
 #define pin_led 13
+#define gpio_led2 gpioe
+#define pin_led2 1
+#define gpio_tr43 gpioe
+#define pin_tr43_0 12
+#define pin_tr43_1 11
 
 const static struct pin_mapping _msel_pins_std[] = {
     { 10, _B,  1 },
@@ -140,6 +145,10 @@ void identify_board_config(void)
     early_delay_us(10);
     low = (~gpioc->idr >> 13) & 7;
 
+    /* Setup input pins for TR43 more fixes below needed */
+    gpio_configure_pin(gpio_tr43, pin_tr43_0, GPI_pull_up);
+    gpio_configure_pin(gpio_tr43, pin_tr43_1, GPI_pull_up);
+
     /* Each PCx pin defines a 'trit': 0=float, 1=low, 2=high. 
      * We build a 3^3 ID space from the resulting three-trit ID. */
     for (i = 0; i < 3; i++) {

+ 5 - 0
src/mcu/stm32f7/floppy.c

@@ -27,6 +27,9 @@ static unsigned int AFO_bus;
 #define pin_trk0    3 /* PA3 */
 #define gpio_wrprot gpioa
 #define pin_wrprot  1 /* PA1 */
+#define gpio_tr43 gpioe
+#define pin_tr43_0 12 /* PE12 */
+#define pin_tr43_1 11 /* PE11 */
 
 /* Output pins. */
 #define gpio_dir   gpioc
@@ -37,6 +40,8 @@ static unsigned int AFO_bus;
 #define pin_wgate  6  /* PA6 */
 #define gpio_head  gpioc
 #define pin_head   3  /* PC3 */
+#define gpio_dsel  gpiob
+#define pin_dsel   12  /* PB12 */
 
 /* RDATA: Pin A0, Timer 2 Channel 1, DMA1 Stream 5 Channel 3. */
 #define gpio_rdata  gpioa