Преглед изворни кода

Initiator mode working

Had pining assignment issue. After fixing that, bought in changes
from the pico-initiator branch for the scsi_accel_host.cpp
changes.
Morio пре 2 година
родитељ
комит
a684bc38c8

+ 3 - 1
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
 
@@ -90,9 +90,11 @@
 #define SD_SPI_CS    15
 
 #ifndef ENABLE_AUDIO_OUTPUT
+# ifdef GPIO_I2C_SDA
     // IO expander I2C
     #define GPIO_I2C_SDA 14
     #define GPIO_I2C_SCL 15
+# endif // GPIO_I2C_SDA
 #else
     // IO expander I2C pins being used as SPI for audio
     #define AUDIO_SPI      spi1

+ 9 - 7
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;
     }
 }
@@ -155,10 +159,8 @@ void scsi_accel_host_init()
     g_scsi_host_state = SCSIHOST_IDLE;
     scsi_accel_host_config_gpio();
 
-#ifndef ZULUSCSI_NETWORK
     // Load PIO programs
     pio_clear_instruction_memory(SCSI_PIO);
-#endif
 
     // Asynchronous / synchronous SCSI read
     g_scsi_host.pio_offset_async_read = pio_add_program(SCSI_PIO, &scsi_host_async_read_program);

+ 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
-