📄 ex_support._c
字号:
/***********************************************************
* 函数库说明:底层硬件初始化驱动函数库 *
* 版本: *
* 作者: *
* 创建日期: *
* -------------------------------------------------------- *
* [硬件说明] *
* 处理器: *
* 系统时钟: *
* -------------------------------------------------------- *
* [支 持 库] *
* 支持库名称:PF_Config.h *
* 需要版本: ----- *
* 声明库说明:硬件平台配置声明库 *
* *
* 支持库名称:HD_Support.h *
* 需要版本: ----- *
* 声明库说明:底层硬件初始化声明库 *
* *
* 支持库名称:EX_Support.h *
* 需要版本: ----- *
* 声明库说明:底层硬件初始化驱动声明库 *
* -------------------------------------------------------- *
* [版本更新] *
* 修改: *
* 修改日期: *
* 版本: *
* -------------------------------------------------------- *
* [版本历史] *
* -------------------------------------------------------- *
* [使用说明] *
***********************************************************/
/********************
* 头 文 件 配 置 区 *
********************/
# include "PF_Config.h"
# include "EX_Support.h"
# include "LIB_Config.h"
# include "RD_ADT_QUEUE.h"
# include "RD_ADT_MSGMap.h"
# include "RD_UseSerialFrame_PROC.h"
/********************
* 系 统 宏 定 义 *
********************/
/*------------------*
* 常 数 宏 定 义 *
*------------------*/
/*------------------*
* 动 作 宏 定 义 *
*------------------*/
/********************
* 模块结构体定义区 *
********************/
/********************
* 函 数 声 明 区 *
********************/
void Delay_MS(uint16 wTime);
void Insert_Timer0_OVF_ISR_Code(void);
void Driver_INIT(void);
uint8 Key_Press_Scan(void);
/********************
* 模块函数声明区 *
********************/
/********************
* 模块变量声明区 *
********************/
static uint16 s_wSystemDelayTimerCounter = 0;
/********************
* 全局变量声明区 *
********************/
uint16 g_wSystemTimer = 0;
uint16 g_wCommunicationTimer = 0;
/***********************************************************
* 函数说明:软件驱动初始化函数 *
* 输入: 无 *
* 输出: 无 *
* 调用函数:无 *
***********************************************************/
void Driver_INIT(void)
{
CMOS_INIT();
LCDInit();
LED_Flash_Control_INIT();
}
/***********************************************************
* 函数说明:系统毫秒延时函数 *
* 输入: 需要延时的时间长度 *
* 输出: 无 *
* 调用函数:无 *
***********************************************************/
void Delay_MS(uint16 wTime)
{
s_wSystemDelayTimerCounter = wTime;
while(s_wSystemDelayTimerCounter);
}
/***********************************************************
* 函数说明:定时器0中断处理程序代码插入函数 *
* 输入: 无 *
* 输出: 无 *
* 调用函数:无 *
***********************************************************/
void Insert_Timer0_OVF_ISR_Code(void)
{
g_wSystemTimer++;
if (s_wSystemDelayTimerCounter)
{
s_wSystemDelayTimerCounter--;
}
//USEKEY_INSERT_MS_TIMER_OVF_ISR_CODE
if (g_wCommunicationTimer)
{
g_wCommunicationTimer--;
LED_DATA = LED_FLASH_VERY_FAST;
}
else
{
LED_DATA = LED_ON;
}
/*
if (!(g_wSystemTimer & 0x0f))
{
LCDSP027_refresh_DISP_BUFF();
}
*/
//PROC_Serial_Transmitter();
//Serial_Frame_Process_Refresh();
PROC_LED_FLASH.IfProcAlive = TRUE;
}
/***********************************************************
* 函数说明:键盘扫描函数(不去抖) *
* 输入: 无 *
* 输出: 无 *
* 调用函数:无 *
***********************************************************/
uint8 Key_Press_Scan(void)
{
uint8 cKeyScanValue = KEY_NULL;
//扫描第一行
SET_KEY_OUT_ALL_PORT_HIGH
KEY_OUT_Y_P1 = LOW;
NOP();
if (!KEY_IN_X_P1)
{
cKeyScanValue = 0x00;
}
if (!KEY_IN_X_P2)
{
cKeyScanValue = 0x01;
}
if (!KEY_IN_X_P3)
{
cKeyScanValue = 0x02;
}
if (!KEY_IN_X_P4)
{
cKeyScanValue = 0x03;
}
//扫描第二行
SET_KEY_OUT_ALL_PORT_HIGH
KEY_OUT_Y_P2 = LOW;
NOP();
if (!KEY_IN_X_P1)
{
cKeyScanValue = 0x04;
}
if (!KEY_IN_X_P2)
{
cKeyScanValue = 0x05;
}
if (!KEY_IN_X_P3)
{
cKeyScanValue = 0x06;
}
if (!KEY_IN_X_P4)
{
cKeyScanValue = 0x07;
}
//扫描第三行
SET_KEY_OUT_ALL_PORT_HIGH
KEY_OUT_Y_P3 = LOW;
NOP();
if (!KEY_IN_X_P1)
{
cKeyScanValue = 0x08;
}
if (!KEY_IN_X_P2)
{
cKeyScanValue = 0x09;
}
if (!KEY_IN_X_P3)
{
cKeyScanValue = 0x0a;
}
if (!KEY_IN_X_P4)
{
cKeyScanValue = 0x0b;
}
//扫描第四行
SET_KEY_OUT_ALL_PORT_HIGH
KEY_OUT_Y_P4 = LOW;
NOP();
if (!KEY_IN_X_P1)
{
cKeyScanValue = 0x0c;
}
if (!KEY_IN_X_P2)
{
cKeyScanValue = 0x0d;
}
if (!KEY_IN_X_P3)
{
cKeyScanValue = 0x0e;
}
if (!KEY_IN_X_P4)
{
cKeyScanValue = 0x0f;
}
//扫描第五行
SET_KEY_OUT_ALL_PORT_HIGH
KEY_OUT_Y_P5 = LOW;
NOP();
if (!KEY_IN_X_P1)
{
cKeyScanValue = 0x10;
}
if (!KEY_IN_X_P2)
{
cKeyScanValue = 0x11;
}
if (!KEY_IN_X_P3)
{
cKeyScanValue = 0x12;
}
if (!KEY_IN_X_P4)
{
cKeyScanValue = 0x13;
}
return cKeyScanValue;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -