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

📄 i2c.h

📁 LPC2102的keil vendor code
💻 H
字号:
/*****************************************************************************
 *   i2c.h:  Header file for NXP LPC210x Family Microprocessors
 *
 *   Copyright(C) 2006, NXP Semiconductors
 *   All rights reserved.
 *
 *   History
 *   2005.10.01  ver 1.00    Prelimnary version, first Release
 *
******************************************************************************/
#ifndef __I2C_H 
#define __I2C_H

/* I2C Address */
#define I2CSL_ADDRS  	(0x17)

#define BUFSIZE			(0x21)
#define MAX_TIMEOUT		(0x00FFFFFF)

#define I2CMASTER		(0x01)
#define I2CSLAVE		(0x02)

/**** Status Errors ****/
#define I2C_OK                  0        /* transfer ended No Errors       */
#define I2C_BUSY                1        /* transfer busy                  */
#define I2C_ERROR               2        /* err: general error             */
#define I2C_NO_DATA             3        /* err: No data in block          */
#define I2C_DATA_NACK           4        /* err: No ack on data            */
#define I2C_ADDRESS_NACK        5        /* err: No ack on address         */
#define I2C_DEVICE_NOT_PRESENT  6        /* err: Device not present        */
#define I2C_ARBITRATION_LOST    7        /* err: Arbitration lost          */
#define I2C_TIME_OUT            8        /* err: Time out occurred         */
#define I2C_SLAVE_ERROR         9        /* err: slave mode error          */
#define I2C_INIT_ERROR          10       /* err: Initialization (not done) */

#define I2C_IDLE				0
#define I2C_STARTED				1
#define I2C_RESTARTED			2
#define I2C_REPEATED_START		3
#define DATA_ACK				4
#define DATA_NACK				5

#define I2CONSET_AA			0x00000004	/* I2C Control Set Register */
#define I2CONSET_SI			0x00000008
#define I2CONSET_STO		0x00000010
#define I2CONSET_STA		0x00000020
#define I2CONSET_I2EN		0x00000040  

#define I2CONCLR_AAC		0x00000004  /* I2C Control clear Register */
#define I2CONCLR_SIC		0x00000008
#define I2CONCLR_STAC		0x00000020
#define I2CONCLR_I2ENC		0x00000040

#define I2DAT_I2C			0x00000000  /* I2C Data Reg */
#define I2ADR_I2C			0x00000000  /* I2C Slave Address Reg */
#define I2SCLH_SCLH			0x00000080  /* I2C SCL Duty Cycle High Reg */
#define I2SCLL_SCLL			0x00000080  /* I2C SCL Duty Cycle Low Reg */

#ifdef LPC2102_I2C1_MASTER
	#define SLV_ADDRESS  	(0x18)
	#define WR_BIT			(0x00)
	#define RD_BIT			(0x01)

	#define I2C_READ		(0x01)
	#define I2C_WRITE		(0x02)
	#define I2C_READ_WRITE	(0x03)
	#define I2C_WRITE_READ  (0x04)
#endif

extern unsigned char ApplnHandler_Flag;
extern unsigned char i2c_send_flag;
extern unsigned char gInterrupt_Status;

extern void SPI_Send( unsigned char *Buf, unsigned long Length );

void I2C0_SlaveHandler(void) __irq;
unsigned long I2C0_Init(unsigned long I2cMode);
unsigned char i2c_slave_islasttxbyte(unsigned char bytenum);
//unsigned char i2c_slave_islastrxbyte(unsigned char bytenum);
void i2c_transfer_finished(void);
void i2c_receive_finished(void);

#ifdef LPC2102_I2C1_MASTER
	void I2C1_Master_Demo(void);
	unsigned long I2C1_Init(unsigned long I2cMode);
	unsigned long I2C1_DeInit(void); 
	void I2C1_MasterHandler (void) __irq;
	unsigned long I2CStart(void);
	unsigned long I2CStop(void);
	unsigned long I2CEngine(void); 
#endif

#endif /* end __I2C_H */
/****************************************************************************
                              End Of File
*****************************************************************************/

⌨️ 快捷键说明

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