📄 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(void ); // LED test
void leds_on(void ); // all leds on
void leds_off(void ); // all leds off
void led1_on(void ); // led 1 on
void led1_off(void ); // led 1 off
void led2_on(void ); // led 2 on
void led2_off(void ); // led 2 off
void led3_on(void ); // led 3 on
void led3_off(void ); // led 3 off
void led4_on(void ); // led 4 on
void led4_off(void ); // led 4 off
void led_display(int nLedStatus); // led control
void beep(int BeepStatus) ;
/*********************************************************************************************
* name: led_test
* func: leds test funciton
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led_test()
{
beep(1);
led2_on();
led3_on();
delay(2000);
// 1 on -> 2 on -> all on -> 2 off -> 1 off
leds_off();
delay(1000);
led1_on();
delay(1800);
led1_off();
led2_on();
delay(800);
beep(0);
leds_on();
delay(800);
led2_off();
led1_off();
delay(1000);
}
/*********************************************************************************************
* name: leds_on,led_off
* func: all leds light or close
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void leds_on()
{
led_display(0xF);
}
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: led3_on,led3_off
* func: led 3 light or close
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led3_on()
{
f_nLedState = f_nLedState | 0x4;
led_display(f_nLedState);
}
void led3_off()
{
f_nLedState = f_nLedState&0xFB;
led_display(f_nLedState);
}
/*********************************************************************************************
* name: led4_on,led4_off
* func: led 4 light or close
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led4_on()
{
f_nLedState = f_nLedState | 0x8;
led_display(f_nLedState);
}
void led4_off()
{
f_nLedState = f_nLedState&0xf7;
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)
rPDATC &= 0xFEFF; // GPC8:LED1 (D1204) on
else
rPDATC |= (1<<8); // off
if((nLedStatus&0x02) == 0x02)
rPDATC &= 0xFDFF; // GPC9:LED2 (D1205) on
else
rPDATC |= (1<<9); // off
if((nLedStatus&0x04) == 0x04)
rPDATF &= 0xEF; // GPF4:LED3 (D1206) on
else
rPDATF |= (1<<4); // off
if((nLedStatus&0x08) == 0x08)
rPDATF &= 0xF7; // GPF3:LED4 (D1207) on
else
rPDATF |= (1<<3); // off
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -