?? 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 + -