📄 iic.h.txt
字号:
#ifndef _IIC_H_
#define _IIC_H_
/*
* I2C D-òé
* ′|àí?÷ààDí£oC51
* °?±?£o1 è??ú£o2006-12-13
*
* °?±?£o2 è??ú£o2006-12-28
* ê1ó?°?±?2Dè?¨ò?I2C_V2
* ?ü??£o?°I2CWriteBunch?±·?·¨·??a?°dat?±2?êy?aêy?Yμ??·?°datAdd?±oí?°dat?±£?è¥3yá?2?êyautoStop
*
* ×÷??£o??μ?í?<yangdewang@gmail.com>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA. Or, point your browser to
* http://www.gnu.org/copyleft/gpl.html
*/
#include <configure.h>
//#define IIC_MULTI_MATER
//#define I2C_WRITEBYTE_U
//?¨ò?êy?Y?ó?úòy??
#ifndef SDA_I2C_PIN
#define SDA_I2C_PIN (P0^0)
#endif//SDA_I2C_PIN
#ifndef SCL_I2C_PIN
#define SCL_I2C_PIN (P0^1)
#endif//SDA_I2C_PIN
sbit SDA_I2C=SDA_I2C_PIN;
sbit SCL_I2C=SCL_I2C_PIN;
#define IIC_WAITCYCLE 1 //?¨ò?μè′y?y?ùéè±?μ?ê±??
extern bool I2CStart(uint8,bool); //?°?·′ó?ú1:μ??·2:?á/D′:true=read re:true=3é1|
#ifdef I2C_V2
/***************************************************
D′ò???×??ú′?μ????¨éè±?
add: éè±?μ??·
datAdd: êy?Yμ??·
dat: êy?Yê××??ú????
count: ′?3¤?è
autoStop:=true???ú3é1|?áê?oó2úéúí£?1D?o?
return: 3é1|D′è?×??úêy
*****************************************************/
uint8 I2CWriteBunch(uint8 add,uint8 datAdd,uint8* dat,uint8 count);
/***************************************************
?áò???×??ú′?′óéè±?
′?·?·¨????2?ó?ìá1?êy?Yμ??·μ?éè±??òá?D??áè?
devAdd: éè±?μ??·
dat: êy?Yê××??ú????
count: ′?3¤?è
return: 3é1|?áè?×??úêy
*****************************************************/
uint8 I2CReadStream(uint8 devAdd,uint8* dat,uint8 count);
/***************************************************
?áò???×??ú′?′óéè±?
devAdd: éè±?μ??·
datAdd: êy?Yμ??·
dat: êy?Yê××??ú????
count: ′?3¤?è
return: 3é1|?áè?×??úêy
*****************************************************/
uint8 I2CReadBunch(uint8 devAdd,uint8 datAdd,uint8* dat,uint8 count);
#else//I2C_V2
#ifdef I2C_WRITEBYTE_U
extern bool I2CWriteByte(uint8,uint8); //D′ò???×??úμ????¨éè±? 1:éè±?μ??·2:êy?Y re:true=3é1|
#endif//I2C_WRITEBYTE_U
//D′ò???×??ú′?μ????¨éè±? 1:éè±?μ??· 2:êy?Yê××??ú???? 3£o′?3¤?è autoStop=true:???ú3é1|?áê?oó2úéúí£?1D?o? re£o3é1|D′è?×??úêy
extern uint8 I2CWriteBunch(uint8 add,uint8* dat,uint8 count,bool autoStop);
//extern bool ReadByte(uint8 add,uint8* dat); //?áò???×??ú′óéè±? 1:éè±?μ??·2:êy?Y re:true=3é1|
//?áò???×??ú′?′óéè±?divAdd:éè±?μ??· datAdd:êy?Yê××??úμ??· dat:êy?Yê××??ú???? count£o′?3¤?è re£o3é1|?áè?×??úêy
extern uint8 I2CReadBunch(uint8 devAdd,uint8 datAdd,uint8* dat,uint8 count);
#endif//I2C_V2
#endif//_IIC_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -