📄 misc.c
字号:
//******************************************************************************
// File Name : misc.c
// Author : Steaven
// Created : 2008-06-09
// Modified :
// Revision : V0.0
//******************************************************************************
#include "app.h"
//global variables definition
INT8U bLED_Test_Enable = 0; //Enable LED Test
INT8U bBuzzer_Test_Enable = 0; //Enable BUZZER Test
//****************************************************************
// Function : sSet_LED_Test
// Input : bEnable - whether Enable LED Test or not
// Output : none
// Description : Interface Function-Set LED Test Flag
//****************************************************************
void sSet_LED_Test(INT8U bEnable)
{
bLED_Test_Enable = bEnable;
}
//****************************************************************
// Function : sbGet_LED_Test
// Input : none
// Output : none
// Description : Interface Function-Get LED Test Flag
//****************************************************************
INT8U sbGet_LED_Test(void)
{
return(bLED_Test_Enable);
}
//****************************************************************
// Function : sSet_Buzzer_Test
// Input : bEnable - whether Enable BUZZER Test or not
// Output : none
// Description : Interface Function-Set BUZZER Test Flag
//****************************************************************
void sSet_Buzzer_Test(INT8U bEnable)
{
bBuzzer_Test_Enable = bEnable;
}
//****************************************************************
// Function : sbGet_Buzzer_Test
// Input : none
// Output : none
// Description : Interface Function-Get BUZZER Test Flag
//****************************************************************
INT8U sbGet_Buzzer_Test(void)
{
return(bBuzzer_Test_Enable);
}
//****************************************************************
// Function : LED_ON_ALL
// Input : none
// Output : none
// Description : LED Control-ON LED
//****************************************************************
void LED_ON_ALL(void)
{
PORTD |= 0xF0;
}
//****************************************************************
// Function : LED_OFF_ALL
// Input : none
// Output : none
// Description : LED Control-OFF LED
//****************************************************************
void LED_OFF_ALL(void)
{
PORTD &= 0x0F;
}
//****************************************************************
// Function : BUZZER_ON
// Input : none
// Output : none
// Description : BUZZER Control-ON BUZZER
//****************************************************************
void BUZZER_ON(void)
{
PORTB |= 0x08;
}
//****************************************************************
// Function : BUZZER_OFF
// Input : none
// Output : none
// Description : BUZZER Control-OFF BUZZER
//****************************************************************
void BUZZER_OFF(void)
{
PORTB &= ~0x08;
}
//****************************************************************
// Function : swGet_Key1
// Input : none
// Output : true - Key1 active; false - Key1 - passitive
// Description : Key1 Detection,rising edge active
//****************************************************************
INT16U swGet_KEY_ESC(void)
{
static INT16U wKeyStatus = 1;
if(wKeyStatus == 1)
{
if((PINB & (1 << cKey1)) == 0) //Key Pressed
{
wKeyStatus = 0;
}
}
else if(wKeyStatus == 0)
{
if(PINB & (1 << cKey1)) //Key Released
{
wKeyStatus = 1;
return(true);
}
}
return(false);
}
//******************************************************************************
// Function : swGet_Key2
// Input : none
// Output : true - Key2 active; false - Key2 - passitive
// Description : Key1 Detection,rising edge active
//******************************************************************************
INT16U swGet_KEY_UP(void)
{
static INT16U wKeyStatus = 1;
if(wKeyStatus == 1)
{
if((PINB & (1 << cKey2)) == 0) //Key Pressed
{
wKeyStatus = 0;
}
}
else if(wKeyStatus == 0)
{
if(PINB & (1 << cKey2)) //Key Released
{
wKeyStatus = 1;
return(true);
}
}
return(false);
}
//******************************************************************************
// Function : swGet_Key3
// Input : none
// Output : true - Key3 active; false - Key3 - passitive
// Description : Key3 Detection,rising edge active
//******************************************************************************
INT16U swGet_KEY_DOWN(void)
{
static INT16U wKeyStatus = 1;
if(wKeyStatus == 1)
{
if((PINB & (1 << cKey3)) == 0) //Key Pressed
{
wKeyStatus = 0;
}
}
else if(wKeyStatus == 0)
{
if(PINB & (1 << cKey3)) //Key Released
{
wKeyStatus = 1;
return(true);
}
}
return(false);
}
//******************************************************************************
// Function : swGet_Key4
// Input : none
// Output : true - Key4 active; false - Key4 - passitive
// Description : Key4 Detection,rising edge active
//******************************************************************************
INT16U swGet_KEY_ENTER(void)
{
static INT16U wKeyStatus = 1;
if(wKeyStatus == 1)
{
if((PINB & (1 << cKey4)) == 0) //Key Pressed
{
wKeyStatus = 0;
}
}
else if(wKeyStatus == 0)
{
if(PINB & (1 << cKey4)) //Key Released
{
wKeyStatus = 1;
return(true);
}
}
return(false);
}
//******************************************************************************
// Function : Key_Detection
// Input : none
// Output : none
// Description : Keys Detection.if active,send Key Event to task
//******************************************************************************
void Key_Detection(void)
{
if(swGet_KEY_ESC()==true)
{
OS_Event_Post(cPrioLCD,eLCDKeyEsc);
}
if(swGet_KEY_UP()==true)
{
OS_Event_Post(cPrioLCD,eLCDKeyUp);
}
if(swGet_KEY_DOWN()==true)
{
OS_Event_Post(cPrioLCD,eLCDKeyDown);
}
if(swGet_KEY_ENTER()==true)
{
OS_Event_Post(cPrioLCD,eLCDKeyEnter);
}
}
//===============================END OF FILE==================================//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -