コード例 #1
0
ファイル: gyro.cpp プロジェクト: brewpoo/bradwii
void init_gyro() {
    lib_i2c_writereg(MPU6050_ADDRESS, 0x6B, 0x80);             //PWR_MGMT_1    -- DEVICE_RESET 1
    lib_timers_delaymilliseconds(5);
    lib_i2c_writereg(MPU6050_ADDRESS, 0x6B, 0x03);             //PWR_MGMT_1    -- SLEEP 0; CYCLE 0; TEMP_DIS 0; CLKSEL 3 (PLL with Z Gyro reference)
    lib_i2c_writereg(MPU6050_ADDRESS, 0x1A, MPU6050_DLPF_CFG); //CONFIG        -- EXT_SYNC_SET 0 (disable input pin for data sync) ; default DLPF_CFG = 0 => ACC bandwidth = 260Hz  GYRO bandwidth = 256Hz)
    lib_i2c_writereg(MPU6050_ADDRESS, 0x1B, 0x18);             //GYRO_CONFIG   -- FS_SEL = 3: Full scale set to 2000 deg/sec
}
コード例 #2
0
ファイル: gyro.c プロジェクト: TheSmartGerman/bradwii-X4
void initgyro(void)
{
    lib_i2c_writereg(MPU3050_ADDRESS, 0x3E, 0x80);  //PWR_MGMT_1 -- DEVICE_RESET 1
    lib_timers_delaymilliseconds(5);
    lib_i2c_writereg(MPU3050_ADDRESS, 0x3E, 0x03); //PWR_MGMT_1 -- SLEEP 0; CYCLE 0; TEMP_DIS 0; CLKSEL 3 (PLL with Z Gyro reference)
    lib_i2c_writereg(MPU3050_ADDRESS, 0x16, MPU3050_DLPF_CFG + 0x18); // Gyro CONFIG -- EXT_SYNC_SET 0 (disable input pin for data sync) ; default DLPF_CFG = 0 => GYRO bandwidth = 256Hz); -- FS_SEL = 3: Full scale set to 2000 deg/sec
    lib_i2c_writereg(MPU3050_ADDRESS, 0x15, SAMPLE_RATE_DIVISOR);
}
コード例 #3
0
ファイル: gyro.cpp プロジェクト: brewpoo/bradwii
void init_gyro() {
    lib_timers_delaymilliseconds(100);
    lib_i2c_writereg(ITG3200_ADDRESS, 0x3E, 0x80); //register: Power Management  --  value: reset device
    lib_timers_delaymilliseconds(5);
    lib_i2c_writereg(ITG3200_ADDRESS, 0x16, 0x18 + ITG3200_DLPF_CFG); //register: DLPF_CFG - low pass filter configuration
    lib_timers_delaymilliseconds(5);
    lib_i2c_writereg(ITG3200_ADDRESS, 0x3E, 0x03); //register: Power Management  --  value: PLL with Z Gyro reference
    lib_timers_delaymilliseconds(100);
}
コード例 #4
0
ファイル: gyro.c プロジェクト: TheSmartGerman/bradwii-X4
void initgyro(void)
{
    // Resetting the MPU6050 does not work for some reason.
    // But it is already in default mode at power up, so there is no need to reset it anyways

    //lib_i2c_writereg(MPU6050_ADDRESS, 0x6B, 0x80);      //PWR_MGMT_1    -- DEVICE_RESET 1
    //lib_timers_delaymilliseconds(10);
    lib_i2c_writereg(MPU6050_ADDRESS, 0x6B, 0x03);      //PWR_MGMT_1    -- SLEEP 0; CYCLE 0; TEMP_DIS 0; CLKSEL 3 (PLL with Z Gyro reference)
    lib_i2c_writereg(MPU6050_ADDRESS, 0x1A, MPU6050_DLPF_CFG);  //CONFIG        -- EXT_SYNC_SET 0 (disable input pin for data sync) ; default DLPF_CFG = 0 => ACC bandwidth = 260Hz  GYRO bandwidth = 256Hz)
    lib_i2c_writereg(MPU6050_ADDRESS, 0x1B, 0x18);      //GYRO_CONFIG   -- FS_SEL = 3: Full scale set to 2000 deg/sec
}
コード例 #5
0
ファイル: accelerometer.c プロジェクト: woogluf/bradwii
void initacc(void)
{
    lib_timers_delaymilliseconds(10);
    // Mode register: standby mode
    lib_i2c_writereg( MC3210_ADDRESS, 0x07, 0x03);
    // INTEN register: disable interrupts
    lib_i2c_writereg( MC3210_ADDRESS, 0x06, 0x00);
    // OUTCFG register:
    // Select +/- 8g range, 14-bit resolution
    // Low-pass filter set to 64 Hz bandwidth
    // (GINT interrupt updates at LPF bandwidth setting)
    lib_i2c_writereg( MC3210_ADDRESS, 0x20, 0x8F + ACC_LOW_PASS_FILTER);
    // Mode register: wake mode
    lib_i2c_writereg( MC3210_ADDRESS, 0x07, 0x01);
}
コード例 #6
0
ファイル: accelerometer.cpp プロジェクト: BeemoLin/bradwii
void initacc() 
   {
      lib_timers_delaymilliseconds(10);
   //default range 2G: 1G = 4096 unit.
   lib_i2c_writereg(BMA180_ADDRESS,0x0D,1<<4); // register: ctrl_reg0  -- value: set bit ee_w to 1 to enable writing
      lib_timers_delaymilliseconds(5);
   unsigned char control = lib_i2c_readreg(BMA180_ADDRESS, 0x20);
   control = control & 0x0F;        // save tcs register
   control = control | (0x01 << 4); // register: bw_tcs reg: bits 4-7 to set bw -- value: set low pass filter to 20Hz
   lib_i2c_writereg(BMA180_ADDRESS, 0x20, control);
      lib_timers_delaymilliseconds(5);
   control = lib_i2c_readreg(BMA180_ADDRESS, 0x30);
   control = control & 0xFC;        // save tco_z register
   control = control | 0x00;        // set mode_config to 0
   lib_i2c_writereg(BMA180_ADDRESS, 0x30, control);
      lib_timers_delaymilliseconds(5); 
   control = lib_i2c_readreg(BMA180_ADDRESS, 0x35);
   control = control & 0xF1;        // save offset_x and smp_skip register
   control = control | (0x05 << 1); // set range to 8G
   lib_i2c_writereg(BMA180_ADDRESS, 0x35, control);
      lib_timers_delaymilliseconds(5); 
   }
コード例 #7
0
ファイル: accelerometer.cpp プロジェクト: BeemoLin/bradwii
void initacc() 
   {
   lib_i2c_writereg(MPU6050_ADDRESS, 0x1C, 0x10);             //ACCEL_CONFIG  -- AFS_SEL=2 (Full Scale = +/-8G)  ; ACCELL_HPF=0   //note something is wrong in the spec.
   }