cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

MaSt_4567191
New Contributor II

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;

}

0 Likes
1 Solution
KandlaguntaR_36
Moderator
Moderator

Hi,

You can use CyU3PGetTime - Get the number of elapsed OS timer ticks since FX3 system start-up.

Each tick value is 1 ms.

Regards,

Sridhar

View solution in original post

5 Replies
KandlaguntaR_36
Moderator
Moderator

Hello,

Are you using Do While loop here?

I don't see where you put DO in the snippet.

If you want a delay, you can use CyU3PBusyWait or CyU3PThreadSleep.

Regards,

Sridhar

MaSt_4567191
New Contributor II

Yes I am using a do ... while (just forgot to copy and paste the do ....

I do not want a delay but I am trying to create a timeout in order not to 'block' the application

I wonder if CLOCK_PER_SECONDS macro (==10 which seems to me a too small value ...) is reliable (I see EZUSB example code does not use CMSIS and the system timer but I understand the SoC is based on the good old 926 and not on a cortex)

Thanks much

0 Likes
KandlaguntaR_36
Moderator
Moderator

Hi,

You can use CyU3PGetTime - Get the number of elapsed OS timer ticks since FX3 system start-up.

Each tick value is 1 ms.

Regards,

Sridhar

View solution in original post

MaSt_4567191
New Contributor II

Thanks much. This solve my problem

One last question; which RTOS is used? It is derived from freeRTOS or what? I'd like to access some documentation about it

regards

0 Likes
KandlaguntaR_36
Moderator
Moderator

Hi,

It is ThreadX RTOS.

regards,

sridhar

0 Likes