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. The delay function should not be used for longer delays than 1000 us. Calling the delay function with > 1000 will give unpredictable results. 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.
|Calibrates the microsecond delay loop. |
|void||UDELAY_Delay (uint32_t usecs)|
|Microsecond active wait delay routine. |
Microsecond active wait delay routine.
- The delay function should not be used for longer delays than 1000 us. Calling the delay function with > 1000 will give unpredictable results.
Number of microseconds to delay.
Definition at line
322 of file