是用avr通过I2C写的, (1)I2CWrite(Addr >> 8)中的Addr >> 8是什么意思?为什么要右移8位? (2)I2CWrite(Addr & 0xFF) 是什么意思? 请教高手们!
BYTE I2CSendAddr(UINT16 Addr) { I2CStart(); I2CWait(); if (I2CState() == TWI_SEND_START || I2CState() == TWI_SEND_RESTART) { I2CWrite(I2C_ADDR_BASE); I2CWait(); if (I2CState() == TWI_SEND_ADDR_ACK) { #ifdef SUPPORT_I2C_24C256 I2CWrite(Addr >> 8);//? I2CWait(); if (I2CState() == TWI_SEND_DATA_ACK) #endif { I2CWrite(Addr & 0xFF); I2CWait(); if (I2CState() == TWI_SEND_DATA_ACK) { return TRUE; } #ifdef DEBUG_WITH_PC else { ShowDebugCMM(_c_IE); ShowDebugDec(4); } #endif } #ifdef DEBUG_WITH_PC else { ShowDebugCMM(_c_IE); ShowDebugDec(3); } #endif } #ifdef DEBUG_WITH_PC else { ShowDebugCMM(_c_IE); ShowDebugDec(2); } #endif } #ifdef DEBUG_WITH_PC else { ShowDebugCMM(_c_IE); ShowDebugDec(1); } #endif
return FALSE; } |