?? zlg7289.h
字號:
#ifndef ZLG7289_H_
#define ZLG7289_H_
#include <intrins.h>
#include <reg52.h>
#ifndef uchar
#define uchar unsigned char
#endif
//申明一個(gè)全局變量,用于延時(shí)
//該變量在調(diào)用函數(shù)zlg7289_init()時(shí)被初始化
extern char zlg7289_delay_t;
/*
*宏定義:zlg7289_short_delay()
*功能:短延時(shí)
*說明:延時(shí)(zlg7289_delay_t*2+2)個(gè)機(jī)器周期
*/
#define zlg7289_short_delay() \
{\
uchar t = zlg7289_delay_t;\
while ( --t != 0 );\
}
/*
*宏定義:zlg7289_long_delay()
*功能:長延時(shí)
*說明:延時(shí)(zlg7289_delay_t*12+8)個(gè)機(jī)器周期
*/
#define zlg7289_long_delay()\
{\
uchar t = zlg7289_delay_t*6;\
while ( --t != 0 );\
}
//三線SPI
sbit zlg_dio=P1^7; //雙向數(shù)據(jù)線
sbit zlg_clk=P1^6; //時(shí)鐘信號
sbit zlg_cs=P1^5; //選通信號
sbit zlg_int=P3^2;
/*
*函數(shù)名: zlg7289_spi_init
*功能:初始化spi總線
*參數(shù):
* t:延時(shí)時(shí)間
*說明:
* # t的取值可以參照以下公式:t>=5*f1/f2
* 其中f1表示C51的晶振頻率,f2表示ZLG7289 的晶振頻率
*/
void zlg7289_spi_init(uchar t) ;
/*
*函數(shù)名: zlg7289_write
*功能: 向總線寫入一個(gè)字節(jié)
*參數(shù):
* d:要寫入的一個(gè)字節(jié)
*/
void zlg7289_write(uchar d);
/*
*函數(shù)名: zlg7289_read
*功能: 從總線讀入一個(gè)字節(jié)
*返回:
* 返回讀取的一個(gè)字節(jié)
*/
uchar zlg7289_read();
/*
*函數(shù)名: zlg7289_readkey
*功能: 讀取鍵值
*返回:
* 返回讀取的鍵值
*/
uchar zlg7289_readkey();
/*
*函數(shù):zlg7289_cmd()
*功能:執(zhí)行zlg7289不帶數(shù)據(jù)指令
*參數(shù):
*cmd:命令字
*/
void zlg7289_cmd(uchar cmd) ;
/*
*函數(shù):zlg7289_cmd_with_data()
*功能:執(zhí)行zlg7289 帶數(shù)據(jù)指令
*參數(shù):
*cmd:命令字
*d:數(shù)據(jù)
*/
void zlg7289_cmd_with_data(uchar cmd, uchar d) ;
/*
*函數(shù):zlg_Download()
*功能:下載數(shù)據(jù)
*參數(shù):
*mod:
* mod=0下載數(shù)據(jù)且按方式0 譯碼
* mod=1下載數(shù)據(jù)且按方式0 譯碼
* mod=2下載數(shù)據(jù)但不譯碼
*index:
* 數(shù)碼管編號(橫坐標(biāo)),0~7
*dp:
* dp=0小數(shù)點(diǎn)不亮 ,dp=1小數(shù)點(diǎn)亮
*d:
* 要顯示的數(shù)據(jù)
*說明:
* 方式0譯碼:
* 命令1 0 0 0 0 a2 a1 a0數(shù)據(jù)dp x x x d3 d2 d1 d0 顯示0-9 - E H L P 空
* 方式1譯碼:
* 命令1 1 0 0 1 a2 a1 a0數(shù)據(jù)dp x x x d3 d2 d1 d0 顯示0-F十六進(jìn)制
* 方式2譯碼:
* 命令1 0 0 1 0 a2 a1 a0數(shù)據(jù)dp a b c d e f g 將dp-g中位值為1的點(diǎn)亮
* a2 a1 a0為數(shù)碼管編號,d3 d2 d1 d0為數(shù)據(jù)
*/
void zlg_download(uchar mod,uchar index , bit dp,uchar d);
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -