#define MAX( x, y ) ( ((x) > (y)) ? (x) : (y) )
#define MIN( x, y ) ( ((x) < (y)) ? (x) : (y) )
#define FOSC 16.6//11.0592 //
#define MACHINE_NUM 1 //定时器
#define M_NUM 1 //程序 SH88F2051 程序是1T,定时器1T/12T可选
#define COVERT(T) ( (T*FOSC+M_NUM) / (M_NUM*2) -1 )
#if (M_NUM==1)
#define d_1ms() do{ uint8 x=30; do{ d_uS(33.0); }while(--x); }while(0)
#else
#if(M_NUM==12)
#define d_1ms() do{ d_uS(333.0);d_uS(333.0); d_uS(333.0); }while(0)
#else
#endif
#endif
#define d_uS(us) do{ uint8 cnt1=MIN(MAX(COVERT(us),1),256); do{}while(--cnt1); }while(0)
//Note:实际延时效果C51 12M 4<= us <= 514(uS)
//Note:实际延时效果88F54 16.6M 1<= us <= 31(uS)
#define d_mS(ms) do{ uint16 cnt2=ms; do{ d_1ms(); }while(--cnt2); }while(0)
|