private int PollSromStatus(uint timeOut, out string strError) { int hr = S_OK; bool fTimeout = false; int baseAddr = CPUSS_SYSREQ; int readData; int timeStart, timeNow; //Poll for operation completion timeStart = GetTickCount(); do { if (fTimeout) { strError = "Timeout of SROM polling. Lost communication with chip."; return(E_FAIL); } hr = Programmer.DAP_ReadIO(baseAddr, out readData, out strError); if (!IsSuccess(hr)) { return(hr); } timeNow = GetTickCount(); fTimeout = ((timeNow - timeStart) >= timeOut); unchecked { readData &= (int)(SROM_SYSREQ_BIT | SROM_PRIVILEGED_BIT); } } while (readData != 0x00); //this bit is reset when SROM request completed //Check status of operation int statusCode; hr = Programmer.DAP_ReadIO(CPUSS_SYSARG, out statusCode, out strError); if (!IsSuccess(hr)) { return(hr); } if ((statusCode & 0xF0000000) != SROM_STATUS_SUCCEEDED) { strError = SROM_FormatStatus(statusCode); return(E_FAIL); } return(hr); }