Selaa lähdekoodia

Add Audio support and consolidate initiator mode

Added back the Audio build and consolidated the initiator PIO assembly
files into one by setting the wait GPIO in the C++ code.
Also confirmed that the DaynaPORT works at 250MHz.
Morio 1 vuosi sitten
vanhempi
sitoutus
3ced4b0d92
33 muutettua tiedostoa jossa 348 lisäystä ja 470 poistoa
  1. 1 1
      lib/SCSI2SD/src/firmware/scsi.c
  2. 3 3
      lib/SCSI2SD/src/firmware/timings.h
  3. 6 0
      lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform.cpp
  4. 5 34
      lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform.h
  5. 47 0
      lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform_config.h
  6. 1 1
      lib/ZuluSCSI_platform_GD32F205/scsi2sd_timings.c
  7. 5 0
      lib/ZuluSCSI_platform_GD32F450/ZuluSCSI_platform.cpp
  8. 4 25
      lib/ZuluSCSI_platform_GD32F450/ZuluSCSI_platform.h
  9. 38 0
      lib/ZuluSCSI_platform_GD32F450/ZuluSCSI_platform_config.h
  10. 1 1
      lib/ZuluSCSI_platform_GD32F450/scsi2sd_timings.c
  11. 20 34
      lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform.cpp
  12. 3 58
      lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform.h
  13. 73 0
      lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform_config.h
  14. 2 0
      lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform_network.cpp
  15. 1 1
      lib/ZuluSCSI_platform_RP2MCU/scsi2sd_timings.c
  16. 6 9
      lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host.cpp
  17. 0 46
      lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_Pico.pio
  18. 0 43
      lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_Pico.pio.h
  19. 0 46
      lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_Pico_2.pio
  20. 0 43
      lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_Pico_2.pio.h
  21. 0 46
      lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_RP2350A.pio
  22. 0 44
      lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_RP2350A.pio.h
  23. 1 1
      lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_RP2MCU.pio
  24. 0 0
      lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_RP2MCU.pio.h
  25. 1 1
      lib/ZuluSCSI_platform_RP2MCU/scsi_accel_target.cpp
  26. 1 1
      lib/ZuluSCSI_platform_RP2MCU/sd_card_sdio.cpp
  27. 1 1
      lib/ZuluSCSI_platform_RP2MCU/sdio.cpp
  28. 110 15
      lib/ZuluSCSI_platform_RP2MCU/timings_RP2MCU.c
  29. 3 11
      lib/ZuluSCSI_platform_RP2MCU/timings_RP2MCU.h
  30. 3 3
      src/ZuluSCSI.cpp
  31. 1 0
      src/ZuluSCSI_cdrom.cpp
  32. 10 2
      src/ZuluSCSI_config.h
  33. 1 0
      src/ZuluSCSI_tape.cpp

+ 1 - 1
lib/SCSI2SD/src/firmware/scsi.c

@@ -28,7 +28,7 @@
 #include "led.h"
 #include "mode.h"
 #include "scsi2sd_time.h"
-#include "scsi2sd_timings.h"
+#include "timings.h"
 #include "bsp.h"
 #include "cdrom.h"
 #include "network.h"

+ 3 - 3
lib/ZuluSCSI_platform_GD32F450/scsi2sd_timings.h → lib/SCSI2SD/src/firmware/timings.h

@@ -18,10 +18,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 **/
-#ifndef ZULUSCSI_PLATFORM_TIMINGS_H
-#define ZULUSCSI_PLATFORM_TIMINGS_H
+#ifndef ZULUSCSI_SCSI2SD_TIMINGS_H
+#define ZULUSCSI_SCSI2SD_TIMINGS_H
 #include <stdint.h>
 extern uint8_t g_max_sync_20_period;
 extern uint8_t g_max_sync_10_period;
 extern uint8_t g_max_sync_5_period;
-#endif // ZULUSCSI_RP2MCU_TIMINGS_H
+#endif // ZULUSCSI_SCSI2SD_TIMINGS_H

+ 6 - 0
lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform.cpp

@@ -137,6 +137,12 @@ void SysTick_Handle_PreEmptively()
     __enable_irq();
 }
 
+uint32_t platform_sys_clock_in_hz()
+{
+    return rcu_clock_freq_get(CK_SYS);
+}
+
+
 /***************/
 /* GPIO init   */
 /***************/

+ 5 - 34
lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform.h

@@ -27,6 +27,7 @@
 #include <gd32f20x.h>
 #include <gd32f20x_gpio.h>
 #include <scsi2sd.h>
+#include <ZuluSCSI_config.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -34,27 +35,6 @@ extern "C" {
 
 extern const char *g_platform_name;
 
-#if defined(ZULUSCSI_V1_0)
-#   if defined(ZULUSCSI_V1_0_mini)
-#       define PLATFORM_NAME "ZuluSCSI mini v1.0"
-#   else
-#       define PLATFORM_NAME "ZuluSCSI v1.0"
-#   endif
-#   define PLATFORM_REVISION "1.0"
-#   define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_ASYNC_50
-#   include "ZuluSCSI_v1_0_gpio.h"
-#else
-#   define PLATFORM_NAME "ZuluSCSI v1.1+"
-#   define PLATFORM_REVISION "1.1+"
-#   define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_10
-#   define PLATFORM_OPTIMAL_MIN_SD_WRITE_SIZE 4096
-#   define PLATFORM_OPTIMAL_MAX_SD_WRITE_SIZE 65536
-#   define PLATFORM_OPTIMAL_LAST_SD_WRITE_SIZE 8192
-#   define PLATFORM_VERSION_1_1_PLUS
-#   define ZULUSCSI_HARDWARE_CONFIG
-#   include "ZuluSCSI_v1_1_gpio.h"
-#endif
-
 #include "platform_hw_config.h"
 
 enum ZuluSCSIVersion_t
@@ -69,12 +49,6 @@ enum ZuluSCSIVersion_t
 extern enum ZuluSCSIVersion_t g_zuluscsi_version;
 extern bool g_moved_select_in;
 
-#ifndef PLATFORM_VDD_WARNING_LIMIT_mV
-#define PLATFORM_VDD_WARNING_LIMIT_mV 2800
-#endif
-
-#define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 10
-
 // Debug logging functions
 void platform_log(const char *s);
 
@@ -128,14 +102,11 @@ void platform_poll();
 // This function should return without significantly delay.
 uint8_t platform_get_buttons();
 
