I got a
HMC6343 Compass hooked up to my
Axon, using I2C. Here is some code I'd like to share . . . don't forget to include the I2C AVRlib library.

//Read HMC6343 compass I2C data:
u08 TARGET_ADDR = 0x32; //0x32 = HMC6343 compass slave write address
u08 command = 0x50; //0x50 = post heading data, pitch data, and roll data
u08 in[6]; //6 bytes = MSB heading, LSB heading, MSB pitch, LSB pitch, MSB roll, LSB roll
i2cMasterSend(TARGET_ADDR, 1, &command); //send 1 byte command to slave from master
delay_ms(10);
i2cMasterReceive(TARGET_ADDR, 6, &in[0]); //read 6 byte data from slave to master
//process heading data:
compass = in[0]; //first byte is MSB heading
compass = compass << 8; //shift MSB byte to top of int
compass = compass + in[1]; //add LSB byte (2nd byte) to bottom of int
compass = compass; // / 10;
//process pitch data:
pitchCompass = in[2]; //3rd byte is MSB pitch
pitchCompass = pitchCompass << 8;
pitchCompass = pitchCompass + in[3]; //4th byte is LSB pitch
pitchCompass = pitchCompass / 10;
if(pitchCompass > 6400)
pitchCompass = (pitchCompass - 6400 - 155); //convert to negative values
//process roll data:
rollCompass = in[4]; //5th byte is MSB roll
rollCompass = rollCompass << 8;
rollCompass = rollCompass + in[5]; //6th byte is LSB roll
rollCompass = rollCompass / 10;
if(rollCompass > 6400)
rollCompass = (rollCompass - 6400 - 155); //convert to negative values
Output of course is pitchCompass and rollCompass.
Also a comment on this compass . . . I'm using it on my robot fish. The fish uses a waterproof magnet switch . . . the magnet is weak, and 2-3 inches away from the compass, but still affects results by about +/- 13% (absolute value 27%). Hopefully that info helps someone!
edit: changed the % error, due to my own error
