From 70bcb78d2467ef7a22388908ecca3ce52d329508 Mon Sep 17 00:00:00 2001 From: Uwe Seimet <48174652+uweseimet@users.noreply.github.com> Date: Wed, 15 Nov 2023 07:51:21 +0100 Subject: [PATCH] Use a standard timer for the DaynaPort delay work-around (#1357) * Do not use the proprietary system timer for the DaynaPort delay work-around --- cpp/hal/bus.h | 2 +- cpp/hal/gpiobus.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cpp/hal/bus.h b/cpp/hal/bus.h index 17a1a805..506cebf3 100644 --- a/cpp/hal/bus.h +++ b/cpp/hal/bus.h @@ -54,7 +54,7 @@ const static int SCSI_DELAY_FAST_NEGATION_PERIOD_NS = 30; // The DaynaPort SCSI Link do a short delay in the middle of transfering // a packet. This is the number of uS that will be delayed between the // header and the actual data. -const static int SCSI_DELAY_SEND_DATA_DAYNAPORT_US = 100; +const static int SCSI_DELAY_SEND_DATA_DAYNAPORT_NS = 100'000; class bus_exception : public runtime_error diff --git a/cpp/hal/gpiobus.cpp b/cpp/hal/gpiobus.cpp index 397ed9cf..f0dc9cf5 100644 --- a/cpp/hal/gpiobus.cpp +++ b/cpp/hal/gpiobus.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #ifdef __linux__ #include #endif @@ -278,9 +278,12 @@ int GPIOBUS::SendHandShake(uint8_t *buf, int count, int delay_after_bytes) if (actmode == mode_e::TARGET) { for (i = 0; i < count; i++) { if (i == delay_after_bytes) { - spdlog::trace("DELAYING for " + to_string(SCSI_DELAY_SEND_DATA_DAYNAPORT_US) + " us after " + + spdlog::trace("DELAYING for " + to_string(SCSI_DELAY_SEND_DATA_DAYNAPORT_NS) + " ns after " + to_string(delay_after_bytes) + " bytes"); - SysTimer::SleepUsec(SCSI_DELAY_SEND_DATA_DAYNAPORT_US); + EnableIRQ(); + const timespec ts = { .tv_sec = 0, .tv_nsec = SCSI_DELAY_SEND_DATA_DAYNAPORT_NS}; + nanosleep(&ts, nullptr); + DisableIRQ(); } // Set the DATA signals