Pārlūkot izejas kodu

ZuluSCSI Pico firmware working

Initiator mode is working, and the dip switch reading are now correct.
Morio 2 gadi atpakaļ
vecāks
revīzija
6e8ce60b47

+ 1 - 5
.gitignore

@@ -1,6 +1,2 @@
 .pio
-.vscode/.browse.c_cpp.db*
-.vscode/c_cpp_properties.json
-.vscode/launch.json
-.vscode/ipch
-.vscode/extensions.json
+.vscode

+ 8 - 0
lib/ZuluSCSI_platform_RP2040/ZuluSCSI_platform.cpp

@@ -126,8 +126,14 @@ void platform_init()
 
     delay(10); // 10 ms delay to let pull-ups do their work
 
+// On the ZuluSCSI Pico dbg and term readings are flipped
+# ifdef ZULUSCSI_PICO
+    bool dbglog = gpio_get(DIP_DBGLOG);
+    bool termination = gpio_get(DIP_TERM);
+# else
     bool dbglog = !gpio_get(DIP_DBGLOG);
     bool termination = !gpio_get(DIP_TERM);
+# endif
 #else
     delay(10);
 #endif
@@ -329,6 +335,8 @@ void platform_late_init()
         gpio_conf(SCSI_IN_REQ,    GPIO_FUNC_SIO, true ,false, false, true, false);
         gpio_conf(SCSI_IN_BSY,    GPIO_FUNC_SIO, true, false, false, true, false);
         gpio_conf(SCSI_IN_RST,    GPIO_FUNC_SIO, true, false, false, true, false);
+        // Reinitialize OUT_RST to output mode. On RP Pico variant the pin is shared with IN_RST.
+        gpio_conf(SCSI_OUT_RST,   GPIO_FUNC_SIO, false, false, true,  true, true);
         gpio_conf(SCSI_OUT_SEL,   GPIO_FUNC_SIO, false,false, true,  true, true);
         gpio_conf(SCSI_OUT_ACK,   GPIO_FUNC_SIO, false,false, true,  true, true);
         gpio_conf(SCSI_OUT_ATN,   GPIO_FUNC_SIO, false,false, true,  true, true);

+ 4 - 4
lib/ZuluSCSI_platform_RP2040/ZuluSCSI_platform_gpio_Pico.h

@@ -65,7 +65,7 @@
 
 // Status line inputs for initiator mode
 #define SCSI_IN_IO    22
-#define SCSI_IN_CD    24
+#define SCSI_IN_CD    18
 #define SCSI_IN_MSG   20
 #define SCSI_IN_REQ   17
 
@@ -102,9 +102,9 @@
 
 // DIP switch pins
 #define HAS_DIP_SWITCHES
-#define DIP_INITIATOR 26
-#define DIP_DBGLOG 16
-#define DIP_TERM 17
+#define DIP_INITIATOR 28
+#define DIP_DBGLOG 20
+#define DIP_TERM 18
 
 // Other pins
 #define SWO_PIN 16

+ 6 - 3
lib/ZuluSCSI_platform_RP2040/run_pioasm.sh

@@ -6,6 +6,9 @@ pioasm sdio_RP2040.pio sdio_RP2040.pio.h
 pioasm sdio_Pico.pio sdio_Pico.pio.h
 pioasm sdio_BS2.pio sdio_BS2.pio.h
 
-pioasm scsi_accel_RP2040.pio scsi_accel.pio_RP2040.h
-pioasm scsi_accel_Pico.pio scsi_accel_Pico.pio.h
-pioasm scsi_accel_BS2.pio scsi_accel_BS2.pio.h
+pioasm scsi_accel_target_RP2040.pio scsi_accel_target_RPP2040.pio.h
+pioasm scsi_accel_target_Pico.pio scsi_accel_target_Pico.pio.h
+pioasm scsi_accel_target_BS2.pio scsi_accel_target_BS2.pio.h
+
+pioasm scsi_accel_host_RP2040.pio scsi_accel_host_RP2040.pio.h
+pioasm scsi_accel_host_Pico.pio scsi_accel_host_Pico.pio.h

+ 9 - 5
lib/ZuluSCSI_platform_RP2040/scsi_accel_host.cpp

@@ -30,12 +30,13 @@
 #include <hardware/structs/iobank0.h>
 #include <hardware/sync.h>
 
