Example #1
0
void hmc5883l_SetMeasurementMode(int mode) {
    u08 b;
    b = i2c_RcvByte(I2C_ID_HMC5883L, HMC5883L_CONFIG_A);
    b &= 0x7c; // "01111100" clear CRA7, keep existing averaging and datarate settings, clear measuremode bits
    b |= ((u08)mode);
    //b = (u08)mode;
    i2c_XmtByte(I2C_ID_HMC5883L, HMC5883L_CONFIG_A,b);
    }
Example #2
0
void hmc5883l_Config(void) {

/*
	  magn.init(false); // Don't set mode yet, we'll do that later on.
	  // Calibrate HMC using self test, not recommended to change the gain after calibration.
	  magn.calibrate(1); // Use gain 1=default, valid 0-7, 7 not recommended.
	  // Single mode conversion was used in calibration, now set continuous mode
	  hmc5883l_SetOperatingMode(HMC5883L_MEAS_CONTINUOUS);
	  DELAY_MS(10);
	  magn.setDOR(B110);
*/

    u08 b;
    hmc5883l_SetGain(HMC5883L_SCALE_13);
    b = 0x78; // "01111000" clear CRA7, 8 sample average, 75Hz data rate, normal measurement flow
    i2c_XmtByte(I2C_ID_HMC5883L, HMC5883L_CONFIG_A,b);
    hmc5883l_SetOperatingMode(HMC5883L_MEAS_CONTINUOUS);
    }
void SetupL3G4200D()
{
	i2c_XmtByte(L3G4200D_I2C_ID, L3G4200D_CTRL_REG1, 0x3e); // "00011111"- Data rate 100Hz, BW 25Hz, power up, enable all axes
	i2c_XmtByte(L3G4200D_I2C_ID, L3G4200D_CTRL_REG4, 0x90); // "10010000"  500dps, disable selftest
}
Example #4
0
void hmc5883l_SetGain(int gain) {
    u08 b;
    gHMC5883L.gainIndex = gain;
    b = (((uint8_t)gain)<<5);
    i2c_XmtByte(I2C_ID_HMC5883L, HMC5883L_CONFIG_B,b);
    }
Example #5
0
void hmc5883l_SetOperatingMode(int mode) {
    u08 b;
    b = (u08)mode;
    i2c_XmtByte(I2C_ID_HMC5883L, HMC5883L_MODE,b);
    }