8c2952457
김태훈
응용 프로그램 추가
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
//------------------------------------------------------------------------------
// 프로젝트 : 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 <linux/i2c.h>
#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_
|