-#ifdef ZULUSCSI_RP2040
+#ifdef PLATFORM_HAS_INITIATOR_MODE
+#ifdef ZULUSCSI_PICO
 #include "scsi_accel_host_Pico.pio.h"
 #else
 #include "scsi_accel_host_RP2040.pio.h"
 #endif
-#ifdef PLATFORM_HAS_INITIATOR_MODE
+
 
 #define SCSI_PIO pio0
 #define SCSI_SM 0
@@ -63,14 +64,16 @@ static void scsi_accel_host_config_gpio()
         iobank0_hw->io[SCSI_IO_DB6].ctrl  = GPIO_FUNC_SIO;
         iobank0_hw->io[SCSI_IO_DB7].ctrl  = GPIO_FUNC_SIO;
         iobank0_hw->io[SCSI_IO_DBP].ctrl  = GPIO_FUNC_SIO;
+        iobank0_hw->io[SCSI_IN_REQ].ctrl  = GPIO_FUNC_SIO;
         iobank0_hw->io[SCSI_OUT_ACK].ctrl = GPIO_FUNC_SIO;
     }
     else if (g_scsi_host_state == SCSIHOST_READ)
     {
         // Data bus and REQ as input, ACK pin as output
-        pio_sm_set_pins(SCSI_PIO, SCSI_SM, 0x7FF);
-        pio_sm_set_consecutive_pindirs(SCSI_PIO, SCSI_SM, 0, 10, false);
-        pio_sm_set_consecutive_pindirs(SCSI_PIO, SCSI_SM, 10, 1, true);
+        pio_sm_set_pins(SCSI_PIO, SCSI_SM, SCSI_IO_DATA_MASK | 1 << SCSI_IN_REQ | 1 << SCSI_OUT_ACK);
+        pio_sm_set_consecutive_pindirs(SCSI_PIO, SCSI_SM, SCSI_IO_DB0, 9, false);
+        pio_sm_set_consecutive_pindirs(SCSI_PIO, SCSI_SM, SCSI_IN_REQ, 1, false);
+        pio_sm_set_consecutive_pindirs(SCSI_PIO, SCSI_SM, SCSI_OUT_ACK, 1, true);
 
         iobank0_hw->io[SCSI_IO_DB0].ctrl  = GPIO_FUNC_SIO;
         iobank0_hw->io[SCSI_IO_DB1].ctrl  = GPIO_FUNC_SIO;
@@ -81,6 +84,7 @@ static void scsi_accel_host_config_gpio()
         iobank0_hw->io[SCSI_IO_DB6].ctrl  = GPIO_FUNC_SIO;
         iobank0_hw->io[SCSI_IO_DB7].ctrl  = GPIO_FUNC_SIO;
         iobank0_hw->io[SCSI_IO_DBP].ctrl  = GPIO_FUNC_SIO;
+        iobank0_hw->io[SCSI_IN_REQ].ctrl  = GPIO_FUNC_SIO;
         iobank0_hw->io[SCSI_OUT_ACK].ctrl = GPIO_FUNC_PIO0;
     }
 }

+ 2 - 2
lib/ZuluSCSI_platform_RP2040/scsi_accel_host_Pico.pio

@@ -25,8 +25,8 @@
 ; -   8: DBP
 ; Side set is ACK pin
 
-.define REQ 9
-.define ACK 10
+.define REQ 17
+.define ACK 26
 
 ; Read from SCSI bus using asynchronous handshake.
 ; Data is returned as 16-bit words that contain the 8 data bits + 1 parity bit.

+ 2 - 3
lib/ZuluSCSI_platform_RP2040/scsi_accel_host_Pico.pio.h

@@ -19,10 +19,10 @@ static const uint16_t scsi_host_async_read_program_instructions[] = {
             //     .wrap_target
     0x90a0, //  0: pull   block           side 1     
     0xb027, //  1: mov    x, osr          side 1     
-    0x3009, //  2: wait   0 gpio, 9       side 1     
+    0x3011, //  2: wait   0 gpio, 17      side 1     
     0x4009, //  3: in     pins, 9         side 0     
     0x4067, //  4: in     null, 7         side 0     
-    0x2089, //  5: wait   1 gpio, 9       side 0     
+    0x2091, //  5: wait   1 gpio, 17      side 0     
     0x1042, //  6: jmp    x--, 2          side 1     
             //     .wrap
 };
@@ -41,4 +41,3 @@ static inline pio_sm_config scsi_host_async_read_program_get_default_config(uint
     return c;
 }
 #endif
-