mirror of https://github.com/akuker/RASCSI.git
Replace timer in WaitSignal()
This commit is contained in:
parent
bd33f66694
commit
2e5982ddce
|
@ -403,42 +403,23 @@ bool GPIOBUS::PollSelectEvent()
|
|||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Cancel SEL signal event
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
void GPIOBUS::ClearSelectEvent()
|
||||
{
|
||||
GPIO_FUNCTION_TRACE
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Wait for signal change
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
bool GPIOBUS::WaitSignal(int pin, bool ast)
|
||||
{
|
||||
// Get current time
|
||||
const uint32_t now = SysTimer::GetTimerLow();
|
||||
|
||||
// Calculate timeout (3000ms)
|
||||
const uint32_t timeout = 3000 * 1000;
|
||||
const auto now = chrono::steady_clock::now();
|
||||
|
||||
// Wait 3 s
|
||||
do {
|
||||
// Immediately upon receiving a reset
|
||||
Acquire();
|
||||
if (GetRST()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for the signal edge
|
||||
if (GetSignal(pin) == ast) {
|
||||
return true;
|
||||
}
|
||||
} while ((SysTimer::GetTimerLow() - now) < timeout);
|
||||
|
||||
// We timed out waiting for the signal
|
||||
// Abort on a reset
|
||||
if (GetRST()) {
|
||||
return false;
|
||||
}
|
||||
} while ((chrono::duration_cast<chrono::seconds>(chrono::steady_clock::now() - now).count()) < 3);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -183,7 +183,10 @@ class GPIOBUS : public BUS
|
|||
// SEL signal event polling
|
||||
bool PollSelectEvent() override;
|
||||
// Clear SEL signal event
|
||||
void ClearSelectEvent() override;
|
||||
void ClearSelectEvent() override
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void MakeTable() = 0;
|
||||
|
|
Loading…
Reference in New Issue