00001 #ifndef __HAL_DELAY_H 00002 #define __HAL_DELAY_H 00003 #include "stdint.h" 00004 00005 /* This function overflows at 65535 us. 00006 * For Keil C51 compiler, this function is accurate down to 10 us, with deviation of upto 2 us. 00007 * 00008 * For the IAR 8051 C compiler, the function is not as accurate before hitting about 500 us. 00009 * Over this number, it seem to have a deviation of about 5 to 10 us. 00010 */ 00011 void delay_us(uint16_t us); 00012 00013 /* Function for looping "delay_us" 00014 * 00015 */ 00016 void delay_ms(uint16_t ms); 00017 00018 #define delay_s(x) delay_ms((uint16_t)1000 * (uint16_t)x) 00019 #endif