From 6aa8b93975fec623981bc6fa8892f15dcfc2fbc8 Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Thu, 16 Nov 2023 16:47:07 +0100 Subject: [PATCH] Merge with develop --- cpp/hal/bus.h | 2 +- cpp/hal/gpiobus.cpp | 9 ++++++--- cpp/hal/gpiobus_raspberry.cpp | 27 ++++++++------------------- cpp/hal/sbc_version.cpp | 2 +- 4 files changed, 16 insertions(+), 24 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 diff --git a/cpp/hal/gpiobus_raspberry.cpp b/cpp/hal/gpiobus_raspberry.cpp index 030413fd..03bb9640 100644 --- a/cpp/hal/gpiobus_raspberry.cpp +++ b/cpp/hal/gpiobus_raspberry.cpp @@ -606,42 +606,31 @@ uint8_t GPIOBUS_Raspberry::GetDAT() return (uint8_t)data; } -//--------------------------------------------------------------------------- -// -// Set data signals -// -//--------------------------------------------------------------------------- void GPIOBUS_Raspberry::SetDAT(uint8_t dat) { - // Write to port + // Write to ports #if SIGNAL_CONTROL_MODE == 0 uint32_t fsel = gpfsel[0]; fsel &= tblDatMsk[0][dat]; fsel |= tblDatSet[0][dat]; - if (fsel != gpfsel[0]) { - gpfsel[0] = fsel; - gpio[GPIO_FSEL_0] = fsel; - } + gpfsel[0] = fsel; + gpio[GPIO_FSEL_0] = fsel; fsel = gpfsel[1]; fsel &= tblDatMsk[1][dat]; fsel |= tblDatSet[1][dat]; - if (fsel != gpfsel[1]) { - gpfsel[1] = fsel; - gpio[GPIO_FSEL_1] = fsel; - } + gpfsel[1] = fsel; + gpio[GPIO_FSEL_1] = fsel; fsel = gpfsel[2]; fsel &= tblDatMsk[2][dat]; fsel |= tblDatSet[2][dat]; - if (fsel != gpfsel[2]) { - gpfsel[2] = fsel; - gpio[GPIO_FSEL_2] = fsel; - } + gpfsel[2] = fsel; + gpio[GPIO_FSEL_2] = fsel; #else gpio[GPIO_CLR_0] = tblDatMsk[dat]; gpio[GPIO_SET_0] = tblDatSet[dat]; -#endif // SIGNAL_CONTROL_MODE +#endif } //--------------------------------------------------------------------------- diff --git a/cpp/hal/sbc_version.cpp b/cpp/hal/sbc_version.cpp index caebbedf..cd334ad3 100644 --- a/cpp/hal/sbc_version.cpp +++ b/cpp/hal/sbc_version.cpp @@ -144,7 +144,7 @@ uint32_t SBC_Version::GetPeripheralAddress(void) return address; } -#elif defined __NetBSD__ +#elif defined __NetBSD__ && (!defined(__x86_64__) || defined(__X86__)) uint32_t SBC_Version::GetPeripheralAddress(void) { char buf[1024];