📄 thestatus.c
字号:
/**********************************************
* File: TheStatus.c
* Description: MCU Status report with LEDs
* Created Date: 2007-09-12
* Last Modified: 2007-09-12
* Author: Jeffrey - Schicksal@126.com
* Notes: None
**********************************************/
#include <REGX51.h>
#define LED_FLASH_T 10000;
void LEDs_Move();
void LEDs_Error();
/**********************************************
* Function: delay(unsigned int t)
* Input Variables: t
* Return Variables: None
* Usage: Common Delay Routine, t as the delay time ticks
**********************************************/
void delay(unsigned int t)
{
for(;t>0;t--); // 延时循环
}
#ifndef true
#define true 1
#endif
/**********************************************
* Function: main()
* Input Variables: None
* Return Variables: None
* Usage: Program Entry
*********************************************/
void main()
{
unsigned char System_Status;
while(1)
{
// 程序主任务区
// ............
// 程序主任务区
if(System_Status == true) // 当系统处于正常状态
{
LEDs_Move(); // 跑马灯指示系统正常
}
else // 当系统发生错误
{
LEDs_Error(); // 跑马灯指示错误
}
}
}
/**********************************************
* Function: LEDs_Move
* Input Variables: None
* Return Variables: None
* Usage: System Normal Status Report
*********************************************/
void LEDs_Move()
{
static unsigned char LEDs = 0x55; // 静态变量用于存储LEDs发光状态
P0 = LEDs; // LED间隔亮灭并移位
delay(LED_FLASH_T); // 延时
LEDs = ~LEDs; // 状态改变
}
/**********************************************
* Function: LEDs_Error
* Input Variables: None
* Return Variables: None
* Usage: System Error Status Report
*********************************************/
void LEDs_Error()
{
static unsigned char LEDs = 0x00; // 静态变量用于存储LEDs发光状态
P0 = LEDs; // LED警告报警亮灭
delay(LED_FLASH_T); // 延时
LEDs = ~LEDs; // 状态改变
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -