i2c驱动

i2c几个结构体(/linux/i2c.h)
i2c_adapter结构体
struct i2c_adapter { 
struct module * owner; /* 所属模块*/  
unsigned int id;     /*algorithm 的类型,定义于i2c-id.h,以I2C_ALGO_ 开始*/  
unsigned int class; 
struct i2c_algorithm * algo;/* 总线通信方法结构体指针*/  
void * algo_ data;/*   algorithm 数据 */  
int (* client_register)(struct i2c_client * );  /* client 注册时调用*/  
int (* client_unregister)(struct i2c_client * ); /* client 注销时调用*/  
u8 level; 
struct semaphore bus_lock;    /* 控制并发访问的自旋锁*/  
struct semaphore clist_lock; 
int timeout; 
int retries;    /* 重试次数*/  
struct device dev;/*  适配器设备 */  
struct class_device class_dev;/*  类设备 */  
int nr; 
struct list_head clien;   /*   client 链表头*/  
struct list_head list; 
char name[48];  /* 适配器名称*/  
struct completion  dev_released;    /* 用于同步*/  
;
i2c _ algorithm结构体
struct i2c_algorithm {  
   int (* master_xfer)(struct i2c_adapter  * adap,struct i2c_msg * msgs,  
                       int num);  /* i2c 传输函数指针*/  
   int (* smbus_xfer) (struct i2c_adapter  * adap, u1 6 addr,  /* smbus传输函数指针*/  
                        unsigned short flags, char read _ write,  
                        u8 command, int size, union i2c_smbus_ data *   data);  
   u32 ( *functionality) (struct i2c_adapter *);/*返回适配器支持的功能*/ 
 };
i2c_driver结构体
struct i2c_driver {  
  int id; 
  unsigned int class; 
  int (* attach_adapter)(struct i2c_adapter  * ); /* 依附i2c _ adapter函数指针 */  
  int (* detach_adapter)(struct i2c_adapter  * ); /* 脱离i2c _ adapter函数指针*/  
  int (* detach_client)(struct i2c_client * );   /* i2c client脱离函数指针*/  
  int ( *probe)(struct i2c_client *, const struct i2c_device_id  *); 
  int (* remove)(struct i2c_client * ); 
  void ( * shutdown)(struct i2c_client   * ); 
  int (* suspend)(struct i2c_client * , pm_ message_ t mesg);     
  int (* resume)(struct i2c_client * ); 
  int (* command)(struct i2c_client * client, unsigned int cmd, void  * arg); 
  struct device _ driver driver; 
  const struct i2c _ device_id  * id_table;  /*该驱动所支持的设备ID表 */  
  int (* detect)(struct i2c_client * , int kind, struct i2c_board_info * ); 
  const struct i2c _client _ address_data * address_data; 
  struct list_head clients;  
}; 
i2c_client结构体
struct i2c_client {  
  unsigned int flags ; /*  标志 */  
  unsigned short addr;   /*  低7 位为芯片地址 */  
  char name[I2C_NAME_SIZE]; /*  设备名称 */  
  struct i2c_adapter  * adapter;/* 依附的i2c _ adapter*/  
  struct i2c_driver * driver;   /* 依附的i2c _ driver */  
  struct device dev;   /*  设备结构体*/  
  int irq;   /*  设备使用的中断号*/  
  struct list_head list;       /*  链表头 */  
  struct completion released;    /*  用于同步 */  
};










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值