mirror of
https://github.com/akuker/RASCSI.git
synced 2025-02-16 19:31:09 +00:00
Replace system timer by C++ standard time for timeout of 3 s (#1361)
This commit is contained in:
parent
bb602040e2
commit
a7c71e4fbb
@ -20,7 +20,6 @@
|
|||||||
#include "devices/storage_device.h"
|
#include "devices/storage_device.h"
|
||||||
#include "hal/gpiobus_factory.h"
|
#include "hal/gpiobus_factory.h"
|
||||||
#include "hal/gpiobus.h"
|
#include "hal/gpiobus.h"
|
||||||
#include "hal/systimer.h"
|
|
||||||
#include "piscsi/piscsi_core.h"
|
#include "piscsi/piscsi_core.h"
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -29,6 +28,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace filesystem;
|
using namespace filesystem;
|
||||||
@ -684,21 +684,19 @@ bool Piscsi::ShutDown(AbstractController::piscsi_shutdown_mode shutdown_mode)
|
|||||||
bool Piscsi::IsNotBusy() const
|
bool Piscsi::IsNotBusy() const
|
||||||
{
|
{
|
||||||
// Wait until BSY is released as there is a possibility for the
|
// Wait until BSY is released as there is a possibility for the
|
||||||
// initiator to assert it while setting the ID (for up to 3 seconds)
|
// initiator to assert it while setting the ID (for up to 3 seconds)
|
||||||
if (bus->GetBSY()) {
|
if (bus->GetBSY()) {
|
||||||
const uint32_t now = SysTimer::GetTimerLow();
|
const auto now = chrono::steady_clock::now();
|
||||||
|
while ((chrono::duration_cast<chrono::seconds>(chrono::steady_clock::now() - now).count()) < 3) {
|
||||||
|
bus->Acquire();
|
||||||
|
|
||||||
// Wait for 3s
|
if (!bus->GetBSY()) {
|
||||||
while ((SysTimer::GetTimerLow() - now) < 3'000'000) {
|
return true;
|
||||||
bus->Acquire();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!bus->GetBSY()) {
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user