void HMC5843(void)
{
uint8_t xh, xl, yh, yl, zh, zl;
long xo, yo, zo;
i2cSendStart();
i2cWaitForComplete();
i2cSendByte(0x3C); //write to HMC
i2cWaitForComplete();
i2cSendByte(0x02); //mode register
i2cWaitForComplete();
i2cSendByte(0x00); //continuous measurement mode
i2cWaitForComplete();
i2cSendStop();
//must read all six registers plus one to move the pointer back to 0x03
i2cSendStart();
i2cWaitForComplete();
i2cSendByte(0x3D); //read from HMC
i2cWaitForComplete();
i2cReceiveByte(TRUE);
i2cWaitForComplete();
xh = i2cGetReceivedByte(); //x high byte
i2cWaitForComplete();
//printf(" %d", xh);
i2cReceiveByte(TRUE);
i2cWaitForComplete();
xl = i2cGetReceivedByte(); //x low byte
i2cWaitForComplete();
xo = xl|(xh << 8);
i need to know what is happening in the last line (xo = xl|(xh << 8)
i mean, the operation of the last line
if it shifts 8bits left, then xh will be '0' and 'xo' will be xl
i don't understand!
please help...
{
uint8_t xh, xl, yh, yl, zh, zl;
long xo, yo, zo;
i2cSendStart();
i2cWaitForComplete();
i2cSendByte(0x3C); //write to HMC
i2cWaitForComplete();
i2cSendByte(0x02); //mode register
i2cWaitForComplete();
i2cSendByte(0x00); //continuous measurement mode
i2cWaitForComplete();
i2cSendStop();
//must read all six registers plus one to move the pointer back to 0x03
i2cSendStart();
i2cWaitForComplete();
i2cSendByte(0x3D); //read from HMC
i2cWaitForComplete();
i2cReceiveByte(TRUE);
i2cWaitForComplete();
xh = i2cGetReceivedByte(); //x high byte
i2cWaitForComplete();
//printf(" %d", xh);
i2cReceiveByte(TRUE);
i2cWaitForComplete();
xl = i2cGetReceivedByte(); //x low byte
i2cWaitForComplete();
xo = xl|(xh << 8);
i need to know what is happening in the last line (xo = xl|(xh << 8)
i mean, the operation of the last line
if it shifts 8bits left, then xh will be '0' and 'xo' will be xl
i don't understand!
please help...