?? i2cint.h
字號:
/*
---------------------------------------------------------------------------------------------------------
*********************************************************************************************************
** 文件名稱 : I2CINT.h
** 功能說明 : Luminary硬件I2C中斷方式軟件包。
** 使用說明 : 主程序要配置好I2C總線接口(I2C引腳功能和I2C中斷,并已使能I2C主模式)
*********************************************************************************************************
---------------------------------------------------------------------------------------------------------
*/
#ifndef __I2CINT_H__
#define __I2CINT_H__
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef ulong
#define ulong unsigned long
#endif
/*
******************************************************************************************
** 函數(shù)名稱: Delays()
** 函數(shù)功能: 延時
** 入口參數(shù): dly
** 出口參數(shù): 無
******************************************************************************************
*/
extern void Delays (ulong dly);
/*
*********************************************************************************************************
** 函數(shù)名稱:I2CInit()
** 函數(shù)功能:I2C接口初始化。
** 入口參數(shù):spd 總線速度100K(參數(shù)值為100000)或400K(參數(shù)值為4000000)
** pri 中斷優(yōu)先級0~7
** 出口參數(shù):返回值為false時表示操作出錯,為true時表示操作正確。
** 說明:
*********************************************************************************************************
*/
extern int I2CInit(ulong spd, uchar pri);
/*
*********************************************************************************************************
** 函數(shù)名稱:ISendByte()
** 函數(shù)功能:向無子地址器件發(fā)送1字節(jié)數(shù)據(jù)。
** 入口參數(shù):sla 器件地址
** c 要發(fā)送的數(shù)據(jù)
** 出口參數(shù):返回值為false時表示操作出錯,為true時表示操作正確。
** 說明: 使用前要初始化好I2C引腳功能和I2C中斷,并已使能I2C主模式
*********************************************************************************************************
*/
extern int ISendByte(uchar sla, uchar c);
/*
*********************************************************************************************************
** 函數(shù)名稱 :ISendStr()
** 函數(shù)功能 :向有子地址器件任意地址開始寫入N字節(jié)數(shù)據(jù)
** 入口參數(shù) : sla 器件從地址
** suba_type 子地址結(jié)構(gòu) 0-8+X結(jié)構(gòu) 1-單字節(jié)地址 2-雙字節(jié)地址 3-三字節(jié)地址
** suba 器件子地址
** s 數(shù)據(jù)發(fā)送緩沖區(qū)指針
** no 寫入的個數(shù)
** 出口參數(shù) : TRUE 操作成功
** FALSE 操作失敗
*********************************************************************************************************
*/
extern int ISendStr(uchar sla, ulong suba, uchar sub_type, uchar *s, ulong no);
/*
*********************************************************************************************************
** 函數(shù)名稱:ISendStrExt()
** 函數(shù)功能:向無子地址器件發(fā)送多字節(jié)數(shù)據(jù)。
** 入口參數(shù):sla 器件地址
** s 要發(fā)送的數(shù)據(jù)
** no 發(fā)送的字節(jié)個數(shù)
** 出口參數(shù):返回值為false時表示操作出錯,為true時表示操作正確。
** 說明: 發(fā)送數(shù)據(jù)字節(jié)至少2個字節(jié)
*********************************************************************************************************
*/
extern int ISendStrExt(uchar sla, uchar *s, uchar no);
/*
*********************************************************************************************************
** 函數(shù)名稱:IRcvByte()
** 函數(shù)功能:向無子地址器件讀取1字節(jié)數(shù)據(jù)。
** 入口參數(shù):sla 器件地址
** c 接收數(shù)據(jù)的變量指針
** 出口參數(shù):返回值為false時表示操作出錯,為true時表示操作正確。
** 說明: 使用前要初始化好I2C引腳功能和I2C中斷,并已使能I2C主模式
*********************************************************************************************************
*/
extern int IRcvByte(uchar sla, uchar *c);
/*
*********************************************************************************************************
** 函數(shù)名稱 :IRcvStr()
** 函數(shù)功能 :向有子地址器件讀取N字節(jié)數(shù)據(jù)
** 入口參數(shù) : sla 器件從地址
** suba_type 子地址結(jié)構(gòu) 0-8+X結(jié)構(gòu) 1-單字節(jié)地址 2-雙字節(jié)地址 3-三字節(jié)地址
** suba 器件內(nèi)部物理地址
** *s 將要讀取的數(shù)據(jù)的指針
** no 將要讀取的數(shù)據(jù)的個數(shù)
** 出口參數(shù) : TRUE 操作成功
** FALSE 操作失敗
*********************************************************************************************************
*/
extern int IRcvStr(uchar sla, ulong suba, uchar sub_type, uchar *s, uchar no);
/*
*********************************************************************************************************
** 函數(shù)名稱:IRvcStrExt()
** 函數(shù)功能:向無子地址器件讀取N字節(jié)數(shù)據(jù)。
** 入口參數(shù):sla 器件地址
** s 接收數(shù)據(jù)的變量指針
** no 將要讀取的數(shù)據(jù)的個數(shù)
** 出口參數(shù):使用前要初始化好I2C引腳功能和I2C中斷,并已使能I2C主模式
** 說明: 至少要讀取2個字節(jié)
*********************************************************************************************************
*/
extern int IRvcStrExt(uchar sla, uchar *s, uchar no);
#ifdef __cplusplus
}
#endif
#endif // __I2C_H__
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -