//------------------------------------------------------------------------------ // 프로젝트 : ETRI I2C AGENT // 파 일 : i2c_api.h // 설 명 : I2C DEVICE DRIVE API INCLUDE // // 작 성 : 유영창 frog@falinux.com //------------------------------------------------------------------------------ #ifndef _I2C_API_LIB_H_ #define _I2C_API_LIB_H_ // #include #define I2C_RETRIES 0x0701 /* number of times a device address */ /* should be polled when not */ /* acknowledging */ #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ /* this is for i2c-dev.c */ #define I2C_SLAVE 0x0703 /* Change slave address */ /* Attn.: Slave address is 7 or 10 bits */ #define I2C_SLAVE_FORCE 0x0706 /* Change slave address */ /* Attn.: Slave address is 7 or 10 bits */ /* This changes the address, even if it */ /* is already taken! */ #define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ #define I2C_FUNCS 0x0705 /* Get the adapter functionality */ #define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/ #define I2C_PEC 0x0708 /* != 0 for SMBus PEC */ #define I2C_SMBUS 0x0720 /* SMBus-level access */ /* ... algo-bit.c recognizes */ #define I2C_UDELAY 0x0705 /* set delay in microsecs between each */ /* written byte (except address) */ #define I2C_MDELAY 0x0706 /* millisec delay between written bytes */ #define __u32 unsigned long #define I2C_NO_ERROR 0000 // 에러가 없다. #define I2C_UNKONW_COMMAND 7001 // 알수 없는 프로토콜 명령이다. #define I2C_NOT_FIND_MAJOR 7002 // I2C 디바이스 드라이버 주번호 획득 실패 #define I2C_NOT_FIND_BUS 7003 // I2C 버스를 발견할수 없다. #define I2C_NOT_FIND_DEVICE 7004 // I2C 디바이스를 발견할수 없다. #define I2C_READ_DEVICE 7005 // 읽기 실패 #define I2C_WRITE_DEVICE 7006 // 쓰기 실패 typedef struct { int fd; char node_fname[128]; } i2c_bus_t; struct i2c_rdwr_ioctl_data { struct i2c_msg *msgs; /* pointers to i2c_msgs */ __u32 nmsgs; /* number of i2c_msgs */ }; typedef struct { int bus; unsigned int addr; int size; unsigned char data[512]; } __attribute__ ((packed)) access_data_t; extern int i2c_init ( void ); extern int i2c_get_bus_count ( void ); extern int i2c_read_data( access_data_t* access_data ); extern int i2c_write_data( access_data_t* access_data ); #endif // _I2C_API_LIB_H_