⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i2c.h

📁 ARM7的I2C读写
💻 H
字号:
#ifndef _I2C_POLL_H
#define _I2C_POLL_H

#include "configLPC.h"

//
//  Does not define slave RX statuses.  Bus errors (I2C_STAT == 0) is remapped
//  to I2CERR_ERROR in i2cStatus() so that we can use a value of 0 to indicate 
//  no error.
//
typedef enum
{
	I2CERR_NONE = 0,
	I2CERR_BUSY,
	I2CERR_EMPTY,
	I2CERR_TIMEOUT,
	I2CERR_TIMEOUTWC,
	I2CERR_TIMEOUTACKPOLL,
	I2CERR_NOTIMPLEMENTED,
	I2CERR_OTHER,
	I2CERR_BUSERROR,
	I2CERR_BUSERRORx       = 0x00,
	I2CERR_STARTTX         = 0x08,
	I2CERR_REPEATEDSTARTTX = 0x10,
	I2CERR_SLAWTX_ACKRX    = 0x18,
	I2CERR_SLAWTX_NACKRX   = 0x20,
	I2CERR_DATTX_ACKRX     = 0x28,
	I2CERR_DATTX_NACKRX    = 0x30,
	I2CERR_ARBLOST         = 0x38,
	I2CERR_SLARTX_ACKRX    = 0x40,
	I2CERR_SLARTX_NACKRX   = 0x48,
	I2CERR_DATRX_ACKTX     = 0x50,
	I2CERR_DATRX_NACKTX    = 0x58,
	I2CERR_NOINFO          = 0xf8
}
i2cErr_e;

//
//
//
extern i2cErr_e i2cErrno;

//
//
//
void i2cInit (void);
int32 i2cGetErrno (void);
const char *i2cStrerror (int32 err);
void i2cSetTimeout (uint32 timeoutInMilliseconds);
void i2cDump (void);
int32 i2cWriteBuffer (uint8 address, uint8 *buffer, uint32 bufferLength);
int32 i2cReadBuffer (uint8 address, uint8 *buffer, uint32 bufferLength);
int32 i2cWriteReadBuffer (uint8 address, uint8 *buffer, uint32 putLength, uint32 getLength);
int32 i2cWriteBufferPoll (uint8 address, uint8 *buffer, uint32 bufferLength);
int32 i2cWriteReadBufferPoll (uint8 address, uint8 *buffer, uint32 putLength, uint32 getLength);
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -