?? example_iog.c
字號:
/************************************************************************************
* Copyright (c), 2004-2007,西安銘朗電子科技有限責任公司
* All rights reserved.
*
* Http: www.mlarm.com
* Email: mlarm@mlarm.com
*
* File name: Example_IOG.c
*
* Project : ML-F020ICB
* Processor: C8051F020
* Compiler : Keil C51 Compiler
*
* Author: EagleC
* Version: 1.00
* Date: 2007.07.05
* Email:
*
* Description: 本文件是光耦隔離IO端口測試程序文件;
*
* Others: none;
*
* Function List:
*
* History:
* 1. Author: Eagle Cao
* Version: 1.00
* Date: 2007.07.05
* Modification: 建立文件
*
*************************************************************************************/
/************************************************************************************/
// 引用外部頭文件
#include "driver.h"
#include "api.h"
#include "ShowLCD.h"
/************************************************************************************/
/************************************************************************************/
// 常量及全局變量定義
extern unsigned long g_nTimer4s; //定時器4的次數
/************************************************************************************/
/*************************************************************************************/
//
// IOG端口測試程序函數定義
//
/*************************************************************************************/
/***********************************************************************************
* Function: IOG_Proc;
*
* Description: 光耦隔離IO端口測試程序;
*
* Input: none;
*
* Return: none;
*
* Note: none;
************************************************************************************/
void IOG_Proc(void)
{
unsigned char i,cmd;
unsigned char ucSetVal; //Put IO輸出值
unsigned char val; //Get IO輸入值
unsigned char flag_;
unsigned char *pDraw;
unsigned char nX;
unsigned char *pItem;
LCDB_ClearScreen();
Show_Title();
LCDB_DispFWord(32,8*(20-7),"隔 離 IO 監 測");
ucSetVal = 0;
flag_ = 1;
Show_IOG();
g_nTimer4s=51;
while(1)
{
EWachdog_Clear();
cmd = Key_Read();
if(cmd != CH452_KEY_INVAL)
{
ALARM_Ctrl(1);
Delay_ms(20);
ALARM_Ctrl(0);
switch (cmd)
{
case 0x00: //設置IO端口輸出0
ucSetVal = 0;
g_nTimer4s=51;
break;
case 0x01: //設置IO端口輸出1
ucSetVal = 1;
g_nTimer4s=51;
break;
case 0x0D: //確認
flag_ = 1;
Show_ClareX64();
Show_IOG();
g_nTimer4s=51;
break;
case 0x0E: //顯示說明文件
flag_ = 0;
Show_ClareX64();
nX = 64;
pItem = "本測試程序主要測試隔離IO端口的輸出、輸入。";
LCDB_DispFWord(nX, 32,pItem);
pItem = "0:設置IO端口輸出0";
LCDB_DispFWord(nX+16*3, 56,pItem);
pItem = "1:設置IO端口輸出1";
LCDB_DispFWord(nX+16*4, 56,pItem);
pItem = "D:確認";
LCDB_DispFWord(nX+16*5, 56,pItem);
pItem = "E:幫助";
LCDB_DispFWord(nX+16*6, 56,pItem);
pItem = "F:返回";
LCDB_DispFWord(nX+16*7, 56,pItem);
break;
case 0x0F:
return;
}
}
if(flag_)
{
if(g_nTimer4s<50) continue;
g_nTimer4s = 0;
for(i=1;i<=8;i++)
{
nX = ORIGIN_X+16*i;
val=IOGx_GetVal(i);
if(val)
pDraw = "1";
else
pDraw = "0";
LCDB_DispFWord(nX, ORIGIN_0Y+8*13,pDraw);
}
for(i=1;i<=8;i++)
{
nX = ORIGIN_X+16*i;
IOGx_PutVal(i,ucSetVal);
if(ucSetVal)
pDraw = "1";
else
pDraw = "0";
LCDB_DispFWord(nX, ORIGIN_1Y+8*13,pDraw);
}
}
}
}
/***********************************************************************************/
// 文件結束
/***********************************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -