REM >>untested<< code for performing measurement and
REM subsequent reading of MEMSIC MMC2120xMG
#picaxe-28x1
SYMBOL Memsic_address = %01100000
SYMBOL MSB_Xchannel = b0
SYMBOL LSB_Xchannel = b1
SYMBOL MSB_Ychannel = b2
SYMBOL LSB_Ychannel = b3
REM Make the device known
HI2Csetup i2cmaster, Memsic_address, i2cfast, i2cbyte
REM Perform continuous measurements
DO
REM Wake-up call and perform measurement (write 1 to command register 0)
HI2Cout %00000000, (%0000001)
REM Wait 5 ms according to datasheet
PAUSE 5
REM Now read the results (registers 1-4 contain the data)
HI2Cin %00000001, (MSB_Xchannel, LSB_Xchannel, MSB_Ychannel, LSB_Ychannel)
LOOP