+// Return system clock in Hz
+uint32_t platform_sys_clock_in_hz();
+
 // Attempt to reclock the MCU - unsupported
-typedef enum
-{
-    ZULUSCSI_RECLOCK_SUCCESS,
-    ZULUSCSI_RECLOCK_NOT_SUPPORTED,
-    ZULUSCSI_RECLOCK_FAILED
-} zuluscsi_reclock_status_t;
-zuluscsi_reclock_status_t platform_reclock(uint32_t clk_in_khz){return ZULUSCSI_RECLOCK_NOT_SUPPORTED;}
+inline zuluscsi_reclock_status_t platform_reclock(uint32_t clk_in_khz){return ZULUSCSI_RECLOCK_NOT_SUPPORTED;}
 
 
 // Reinitialize SD card connection and save log from interrupt context.

+ 47 - 0
lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform_config.h

@@ -0,0 +1,47 @@
+/** 
+ * ZuluSCSI™ - Copyright (c) 2024 Rabbit Hole Computing™
+ * 
+ * ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
+ * 
+ * https://www.gnu.org/licenses/gpl-3.0.html
+ * ----
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version. 
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details. 
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+**/
+#pragma once
+#if defined(ZULUSCSI_V1_0)
+#   if defined(ZULUSCSI_V1_0_mini)
+#       define PLATFORM_NAME "ZuluSCSI mini v1.0"
+#   else
+#       define PLATFORM_NAME "ZuluSCSI v1.0"
+#   endif
+#   define PLATFORM_REVISION "1.0"
+#   define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_ASYNC_50
+#   include "ZuluSCSI_v1_0_gpio.h"
+#else
+#   define PLATFORM_NAME "ZuluSCSI v1.1+"
+#   define PLATFORM_REVISION "1.1+"
+#   define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_10
+#   define PLATFORM_OPTIMAL_MIN_SD_WRITE_SIZE 4096
+#   define PLATFORM_OPTIMAL_MAX_SD_WRITE_SIZE 65536
+#   define PLATFORM_OPTIMAL_LAST_SD_WRITE_SIZE 8192
+#   define PLATFORM_VERSION_1_1_PLUS
+#   define ZULUSCSI_HARDWARE_CONFIG
+#   include "ZuluSCSI_v1_1_gpio.h"
+#endif
+
+#ifndef PLATFORM_VDD_WARNING_LIMIT_mV
+#define PLATFORM_VDD_WARNING_LIMIT_mV 2800
+#endif
+
+#define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 10

+ 1 - 1
lib/ZuluSCSI_platform_GD32F205/scsi2sd_timings.c

@@ -18,7 +18,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 **/
-#include "scsi2sd_timings.h"
+#include "timings.h"
 uint8_t g_max_sync_20_period = 25;
 uint8_t g_max_sync_10_period = 25;
 uint8_t g_max_sync_5_period  = 50; 

+ 5 - 0
lib/ZuluSCSI_platform_GD32F450/ZuluSCSI_platform.cpp

@@ -128,6 +128,11 @@ void SysTick_Handle_PreEmptively()
     __enable_irq();
 }
 
+uint32_t platform_sys_clock_in_hz()
+{
+    return rcu_clock_freq_get(CK_SYS);
+}
+
 /***************/
 /* GPIO init   */
 /***************/

+ 4 - 25
lib/ZuluSCSI_platform_GD32F450/ZuluSCSI_platform.h

@@ -27,8 +27,7 @@
 #include <gd32f4xx.h>
 #include <gd32f4xx_gpio.h>
 #include <scsi2sd.h>
-#include "ZuluSCSI_config.h"
-
+#include <ZuluSCSI_config.h>
 
 #ifdef __cplusplus
 #include <SdFat.h>
