效果显示 - #include
- #include "MacroAndConst.h"
- #include "Led.h"
- #include "Timer.h"
- static uint16 g_u16LedTimeCount = 0 ; //LED 计数器
- static uint8 g_u8LedState = 0 ; //LED 状态标志, 0表示亮,1表示熄灭
- #define LED P0 //定义 LED 接口
- #define LED_ON() LED = 0x00 ; //所有 LED 亮
- #define LED_OFF() LED = 0xff ; //所有 LED 熄灭
- void LedProcess(void)
- {
- if(0 == g_u8LedState) //如果 LED 的状态为亮,则点亮 LED
- {
- LED_ON() ;
- }
- else //否则熄灭 LED
- {
- LED_OFF() ;
- }
- }
-
- void LedStateChange(void)
- {
- if(g_bSystemTime1Ms) //系统1MS 时标到
- {
- g_bSystemTime1Ms = 0 ;
- g_u16LedTimeCount++ ; //LED 计数器加一
- if(g_u16LedTimeCount >= 500) //计数达到500,即500MS 到了,改变 LED 的状态。
- {
- g_u16LedTimeCount = 0 ;
- g_u8LedState = ! g_u8LedState ;
- }
- }
- }
复制代码 |