Udelay
[Drivers]

Implements active wait microsecond delay. More...

Collaboration diagram for Udelay:

Functions

void UDELAY_Calibrate (void)
 Calibrates the microsecond delay loop.
void UDELAY_Delay (uint32_t usecs)
 Microsecond active wait delay routine.

Detailed Description

Implements active wait microsecond delay.

The delay is implemented as a loop coded in assembly. The delay loop must be calibrated by calling UDELAY_Calibrate() once. The calibration algorithm is taken from linux 2.4 sources (bogomips).

The delay is fairly accurate, the assembly coding will not be optimized by the compiler. Recalibrate the loop when HFCORECLK is changed.

The calibration uses the RTC clocked by LFRCO to measure time. Better accuracy can be achieved by adding #define UDELAY_LFXO (i.e. add -DUDELAY_LFXO on the commandline). The LFXO oscillator is then used for delay loop calibration.

The calibration function will restore RTC upon exit.


Function Documentation

void UDELAY_Calibrate ( void   ) 

Calibrates the microsecond delay loop.

Definition at line 65 of file udelay.c.

void UDELAY_Delay ( uint32_t  usecs  ) 

Microsecond active wait delay routine.

Parameters:
[in] usecs Number of microseconds to delay.

Definition at line 202 of file udelay.c.