wiced_result_t wiced_rtos_delay_microseconds( uint32_t microseconds )
{
 //rk change
    #if 0
      uint32_t current_time;
    uint32_t duration;
    uint32_t elapsed_time = 0;

    current_time = host_platform_get_cycle_count( );
    duration     = ( microseconds * CPU_CYCLES_PER_MICROSECOND );
    while ( elapsed_time < duration )
    {
        elapsed_time = host_platform_get_cycle_count( ) - current_time;
    }
#endif
    return WICED_SUCCESS;
}
Beispiel #2
0
/**
 * Delay for a number of milliseconds
 *
 * Processing of this function depends on the minimum sleep
 * time resolution of the RTOS.
 * The current thread sleeps for the longest period possible which
 * is less than the delay required, then makes up the difference
 * with a tight loop
 *
 * @return wwd_result_t : WWD_SUCCESS if delay was successful
 *                        : WICED_ERROR if an error occurred
 *
 */
wwd_result_t host_rtos_delay_milliseconds( uint32_t num_ms )
{
    if ( ( num_ms * SYSTICK_FREQUENCY / 1000 ) != 0 )
    {
        if ( ( tx_thread_sleep( (ULONG) ( num_ms * SYSTICK_FREQUENCY / 1000 ) ) ) != TX_SUCCESS )
        {
            return WWD_SLEEP_ERROR;
        }
    }
    else
    {
        uint32_t time_reference = host_platform_get_cycle_count( );
        int32_t wait_time       = (int32_t)num_ms * CPU_CLOCK_HZ / 1000;
        while ( wait_time > 0 )
        {
            uint32_t current_time = host_platform_get_cycle_count( );
            wait_time            -= (int32_t)( current_time - time_reference );
            time_reference        = current_time;
        }
    }

    return WWD_SUCCESS;
}