Files
CHJ/user/Utility/delay.c
2026-03-20 21:19:53 +08:00

78 lines
1.1 KiB
C

#include "../main/SystemInclude.h"
#include "delay.h"
void delay_ms(u16 ms)
{
u16 temp;
for (; ms > 0; ms--)
{
#if LOOP_1000US < 65535
for (temp = (u16)LOOP_1000US; temp > 0; temp--){
__NOP();
}
#if DELTA_1000US > 0
__NOP();
#endif
#if DELTA_1000US > 1
__NOP();
#endif
#if DELTA_1000US > 2
__NOP();
#endif
#if DELTA_1000US > 3
__NOP();
#endif
#if DELTA_1000US > 4
__NOP();
#endif
#if DELTA_1000US > 5
__NOP();
#endif
#else
// Clear_WDT();
delay_10us(100);
#endif
}
}
void delay_10us(u16 us)
{
u16 temp;
for (; us > 0; us--)
{
for (temp = (u16)LOOP_10US; temp > 0; temp--);
#if DELTA_10US > 0
__NOP();
#endif
#if DELTA_10US > 1
__NOP();
#endif
#if DELTA_10US > 2
__NOP();
#endif
#if DELTA_10US > 3
__NOP();
#endif
#if DELTA_10US > 4
__NOP();
#endif
#if DELTA_10US > 5
__NOP();
#endif
}
}