📄 led.c
字号:
/*********************************************************************************************
* File: led.c
* Author: embest
* Desc: control board's LEDs
* History:
*********************************************************************************************/
#include "44b.h"
#include "44blib.h"
/*------------------------------------------------------------------------------------------*/
/* global variables */
/*------------------------------------------------------------------------------------------*/
int f_nLedState; // LED status
/*------------------------------------------------------------------------------------------*/
/* function declare */
/*------------------------------------------------------------------------------------------*/
void led_test(unsigned char cnt); // LED test
void leds_on(); // all leds on
void leds_off(); // all leds off
void led1_on(); // led 1 on
void led1_off(); // led 1 off
void led2_on(); // led 2 on
void led2_off(); // led 2 off
void led_display(int nLedStatus); // led control
/*********************************************************************************************
* name: led_test
* func: leds test funciton
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led_test(unsigned char cnt)
{
rPDATF = rPDATF&0xef; // LED 3 (D1206) off
delay(cnt*900);
rPDATF = rPDATF|0xff; // LED 3 (D1206) on
}
/*********************************************************************************************
* name: leds_on,led_off
* func: all leds light or close
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void leds_on()
{
led_display(0x3);
}
void leds_off()
{
led_display(0x0);
}
/*********************************************************************************************
* name: led1_on,led1_off
* func: led 1 light or close
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led1_on()
{
f_nLedState = f_nLedState | 0x1;
led_display(f_nLedState);
}
void led1_off()
{
f_nLedState = f_nLedState&0xfe;
led_display(f_nLedState);
}
/*********************************************************************************************
* name: led2_on,led2_off
* func: led 2 light or close
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led2_on()
{
f_nLedState = f_nLedState | 0x2;
led_display(f_nLedState);
}
void led2_off()
{
f_nLedState = f_nLedState&0xfd;
led_display(f_nLedState);
}
/*********************************************************************************************
* name: led_display
* func: light or close the Led 1,2
* para: nLedStatus -- input, light LED 1,2 according to the nLedStatus' bit[2:1]
* nLedStatus' bit[2:1] = 00 : LED 2,1 off
* nLedStatus' bit[2:1] = 11 : LED 2,1 on
* nLedStatus = 1 : LED 1 on
* nLedStatus = 2 : LED 2 on
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led_display(int nLedStatus)
{
f_nLedState = nLedStatus;
// change the led's current status
if((nLedStatus&0x01) == 0x01)
rPDATB = rPDATB&0x6F; // PB4:LED1 (D1204) on
else
rPDATB = rPDATB|(1<<4); // PB4:LED1 (D1204) off
if((nLedStatus&0x02) == 0x02)
rPDATB = rPDATB&0x5F; // PB5:LED2 (D1205) on
else
rPDATB = rPDATB|(1<<5); // PB5:LED2 (D1205) off
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -