- UID
- 164800
- 性别
- 女
|
用ZLG7290做了一个8x8的板子,现在要在华恒——EDU的的板子上驱动起来,
读写函数不正确,那位高手能看看是什么毛病不? static ssize_t zlg_rd(struct file *filep,char * buffer,size_t length,loff_t * off) { int ret = 0,i; U8 rdata;
dbuf = kmalloc(5*sizeof(char) , GFP_KERNEL);
Init_Iic();
/*SYSAvi*/ _Rd2410Iic(ZLG_SLAVE_ADDR,REG_Sys,&(rdata)); dbuf[0] = rdata;
/*Key_value*/ _Rd2410Iic(ZLG_SLAVE_ADDR,REG_Key,&(rdata)); dbuf[1] = rdata;
/*Repeat*/ _Rd2410Iic(ZLG_SLAVE_ADDR,REG_Cnt,&(rdata)); dbuf[2] = rdata;
/*Function*/ _Rd2410Iic(ZLG_SLAVE_ADDR,REG_Func,&(rdata)); dbuf[3] = rdata; /*Fastpresscound*/ _Rd2410Iic(ZLG_SLAVE_ADDR,REG_Fprc,&(rdata)); dbuf[4] = rdata; copy_to_user(buffer,dbuf,5); kfree(dbuf); return ret; }
static ssize_t zlg_wr(struct file *filep,char * buffer,size_t length,loff_t * off) { U8 data; int ic , ret = 0; unsigned int reg, mreg, lreg; dbuf = kmalloc(length*sizeof(char),GFP_KERNEL);
copy_from_user(dbuf,buffer,length); Init_Iic();
for(ic = 0;ic < length; ic+=2) { //mreg = dbuf[ic]; //lreg = dbuf[ic+1]; //reg = mreg<<8|lreg; reg = dbuf[ic]; data = dbuf[ic+1]; _Wr2410Iic(ZLG_SLAVE_ADDR,reg,data); } kfree(dbuf); return ret; }
|
|