5 Replies Latest reply on Dec 11, 2019 7:48 AM by KandlaguntaR_36

    timeout foe EZUSB

    MaSt_4567191

      I need to code a timeout for making a loop non blocking using <time.h>.

      I am in the EZUSB echosystem (no cmisys, ARM9269)

       

      Please advice: here is the code exceprt

       

      Thanks

       

      #include <time.h> // are deines correct?

       

      ErrorCode_t postReset(void)

      {

      cmd_reg_t _cmd;

      uint8_t _trigger_ms = 10; /* 10ms */

      const clock_t _before = clock();

      {

          const clock_t _delta = clock() - _before;

          uint16_t _msec = _delta * 1000 / CLOCKS_PER_SEC; // CLOCK_PER_SECONDS is guarantee?

              if (_msec > _trigger_ms)

      {

      _status = -1;

                  break;

      }

          _status = I2C_Read(sys_ctl.command_register.addr, 2, &(uint8_t)_cmd);

          if(_status !=0 )

        break;

      } while (_cmd.ok !=1);

          return _status;

      }