iicSt = R_IICSTAT;
if(iicSt & 0x8){
PDEBUG("bus arbitration is failed\n");
} //When bus arbitration is failed.
if(iicSt & 0x4){
PDEBUG("matched\n");
} //When a slave address is matched with IICADD
if(iicSt & 0x2){
PDEBUG("slave address 0000000b\n");
} //When a slave address is 0000000b
if(iicSt & 0x1){
PDEBUG("Ack isn't received\n");
} //When ACK isn't received
switch(_iicMode)
{
case POLLACK:
PDEBUG("poll--ACK\n");
_iicStatus = iicSt;
break;
case RDDATA:
PDEBUG("read--ACK\n");
if((_iicDataCount--)==0)
{
_iicData[_iicPt++] = R_IICDS;
R_IICSTAT = 0x90; //Stop MasRx condition
R_IICCON = 0xaf; //Resumes IIC operation.
Delay(1); //Wait until stop condtion is in effect.
//Too long time...
//The pending bit will not be set after issuing stop condition.
break;
}
_iicData[_iicPt++] = R_IICDS;
//The last data has to be read with no ack.
if((_iicDataCount)==0)
R_IICCON = 0x2f; //Resumes IIC operation with NOACK.
else
R_IICCON = 0xaf; //Resumes IIC operation with ACK
break;
case SETRDADDR:
PDEBUG("SETRDADDR\n");
if((_iicDataCount--)==0)
{
break; //IIC operation is stopped because of IICCON[4]
}
R_IICDS = _iicData[_iicPt++];
for(i=0;i<10;i++); //for setup time until rising edge of IICSCL
R_IICCON = 0xaf; //resumes IIC operation.
break;
接上:
static int __init IIC_init(void)
{
// 1. 分配主设备号
dev_t devno = MKDEV( major, minor );
int ret = register_chrdev_region( devno, 1, DEVICE );
if( ret < 0 )
{
printk(KERN_DEBUG "register major number failed with %d\n", ret);
return ret;
}
printk(KERN_DEBUG "%s:register major number OK\n",DEVICE);
make -C /qt2440/qt2440-kernel/ M=/mnt/hgfs/share/1 modules
make[1]: Entering directory `/qt2440/qt2440-kernel'
CC [M] /mnt/hgfs/share/1/iic_zlg7290.o
/mnt/hgfs/share/1/iic_zlg7290.c: In function `_Rd2410Iic':
/mnt/hgfs/share/1/iic_zlg7290.c:153: warning: implicit declaration of function `PDEBUG'
/mnt/hgfs/share/1/iic_zlg7290.c:159: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:160: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:170: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:171: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:172: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c: In function `Run_IicPoll':
/mnt/hgfs/share/1/iic_zlg7290.c:183: error: invalid operands to binary &
/mnt/hgfs/share/1/iic_zlg7290.c: In function `IicPoll':
/mnt/hgfs/share/1/iic_zlg7290.c:192: warning: assignment makes integer from pointer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:217: warning: assignment makes integer from pointer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:219: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:220: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:226: warning: assignment makes integer from pointer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:229: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:231: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:240: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:242: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c: In function `Getkey_zlg7290':
/mnt/hgfs/share/1/iic_zlg7290.c:254: error: void value not ignored as it ought to be
/mnt/hgfs/share/1/iic_zlg7290.c:252: warning: unused variable `repeatcount'
/mnt/hgfs/share/1/iic_zlg7290.c: In function `IIC_init':
/mnt/hgfs/share/1/iic_zlg7290.c:296: warning: ISO C90 forbids mixed declarations and code
/mnt/hgfs/share/1/iic_zlg7290.c:318: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c:319: warning: assignment makes pointer from integer without a cast
/mnt/hgfs/share/1/iic_zlg7290.c: In function `IIC_open':
/mnt/hgfs/share/1/iic_zlg7290.c:347: warning: ISO C90 forbids mixed declarations and code
/mnt/hgfs/share/1/iic_zlg7290.c: In function `Iic_do_work':
/mnt/hgfs/share/1/iic_zlg7290.c:417: error: parameter name omitted
make[2]: *** [/mnt/hgfs/share/1/iic_zlg7290.o] Error 1
make[1]: *** [_module_/mnt/hgfs/share/1] Error 2
make[1]: Leaving directory `/qt2440/qt2440-kernel'
make: *** [all] Error 2