@@ -38,22 +37,6 @@ extern "C" {
 
 extern const char *g_platform_name;
 
-#if defined(ZULUSCSI_V1_4)
-#   define PLATFORM_NAME "ZuluSCSI v1.4"
-#   define PLATFORM_REVISION "1.4"
-#   define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_10
-#   define PLATFORM_OPTIMAL_MIN_SD_WRITE_SIZE 4096
-#   define PLATFORM_OPTIMAL_MAX_SD_WRITE_SIZE 65536
-#   define PLATFORM_OPTIMAL_LAST_SD_WRITE_SIZE 8192
-#   define PLATFORM_FLASH_SECTOR_ERASE
-#   include "ZuluSCSI_v1_4_gpio.h"
-#endif
-
-#ifndef PLATFORM_VDD_WARNING_LIMIT_mV
-#define PLATFORM_VDD_WARNING_LIMIT_mV 2800
-#endif
-
-#define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 10
 // Debug logging functions
 void platform_log(const char *s);
 
@@ -111,14 +94,10 @@ void platform_poll();
 // This function should return without significantly delay.
 uint8_t platform_get_buttons();
 
+uint32_t platform_sys_clock_in_hz();
+
 // Attempt to reclock the MCU - unsupported
-typedef enum
-{
-    ZULUSCSI_RECLOCK_SUCCESS,
-    ZULUSCSI_RECLOCK_NOT_SUPPORTED,
-    ZULUSCSI_RECLOCK_FAILED
-} zuluscsi_reclock_status_t;
-zuluscsi_reclock_status_t platform_reclock(uint32_t clk_in_khz){return ZULUSCSI_RECLOCK_NOT_SUPPORTED;}
+inline zuluscsi_reclock_status_t platform_reclock(uint32_t clk_in_khz){return ZULUSCSI_RECLOCK_NOT_SUPPORTED;}
 
 
 // Reinitialize SD card connection and save log from interrupt context.

+ 38 - 0
lib/ZuluSCSI_platform_GD32F450/ZuluSCSI_platform_config.h

@@ -0,0 +1,38 @@
+/** 
+ * ZuluSCSI™ - Copyright (c) 2024 Rabbit Hole Computing™
+ * 
+ * ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
+ * 
+ * https://www.gnu.org/licenses/gpl-3.0.html
+ * ----
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version. 
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details. 
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+**/
+#pragma once
+
+#if defined(ZULUSCSI_V1_4)
+#   define PLATFORM_NAME "ZuluSCSI v1.4"
+#   define PLATFORM_REVISION "1.4"
+#   define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_10
+#   define PLATFORM_OPTIMAL_MIN_SD_WRITE_SIZE 4096
+#   define PLATFORM_OPTIMAL_MAX_SD_WRITE_SIZE 65536
+#   define PLATFORM_OPTIMAL_LAST_SD_WRITE_SIZE 8192
+#   define PLATFORM_FLASH_SECTOR_ERASE
+#   include "ZuluSCSI_v1_4_gpio.h"
+#endif
+
+#ifndef PLATFORM_VDD_WARNING_LIMIT_mV
+#define PLATFORM_VDD_WARNING_LIMIT_mV 2800
+#endif
+
+#define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 10

+ 1 - 1
lib/ZuluSCSI_platform_GD32F450/scsi2sd_timings.c

@@ -18,7 +18,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 **/
-#include "scsi2sd_timings.h"
+#include "timings.h"
 uint8_t g_max_sync_20_period = 25;
 uint8_t g_max_sync_10_period = 25;
 uint8_t g_max_sync_5_period  = 50; 

+ 20 - 34
lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform.cpp

@@ -21,7 +21,6 @@
 
 #include "ZuluSCSI_platform.h"
 #include "ZuluSCSI_log.h"
-#include "ZuluSCSI_config.h"
 #include <SdFat.h>
 #include <scsi.h>
 #include <assert.h>
@@ -58,7 +57,7 @@ extern "C" {
 extern bool g_rawdrive_active;
 
 extern "C" {
-#include "timings.h"
+#include "timings_RP2MCU.h"
 const char *g_platform_name = PLATFORM_NAME;
 static bool g_scsi_initiator = false;
 static uint32_t g_flash_chip_size = 0;
@@ -82,37 +81,10 @@ static void gpio_conf(uint gpio, gpio_function_t fn, bool pullup, bool pulldown,
     }
 }
 
-// \todo setup up timing for audio
-#ifdef ENABLE_AUDIO_OUTPUT
-// Increases clk_sys and clk_peri to 135.428571MHz at runtime to support
-// division to audio output rates. Invoke before anything is using clk_peri
-// except for the logging UART, which is handled below.
-    // reset PLL for 135.428571MHz
-    pll_init(pll_sys, 1, 948000000, 7, 1);
-    // switch clocks back to pll_sys
-    clock_configure(clk_sys,
-            CLOCKS_CLK_SYS_CTRL_SRC_VALUE_CLKSRC_CLK_SYS_AUX,
-            CLOCKS_CLK_SYS_CTRL_AUXSRC_VALUE_CLKSRC_PLL_SYS,
-            135428571,
-            135428571);
-    clock_configure(clk_peri,
-            0,
-            CLOCKS_CLK_PERI_CTRL_AUXSRC_VALUE_CLKSRC_PLL_SYS,
-            135428571,
-            135428571);
-
-#endif
-
-
 static void reclock() {
-    gpio_set_drive_strength(SDIO_CLK,  GPIO_DRIVE_STRENGTH_12MA);
-    gpio_set_drive_strength(SDIO_CMD,  GPIO_DRIVE_STRENGTH_12MA);
-    gpio_set_drive_strength(SDIO_D0,  GPIO_DRIVE_STRENGTH_12MA);
-    gpio_set_drive_strength(SDIO_D1,  GPIO_DRIVE_STRENGTH_12MA);
-    gpio_set_drive_strength(SDIO_D2,  GPIO_DRIVE_STRENGTH_12MA);
-    gpio_set_drive_strength(SDIO_D3,  GPIO_DRIVE_STRENGTH_12MA);
     // ensure UART is fully drained before we mess up its clock
-    uart_tx_wait_blocking(uart0);
+    if (uart_is_enabled(uart0))
+        uart_tx_wait_blocking(uart0);
     // switch clk_sys and clk_peri to pll_usb
     // see code in 2.15.6.1 of the datasheet for useful comments
     clock_configure(clk_sys,
@@ -144,14 +116,22 @@ static void reclock() {
             g_zuluscsi_timings->clk_hz,
             g_zuluscsi_timings->clk_hz);
     // reset UART for the new clock speed
-    uart_init(uart0, 1000000);
+    if (uart_is_enabled(uart0))
+        uart_init(uart0, 1000000);
+}
+
+uint32_t platform_sys_clock_in_hz()
+{
+    return clock_get_hz(clk_sys);
 }
 
 zuluscsi_reclock_status_t platform_reclock(uint32_t clock_in_khz)
 {
     if (set_timings(clock_in_khz))
     {
+        logmsg("Initial Clock set to ", (int) platform_sys_clock_in_hz(), "Hz");
         reclock();
+        logmsg("SDIO clock set to ", (int)((g_zuluscsi_timings->clk_hz / g_zuluscsi_timings->sdio.clk_div_pio + (5 * MHZ / 10)) / MHZ) , "MHz");
         return ZULUSCSI_RECLOCK_SUCCESS;
     }
     return ZULUSCSI_RECLOCK_FAILED;
@@ -285,8 +265,14 @@ void platform_init()
 
 #ifdef ENABLE_AUDIO_OUTPUT
     logmsg("SP/DIF audio to expansion header enabled");
-    logmsg("-- Overclocking to 135.428571MHz");
-    reclock_for_audio();
+    if (platform_reclock(135428) == ZULUSCSI_RECLOCK_SUCCESS)
+    {
+        logmsg("Reclocked for Audio Ouput at ", (int) platform_sys_clock_in_hz(), "Hz");
+    }
+    else
+    {
+        logmsg("Audio Output timings not found");
+    }
 #endif // ENABLE_AUDIO_OUTPUT
 
     // Get flash chip size

+ 3 - 58
lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform.h

@@ -25,6 +25,7 @@
 
 #include <stdint.h>
 #include <Arduino.h>
+#include "ZuluSCSI_config.h"
 #include "ZuluSCSI_platform_network.h"
 
 #ifdef ZULUSCSI_PICO
@@ -54,58 +55,6 @@ extern "C" {
 /* These are used in debug output and default SCSI strings */
 extern const char *g_platform_name;
 
-#ifdef ZULUSCSI_PICO
-# ifdef ZULUSCSI_DAYNAPORT
-#   define PLATFORM_NAME "ZuluSCSI Pico DaynaPORT"
-# else
-#   define PLATFORM_NAME "ZuluSCSI Pico"
-# endif
-# define PLATFORM_PID "Pico"
-# define PLATFORM_REVISION "2.0"
-# define PLATFORM_HAS_INITIATOR_MODE 1
-# define DISABLE_SWO
-# define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
-# define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 10
-#elif defined(ZULUSCSI_PICO_2)
-# define PLATFORM_NAME "ZuluSCSI Pico 2"
-# define PLATFORM_PID "Pico 2"
-# define PLATFORM_REVISION "2.0"
-# define PLATFORM_HAS_INITIATOR_MODE 1
-# define DISABLE_SWO
-# define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
-# define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 20
-#elif defined(ZULUSCSI_RP2350A)
-# define PLATFORM_NAME "ZuluSCSI RP2350A"
-# define PLATFORM_PID "RP2350A"
-# define PLATFORM_REVISION "2.0"
-# define PLATFORM_HAS_INITIATOR_MODE 1
-# define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
-# define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 20
-#elif defined(ZULUSCSI_BS2)
-# define PLATFORM_NAME "ZuluSCSI BS2"
-# define PLATFORM_PID "BS2"
-# define PLATFORM_REVISION "1.0"
-# define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
-# define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 10
-#else
-# define PLATFORM_NAME "ZuluSCSI RP2040"
-# define PLATFORM_PID "RP2040"
-# define PLATFORM_REVISION "2.0"
-# define PLATFORM_HAS_INITIATOR_MODE 1
-# define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
-# define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 10
-#endif
-
-#define PLATFORM_OPTIMAL_MIN_SD_WRITE_SIZE 32768
-#define PLATFORM_OPTIMAL_MAX_SD_WRITE_SIZE 65536
-#define PLATFORM_OPTIMAL_LAST_SD_WRITE_SIZE 8192
-#define SD_USE_SDIO 1
-#define PLATFORM_HAS_PARITY_CHECK 1
-
-#ifndef PLATFORM_VDD_WARNING_LIMIT_mV
-#define PLATFORM_VDD_WARNING_LIMIT_mV 2800
-#endif
-
 // NOTE: The driver supports synchronous speeds higher than 10MB/s, but this
 // has not been tested due to lack of fast enough SCSI adapter.
 // #define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
@@ -162,13 +111,9 @@ void platform_poll();
 // This function should return without significantly delay.
 uint8_t platform_get_buttons();
 
+uint32_t platform_sys_clock_in_hz();
+
 // Attempt to reclock the MCU
-typedef enum
-{
-    ZULUSCSI_RECLOCK_SUCCESS,
-    ZULUSCSI_RECLOCK_NOT_SUPPORTED,
-    ZULUSCSI_RECLOCK_FAILED
-} zuluscsi_reclock_status_t;
 zuluscsi_reclock_status_t platform_reclock(uint32_t clk_in_khz);
 
 // Set callback that will be called during data transfer to/from SD card.

+ 73 - 0
lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform_config.h

@@ -0,0 +1,73 @@
+/** 
+ * ZuluSCSI™ - Copyright (c) 2024 Rabbit Hole Computing™
+ * 
+ * ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
+ * 
+ * https://www.gnu.org/licenses/gpl-3.0.html
+ * ----
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version. 
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details. 
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+**/
+#pragma once
+
+#ifdef ZULUSCSI_PICO
+# ifdef ZULUSCSI_DAYNAPORT
+#   define PLATFORM_NAME "ZuluSCSI Pico DaynaPORT"
+# else
+#   define PLATFORM_NAME "ZuluSCSI Pico"
+# endif
+# define PLATFORM_PID "Pico"
+# define PLATFORM_REVISION "2.0"
+# define PLATFORM_HAS_INITIATOR_MODE 1
+# define DISABLE_SWO
+# define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
+# define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 10
+#elif defined(ZULUSCSI_PICO_2)
+# define PLATFORM_NAME "ZuluSCSI Pico 2"
+# define PLATFORM_PID "Pico 2"
+# define PLATFORM_REVISION "2.0"
+# define PLATFORM_HAS_INITIATOR_MODE 1
+# define DISABLE_SWO
+# define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
+# define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 20
+#elif defined(ZULUSCSI_RP2350A)
+# define PLATFORM_NAME "ZuluSCSI RP2350A"
+# define PLATFORM_PID "RP2350A"
+# define PLATFORM_REVISION "2.0"
+# define PLATFORM_HAS_INITIATOR_MODE 1
+# define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
+# define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 20
+#elif defined(ZULUSCSI_BS2)
+# define PLATFORM_NAME "ZuluSCSI BS2"
+# define PLATFORM_PID "BS2"
+# define PLATFORM_REVISION "1.0"
+# define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
+# define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 10
+#else
+# define PLATFORM_NAME "ZuluSCSI RP2040"
+# define PLATFORM_PID "RP2040"
+# define PLATFORM_REVISION "2.0"
+# define PLATFORM_HAS_INITIATOR_MODE 1
+# define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
+# define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 10
+#endif
+
+#define PLATFORM_OPTIMAL_MIN_SD_WRITE_SIZE 32768
+#define PLATFORM_OPTIMAL_MAX_SD_WRITE_SIZE 65536
+#define PLATFORM_OPTIMAL_LAST_SD_WRITE_SIZE 8192
+#define SD_USE_SDIO 1
+#define PLATFORM_HAS_PARITY_CHECK 1
+
+#ifndef PLATFORM_VDD_WARNING_LIMIT_mV
+#define PLATFORM_VDD_WARNING_LIMIT_mV 2800
+#endif

+ 2 - 0
lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform_network.cpp

@@ -14,6 +14,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 #ifdef ZULUSCSI_NETWORK
+#include <Arduino.h>
 #include "ZuluSCSI_platform_network.h"
 #include "ZuluSCSI_log.h"
 #include "ZuluSCSI_config.h"
@@ -24,6 +25,7 @@ extern "C" {
 
 #include <cyw43.h>
 #include <pico/cyw43_arch.h>
+#include <pico/unique_id.h>
 
 #ifndef CYW43_IOCTL_GET_RSSI
 #define CYW43_IOCTL_GET_RSSI (0xfe)

+ 1 - 1
lib/ZuluSCSI_platform_RP2MCU/scsi2sd_timings.c

@@ -18,7 +18,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 **/
-#include "scsi2sd_timings.h"
+#include "timings.h"
 #include "ZuluSCSI_platform.h"
 #if defined(ZULUSCSI_MCU_RP23XX)
 uint8_t g_max_sync_20_period = 18;

+ 6 - 9
lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host.cpp

@@ -31,15 +31,7 @@
 #include <hardware/sync.h>
 
 #ifdef PLATFORM_HAS_INITIATOR_MODE
-# ifdef ZULUSCSI_PICO_2
-#  include "scsi_accel_host_Pico_2.pio.h"
-# elif defined(ZULUSCSI_PICO)
-#  include "scsi_accel_host_Pico.pio.h"
-# elif defined(ZULUSCSI_RP2350A)
-#  include "scsi_accel_host_RP2350A.pio.h"
-# else
-#  include "scsi_accel_host_RP2040.pio.h"
-# endif
+# include "scsi_accel_host_RP2MCU.pio.h"
 
 #define SCSI_PIO pio0
 #define SCSI_SM 0
@@ -167,6 +159,11 @@ void scsi_accel_host_init()
 
     // Asynchronous / synchronous SCSI read
     g_scsi_host.pio_offset_async_read = pio_add_program(SCSI_PIO, &scsi_host_async_read_program);
+    //    wait 0 gpio REQ             side 1  ; Wait for REQ low
+    uint16_t instr = pio_encode_wait_gpio(false, SCSI_IN_REQ) | pio_encode_sideset(1, 1);
+    SCSI_PIO->instr_mem[g_scsi_host.pio_offset_async_read + 2] = instr;
+    instr =   pio_encode_wait_gpio(true, SCSI_IN_REQ) | pio_encode_sideset(1, 0);
+    SCSI_PIO->instr_mem[g_scsi_host.pio_offset_async_read + 5] = instr;
     g_scsi_host.pio_cfg_async_read = scsi_host_async_read_program_get_default_config(g_scsi_host.pio_offset_async_read);
     sm_config_set_in_pins(&g_scsi_host.pio_cfg_async_read, SCSI_IO_DB0);
     sm_config_set_sideset_pins(&g_scsi_host.pio_cfg_async_read, SCSI_OUT_ACK);

+ 0 - 46
lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_Pico.pio

@@ -1,46 +0,0 @@
-; ZuluSCSI™ - Copyright (c) 2022 Rabbit Hole Computing™
-; 
-; ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
-; 
-; https://www.gnu.org/licenses/gpl-3.0.html
-; ----
-; This program is free software: you can redistribute it and/or modify
-; it under the terms of the GNU General Public License as published by
-; the Free Software Foundation, either version 3 of the License, or
-; (at your option) any later version. 
-; 
-; This program is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details. 
-; 
-; You should have received a copy of the GNU General Public License
-; along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-
-; RP2040 PIO program for accelerating SCSI initiator / host function
-; Run "pioasm scsi_accel_host.pio scsi_accel_host.pio.h" to regenerate the C header from this.
-; GPIO mapping:
-; - 0-7: DB0-DB7
-; -   8: DBP
-; Side set is ACK pin
-
-.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.
-; Number of bytes to receive minus 1 should be written to TX fifo.
-; Number of bytes to receive must be divisible by 2.
-.program scsi_host_async_read
-    .side_set 1
-
-    pull block                  side 1  ; Get number of bytes to receive
-    mov x, osr                  side 1  ; Store to counter X
-
-start:
-    wait 0 gpio REQ             side 1  ; Wait for REQ low
-    in pins, 9                  side 0  ; Assert ACK, read GPIO
-    in null, 7                  side 0  ; Padding bits
-    wait 1 gpio REQ             side 0  ; Wait for REQ high
-    jmp x-- start               side 1  ; Deassert ACK, decrement byte count and jump to start

+ 0 - 43
lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_Pico.pio.h

@@ -1,43 +0,0 @@
-// -------------------------------------------------- //
-// This file is autogenerated by pioasm; do not edit! //
-// -------------------------------------------------- //
-
-#pragma once
-
-#if !PICO_NO_HARDWARE
-#include "hardware/pio.h"
-#endif
-
-// -------------------- //
-// scsi_host_async_read //
-// -------------------- //
-
-#define scsi_host_async_read_wrap_target 0
-#define scsi_host_async_read_wrap 6
-
-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     
-    0x3011, //  2: wait   0 gpio, 17      side 1     
-    0x4009, //  3: in     pins, 9         side 0     
-    0x4067, //  4: in     null, 7         side 0     
-    0x2091, //  5: wait   1 gpio, 17      side 0     
-    0x1042, //  6: jmp    x--, 2          side 1     
-            //     .wrap
-};
-
-#if !PICO_NO_HARDWARE
-static const struct pio_program scsi_host_async_read_program = {
-    .instructions = scsi_host_async_read_program_instructions,
-    .length = 7,
-    .origin = -1,
-};
-
-static inline pio_sm_config scsi_host_async_read_program_get_default_config(uint offset) {
-    pio_sm_config c = pio_get_default_sm_config();
-    sm_config_set_wrap(&c, offset + scsi_host_async_read_wrap_target, offset + scsi_host_async_read_wrap);
-    sm_config_set_sideset(&c, 1, false, false);
-    return c;
-}
-#endif

+ 0 - 46
lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_Pico_2.pio

@@ -1,46 +0,0 @@
-; ZuluSCSI™ - Copyright (c) 2022 Rabbit Hole Computing™
-; 
-; ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
-; 
-; https://www.gnu.org/licenses/gpl-3.0.html
-; ----
-; This program is free software: you can redistribute it and/or modify
-; it under the terms of the GNU General Public License as published by
-; the Free Software Foundation, either version 3 of the License, or
-; (at your option) any later version. 
-; 
-; This program is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details. 
-; 
-; You should have received a copy of the GNU General Public License
-; along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-
-; RP2040 PIO program for accelerating SCSI initiator / host function
-; Run "pioasm scsi_accel_host.pio scsi_accel_host.pio.h" to regenerate the C header from this.
-; GPIO mapping:
-; - 0-7: DB0-DB7
-; -   8: DBP
-; Side set is ACK pin
-
-.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.
-; Number of bytes to receive minus 1 should be written to TX fifo.
-; Number of bytes to receive must be divisible by 2.
-.program scsi_host_async_read
-    .side_set 1
-
-    pull block                  side 1  ; Get number of bytes to receive
-    mov x, osr                  side 1  ; Store to counter X
-
-start:
-    wait 0 gpio REQ             side 1  ; Wait for REQ low
-    in pins, 9                  side 0  ; Assert ACK, read GPIO
-    in null, 7                  side 0  ; Padding bits
-    wait 1 gpio REQ             side 0  ; Wait for REQ high
-    jmp x-- start               side 1  ; Deassert ACK, decrement byte count and jump to start

+ 0 - 43
lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_Pico_2.pio.h

@@ -1,43 +0,0 @@
-// -------------------------------------------------- //
-// This file is autogenerated by pioasm; do not edit! //
-// -------------------------------------------------- //
-
-#pragma once
-
-#if !PICO_NO_HARDWARE
-#include "hardware/pio.h"
-#endif
-
-// -------------------- //
-// scsi_host_async_read //
-// -------------------- //
-
-#define scsi_host_async_read_wrap_target 0
-#define scsi_host_async_read_wrap 6
-
-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     
-    0x3011, //  2: wait   0 gpio, 17      side 1     
-    0x4009, //  3: in     pins, 9         side 0     
-    0x4067, //  4: in     null, 7         side 0     
-    0x2091, //  5: wait   1 gpio, 17      side 0     
-    0x1042, //  6: jmp    x--, 2          side 1     
-            //     .wrap
-};
-
-#if !PICO_NO_HARDWARE
-static const struct pio_program scsi_host_async_read_program = {
-    .instructions = scsi_host_async_read_program_instructions,
-    .length = 7,
-    .origin = -1,
-};
-
-static inline pio_sm_config scsi_host_async_read_program_get_default_config(uint offset) {
-    pio_sm_config c = pio_get_default_sm_config();
-    sm_config_set_wrap(&c, offset + scsi_host_async_read_wrap_target, offset + scsi_host_async_read_wrap);
-    sm_config_set_sideset(&c, 1, false, false);
-    return c;
-}
-#endif

+ 0 - 46
lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_RP2350A.pio

@@ -1,46 +0,0 @@
-; ZuluSCSI™ - Copyright (c) 2022 Rabbit Hole Computing™
-; 
-; ZuluSCSI™ firmware is licensed under the GPL version 3 or any later version. 
-; 
-; https://www.gnu.org/licenses/gpl-3.0.html
-; ----
-; This program is free software: you can redistribute it and/or modify
-; it under the terms of the GNU General Public License as published by
-; the Free Software Foundation, either version 3 of the License, or
-; (at your option) any later version. 
-; 
-; This program is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details. 
-; 
-; You should have received a copy of the GNU General Public License
-; along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-
-; RP2040 PIO program for accelerating SCSI initiator / host function
-; Run "pioasm scsi_accel_host.pio scsi_accel_host.pio.h" to regenerate the C header from this.
-; GPIO mapping:
-; - 0-7: DB0-DB7
-; -   8: DBP
-; Side set is ACK pin
-
-.define REQ 9
-.define ACK 10
-
-; Read from SCSI bus using asynchronous handshake.
-; Data is returned as 16-bit words that contain the 8 data bits + 1 parity bit.
-; Number of bytes to receive minus 1 should be written to TX fifo.
-; Number of bytes to receive must be divisible by 2.
-.program scsi_host_async_read
-    .side_set 1
-
-    pull block                  side 1  ; Get number of bytes to receive
-    mov x, osr                  side 1  ; Store to counter X
-
-start:
-    wait 0 gpio REQ             side 1  ; Wait for REQ low
-    in pins, 9                  side 0  ; Assert ACK, read GPIO
-    in null, 7                  side 0  ; Padding bits
-    wait 1 gpio REQ             side 0  ; Wait for REQ high
-    jmp x-- start               side 1  ; Deassert ACK, decrement byte count and jump to start

+ 0 - 44
lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_RP2350A.pio.h

@@ -1,44 +0,0 @@
-// -------------------------------------------------- //
-// This file is autogenerated by pioasm; do not edit! //
-// -------------------------------------------------- //
-
-#pragma once
-
-#if !PICO_NO_HARDWARE
-#include "hardware/pio.h"
-#endif
-
-// -------------------- //
-// scsi_host_async_read //
-// -------------------- //
-
-#define scsi_host_async_read_wrap_target 0
-#define scsi_host_async_read_wrap 6
-
-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     
-    0x4009, //  3: in     pins, 9         side 0     
-    0x4067, //  4: in     null, 7         side 0     
-    0x2089, //  5: wait   1 gpio, 9       side 0     
-    0x1042, //  6: jmp    x--, 2          side 1     
-            //     .wrap
-};
-
-#if !PICO_NO_HARDWARE
-static const struct pio_program scsi_host_async_read_program = {
-    .instructions = scsi_host_async_read_program_instructions,
-    .length = 7,
-    .origin = -1,
-};
-
-static inline pio_sm_config scsi_host_async_read_program_get_default_config(uint offset) {
-    pio_sm_config c = pio_get_default_sm_config();
-    sm_config_set_wrap(&c, offset + scsi_host_async_read_wrap_target, offset + scsi_host_async_read_wrap);
-    sm_config_set_sideset(&c, 1, false, false);
-    return c;
-}
-#endif
-

+ 1 - 1
lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_RP2040.pio → lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_RP2MCU.pio

@@ -24,7 +24,7 @@
 ; - 0-7: DB0-DB7
 ; -   8: DBP
 ; Side set is ACK pin
-
+; REQ is a dummy value, set by via pico-sdk encode functions
 .define REQ 9
 .define ACK 10
 

+ 0 - 0
lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_RP2040.pio.h → lib/ZuluSCSI_platform_RP2MCU/scsi_accel_host_RP2MCU.pio.h


+ 1 - 1
lib/ZuluSCSI_platform_RP2MCU/scsi_accel_target.cpp

@@ -33,7 +33,7 @@
 #include "ZuluSCSI_platform.h"
 #include "ZuluSCSI_log.h"
 #include "scsi_accel_target.h"
-#include "timings.h"
+#include "timings_RP2MCU.h"
 #include <hardware/pio.h>
 #include <hardware/dma.h>
 #include <hardware/irq.h>

+ 1 - 1
lib/ZuluSCSI_platform_RP2MCU/sd_card_sdio.cpp

@@ -28,7 +28,7 @@
 
 #include "ZuluSCSI_log.h"
 #include "sdio.h"
-#include "timings.h"
+#include "timings_RP2MCU.h"
 #include <hardware/gpio.h>
 #include <SdFat.h>
 #include <SdCard/SdCardInfo.h>

+ 1 - 1
lib/ZuluSCSI_platform_RP2MCU/sdio.cpp

@@ -37,7 +37,7 @@
 #include <hardware/structs/scb.h>
 #include <ZuluSCSI_platform.h>
 #include <ZuluSCSI_log.h>
-#include "timings.h"
+#include "timings_RP2MCU.h"
 
 # include "sdio_RP2MCU.pio.h"
 

+ 110 - 15
lib/ZuluSCSI_platform_RP2MCU/timings.c → lib/ZuluSCSI_platform_RP2MCU/timings_RP2MCU.c

@@ -18,9 +18,9 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 **/
-#include "timings.h"
+#include "timings_RP2MCU.h"
 #include <string.h>
-#include "scsi2sd_timings.h"
+#include "timings.h"
 
 
 static zuluscsi_timings_t  predefined_timings[]  = {
@@ -38,14 +38,13 @@ static zuluscsi_timings_t  predefined_timings[]  = {
         .scsi =
         {
             .req_delay = 7,
-            .clk_period_ps = 5000
+            .clk_period_ps = 8000
         },
 
         .scsi_20 =
         {
             .delay0 = 4,
             .delay1 = 6,
-            .mode = ZULUSCSI_PIO_TARGET_MODE_SIMPLE,
             .total_delay_adjust = -1,
             .max_sync = 25,
 
@@ -55,7 +54,6 @@ static zuluscsi_timings_t  predefined_timings[]  = {
         {
             .delay0 = 4,
             .delay1 = 6,
-            .mode = ZULUSCSI_PIO_TARGET_MODE_SIMPLE,
             .total_delay_adjust = -1,
             .max_sync = 25,
         },
@@ -64,7 +62,6 @@ static zuluscsi_timings_t  predefined_timings[]  = {
         {
             .delay0 = 10 - 1,
             .delay1 = 15 - 1,
-            .mode = ZULUSCSI_PIO_TARGET_MODE_SIMPLE,
             .total_delay_adjust = -1,
             .max_sync = 50,
         },
@@ -76,6 +73,106 @@ static zuluscsi_timings_t  predefined_timings[]  = {
             .delay0 = 3 - 1, // subtract one for the instruction delay
             .delay1 = 2 - 1  // clk_div_pio - delay0 and subtract one for the instruction delay
         }
+    },
+        {
+        .clk_hz = 133000000,
+
+        .pll =
+        {
+            .refdiv = 1,
+            .vco_freq = 1596000000,
+            .post_div1 = 6,
+            .post_div2 = 2
+        },
+
+        .scsi =
+        {
+            .req_delay = 7,
+            .clk_period_ps = 7519
+        },
+
+        .scsi_20 =
+        {
+            .delay0 = 4,
+            .delay1 = 6,
+            .total_delay_adjust = -1,
+            .max_sync = 25,
+
+        },
+
+        .scsi_10 =
+        {
+            .delay0 = 4,
+            .delay1 = 6,
+            .total_delay_adjust = -1,
+            .max_sync = 25,
+        },
+
+        .scsi_5 =
+        {
+            .delay0 = 10 - 1,
+            .delay1 = 15 - 1,
+            .total_delay_adjust = -1,
+            .max_sync = 50,
+        },
+
+        .sdio =
+        {
+            .clk_div_1mhz = 25,
+            .clk_div_pio = 5,
+            .delay0 = 3 - 1, // subtract one for the instruction delay
+            .delay1 = 2 - 1  // clk_div_pio - delay0 and subtract one for the instruction delay
+        }
+    },
+    {
+        .clk_hz = 135428571,
+
+        .pll =
+        {
+            .refdiv = 1,
+            .vco_freq = 948000000,
+            .post_div1 = 7,
+            .post_div2 = 1
+        },
+
+        .scsi =
+        {
+            .req_delay = 7,
+            .clk_period_ps = 7384
+        },
+
+        .scsi_20 =
+        {
+            .delay0 = 4,
+            .delay1 = 6,
+            .total_delay_adjust = -1,
+            .max_sync = 25,
+
+        },
+
+        .scsi_10 =
+        {
+            .delay0 = 4,
+            .delay1 = 6,
+            .total_delay_adjust = -1,
+            .max_sync = 25,
+        },
+
+        .scsi_5 =
+        {
+            .delay0 = 10 - 1,
+            .delay1 = 15 - 1,
+            .total_delay_adjust = -1,
+            .max_sync = 50,
+        },
+
+        .sdio =
+        {
+            .clk_div_1mhz = 27 , // = 135MHz clk / clk_div_pio
+            .clk_div_pio = 5,
+            .delay0 = 3 - 1, // subtract one for the instruction delay
+            .delay1 = 2 - 1  // clk_div_pio - delay0 and subtract one for the instruction delay
+        }
     },
     {
         .clk_hz = 150000000,
@@ -98,7 +195,6 @@ static zuluscsi_timings_t  predefined_timings[]  = {
         {
             .delay0 = 3 - 1,
             .delay1 = 4 - 1,
-            .mode = ZULUSCSI_PIO_TARGET_MODE_SIMPLE,
             .total_delay_adjust = 0,
             .max_sync = 18,
 
@@ -108,7 +204,6 @@ static zuluscsi_timings_t  predefined_timings[]  = {
         {
             .delay0 = 4 - 1,
             .delay1 = 5 - 1,
-            .mode = ZULUSCSI_PIO_TARGET_MODE_SIMPLE,
             .total_delay_adjust = 0,
             .max_sync = 25,
 
@@ -118,7 +213,6 @@ static zuluscsi_timings_t  predefined_timings[]  = {
         {
             .delay0 = 10 - 1,
             .delay1 = 15, // should be 18 - 1 but max currently is 15
-            .mode = ZULUSCSI_PIO_TARGET_MODE_SIMPLE,
             .total_delay_adjust = 0,
             .max_sync = 50,
 
@@ -153,7 +247,6 @@ static zuluscsi_timings_t  predefined_timings[]  = {
         {
             .delay0 = 3 - 1,
             .delay1 = 5 - 1,
-            .mode = ZULUSCSI_PIO_TARGET_MODE_SIMPLE,
             .total_delay_adjust = 1,
             .max_sync = 12,
 
@@ -163,7 +256,6 @@ static zuluscsi_timings_t  predefined_timings[]  = {
         {
             .delay0 = 6 - 1,
             .delay1 = 9 - 1,
-            .mode = ZULUSCSI_PIO_TARGET_MODE_SIMPLE,
             .total_delay_adjust = 1,
             .max_sync = 25,
         },
@@ -172,7 +264,6 @@ static zuluscsi_timings_t  predefined_timings[]  = {
         {
             .delay0 = 15, // maxed out should be 16
             .delay1 = 15, // maxed out should be 30
-            .mode = ZULUSCSI_PIO_TARGET_MODE_SIMPLE,
             .total_delay_adjust = 1,
             .max_sync = 50,
         },
@@ -194,14 +285,18 @@ static zuluscsi_timings_t  predefined_timings[]  = {
         }
 
 #endif
-    }
+    },
 };
     zuluscsi_timings_t  current_timings;
-#ifdef ZULUSCSI_MCU_RP23XX
+
+#ifdef ENABLE_AUDIO_OUTPUT
+    zuluscsi_timings_t *g_zuluscsi_timings = &predefined_timings[2];
+#elif defined(ZULUSCSI_MCU_RP23XX)
+    zuluscsi_timings_t *g_zuluscsi_timings = &predefined_timings[3];
+#elif defined(ZULUSCSI_PICO)
     zuluscsi_timings_t *g_zuluscsi_timings = &predefined_timings[1];
 #else
     zuluscsi_timings_t *g_zuluscsi_timings = &predefined_timings[0];
-    
 #endif
 
 

+ 3 - 11
lib/ZuluSCSI_platform_RP2MCU/timings.h → lib/ZuluSCSI_platform_RP2MCU/timings_RP2MCU.h

@@ -18,15 +18,10 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 **/
-#ifndef ZULUSCSI_RP2MCU_TIMINGS_H
-#define ZULUSCSI_RP2MCU_TIMINGS_H
+#ifndef ZULUSCSI_TIMINGS_RP2MCU_H
+#define ZULUSCSI_TIMINGS_RP2MCU_H
 #include <stdint.h>
 #include <stdbool.h>
-typedef enum
-{
-    ZULUSCSI_PIO_TARGET_MODE_SIMPLE,
-    ZULUSCSI_PIO_TARGET_MODE_EXTRA_DELAY,
-} zuluscsi_pio_target_mode_t;
 
 typedef struct
 {
@@ -63,7 +58,6 @@ typedef struct
     // Max sync - the minimum sync period ("max" clock rate) that is supported at this clock rate, the number is 1/4 the actual value in ns
     struct
     {
-        zuluscsi_pio_target_mode_t mode;
         uint8_t delay0;
         uint8_t delay1;
         int16_t total_delay_adjust;
@@ -72,7 +66,6 @@ typedef struct
 
     struct
     {
-        zuluscsi_pio_target_mode_t mode;
         uint8_t delay0;
         uint8_t delay1;
         int16_t total_delay_adjust;
@@ -81,7 +74,6 @@ typedef struct
 
     struct
     {
-        zuluscsi_pio_target_mode_t mode;
         uint8_t delay0;
         uint8_t delay1;
         int16_t total_delay_adjust;
@@ -111,4 +103,4 @@ typedef struct
 extern  zuluscsi_timings_t *g_zuluscsi_timings;
 
 bool set_timings(uint32_t target_clk_in_khz);
-#endif // ZULUSCSI_RP2MCU_TIMINGS_H
+#endif // ZULUSCSI_TIMINGS_RP2MCU_H

+ 3 - 3
src/ZuluSCSI.cpp

@@ -619,7 +619,7 @@ bool findHDDImages()
       logmsg("Eject set to device with ID: ", last_removable_device);
     else if (eject_btn_set == 0)
     {
-      logmsg("Found 1 removable device, to set an eject button see EjectButton in the, '", CONFIGFILE,"', or the http://zuluscsi.com/manual");
+      logmsg("Found 1 removable device, to set an eject button see EjectButton in the '", CONFIGFILE,"', or the http://zuluscsi.com/manual");
     } 
   }
   else if (removable_count > 1)
@@ -642,7 +642,7 @@ bool findHDDImages()
     }
     else
     {
-      logmsg("Multiple removable devices, to set an eject button see EjectButton in the, '", CONFIGFILE,"', or the http://zuluscsi.com/manual");
+      logmsg("Multiple removable devices, to set an eject button see EjectButton in the '", CONFIGFILE,"', or the http://zuluscsi.com/manual");
     }
   }
   return foundImage;
@@ -932,7 +932,7 @@ extern "C" void zuluscsi_setup(void)
     }
   }
 #endif
-
+  logmsg("Clock set to: ", (int) platform_sys_clock_in_hz(), "Hz");
   logmsg("Initialization complete!");
 }
 

+ 1 - 0
src/ZuluSCSI_cdrom.cpp

@@ -31,6 +31,7 @@
 #include "ZuluSCSI_cdrom.h"
 #include "ZuluSCSI_log.h"
 #include "ZuluSCSI_config.h"
+#include "ZuluSCSI_platform.h"
 #include "ZuluSCSI_settings.h"
 #include <CUEParser.h>
 #include <assert.h>

+ 10 - 2
src/ZuluSCSI_config.h

@@ -25,10 +25,10 @@
 
 #pragma once
 
-#include <ZuluSCSI_platform.h>
+#include <ZuluSCSI_platform_config.h>
 
 // Use variables for version number
-#define FW_VER_NUM      "24.10.28"
+#define FW_VER_NUM      "24.10.31"
 #define FW_VER_SUFFIX   "devel"
 
 #define ZULU_FW_VERSION FW_VER_NUM "-" FW_VER_SUFFIX
@@ -124,3 +124,11 @@
 // Zip disk  media sizes
 #define ZIP100_DISK_SIZE    100663296 // bytes
 #define ZIP250_DISK_SIZE    250640384 // bytes
+
+// Reclocking return status
+typedef enum
+{
+    ZULUSCSI_RECLOCK_SUCCESS,
+    ZULUSCSI_RECLOCK_NOT_SUPPORTED,
+    ZULUSCSI_RECLOCK_FAILED
+} zuluscsi_reclock_status_t;

+ 1 - 0
src/ZuluSCSI_tape.cpp

@@ -26,6 +26,7 @@
 #include "ZuluSCSI_disk.h"
 #include "ZuluSCSI_log.h"
 #include "ZuluSCSI_config.h"
+#include <ZuluSCSI_platform.h>
 
 extern "C" {
 #include <scsi.h>