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

📄 i2c.h

📁 我写的针对lpc2141的ucos源码
💻 H
字号:
#ifndef __I2C_H__
#define __I2C_H__

#include <LPC214X.H>
#include "type.h"

#define MAX_TIMEOUT		0x00ffffff

#define I2CMASTER		0x01
#define I2CSLAVE		0x02

#define I2C_IDLE		0
#define I2C_STARTED		1
#define I2C_RESTARTED		2
#define I2C_REPEATED_START	3
#define I2C_DATA_ACK		4
#define I2C_DATA_NACK		5

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

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

#define I2C0SCLH_SCLH	0xff	
#define I2C0SCLL_SCLL	0xff

typedef struct i2c_wr_unit {
	uint8 device_addr; //LSB is W/R flag
	uint8 length;
	uint8 *buffer;
	uint8 counter;
	//struct i2c_wr_unit *next;
	//uint8 i2c_state;
}I2C_WR_UNIT;

extern uint8 state_flag;

extern void i2c0_irq_handler( void ) __irq;
extern uint8 i2c0_init(uint8 );
extern uint8 i2c0_start(void);
extern uint8 i2c0_stop(void);
extern uint8 i2c0_operation(I2C_WR_UNIT *, uint8);

extern void i2c1_irq_handler( void ) __irq;


#endif
	

⌨️ 快捷键说明

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