📄 miscellaneous.c
字号:
#define MISCELL_GLOBLE
#include "includes.h"
/****************************************************************/
/*description: delay a while depend on the PB_delay */
/* each unit of delay is 260.1 ms when applying 36014f */
/* */
/*input parameters: PB_delay:the delay number */
/* */
/*output argument: none */
/*relative globe variables: none */
/***************************************************************/
/*each unit of delay is 260.1 ms*/
void delay(uchar PB_delay)
{
uchar i,j,k;
for(i=PB_delay;i!=0;i--)
{
for(j=0;j<255;j++)
{
for(k=0;k<255;k++)
{
#ifdef crystal4M
nop();nop();
nop();nop();nop();
#else
#ifdef crystal8M
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
nop();nop();nop();
#else
#ifdef crystal10M
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
#else
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
#endif
#endif
#endif
}
}
}
}
void toggle_led0(void)
{
P_LED0_INV;delay(2);P_LED0_INV;
}
void toggle_led1(void)
{
P_LED1_INV;delay(2);P_LED1_INV;
}
/****************************************************************/
/*description: delay a while depend on the PB_delay */
/* each unit of sub_delay is 2.04 ms */
/* */
/*input parameters: PB_delay:the delay number */
/* */
/*output argument: none */
/*relative globe variables: none */
/***************************************************************/
void sub_delay(uchar PB_delay)
{
uchar i,j;
for(i=PB_delay;i!=0;i--)
{
for(j=0;j<255;j++)
{
#ifdef crystal4M
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
nop();nop();nop();
#else
#ifdef crystal8M
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
nop();nop();nop();nop();
#else
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
nop();nop();nop();nop();nop();
#endif
#endif
}
}
}
/****************************************************************/
/*description: delay a while depend on the PB_delay */
/* each unit of sub_delay is XX us */
/* */
/*input parameters: PB_delay:the delay number */
/* */
/*output argument: none */
/*relative globe variables: none */
/***************************************************************/
void us_delay(uchar PB_delay)
{
uchar i;
for(i=PB_delay;i!=0;i--)
{
nop();nop();
}
}
/****************************************************************/
/*description: */
/* */
/* */
/*input parameters: */
/* */
/*output argument: */
/*relative globe variables: */
/***************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -