[driver] Attempt to read the ms5611 as a slave behind the MPU6000 --- preliminary

This commit is contained in:
Christophe De Wagter
2012-06-20 23:14:04 +02:00
parent e3dd56fb73
commit fb951e82b1
2 changed files with 77 additions and 10 deletions
+8 -8
View File
@@ -32,8 +32,8 @@
*
* Note: Aspirin 2.1 has CSB bound to GND.
*/
#define MS5611_ADDR0 0x76
#define MS5611_ADDR1 0x77
#define MS5611_ADDR0 0x77
#define MS5611_ADDR1 0x76
/* General Registers */
#define MS5611_REG_ADCREAD 0x00 // Read converted value
@@ -47,8 +47,8 @@
#define MS5611_OSR4096 0x08
/* D1 Register defines */
#define MS5611_REG_D1 0x40 // Request D1 (pressure) conversion
#define MS5611_REG_D1(_osr) (MS5611_REG_D1 | _osr)
#define MS5611_REG_D1R 0x40 // Request D1 (pressure) conversion
#define MS5611_REG_D1(_osr) (MS5611_REG_D1R | _osr)
#define MS5611_REG_D1OSR256 MS5611_REG_D1(MS5611_ORS256)
#define MS5611_REG_D1OSR512 MS5611_REG_D1(MS5611_OSR512)
#define MS5611_REG_D1OSR1024 MS5611_REG_D1(MS5611_OSR1024)
@@ -56,8 +56,8 @@
#define MS5611_REG_D1OSR4096 MS5611_REG_D1(MS5611_OSR4096)
/* D2 register defines */
#define MS5611_REG_D2 0x40 // Request D2 (temperature) conversion
#define MS5611_REG_D2(_osr) (MS5611_REG_D2 | _osr)
#define MS5611_REG_D2R 0x50 // Request D2 (temperature) conversion
#define MS5611_REG_D2(_osr) (MS5611_REG_D2R | _osr)
#define MS5611_REG_D2OSR256 MS5611_REG_D2(MS5611_ORS256)
#define MS5611_REG_D2OSR512 MS5611_REG_D2(MS5611_OSR512)
#define MS5611_REG_D2OSR1024 MS5611_REG_D2(MS5611_OSR1024)
@@ -75,8 +75,8 @@
#define MS5611_PROM_ADDR7 0x0E // CRC-4 (Chkecksum of the PROM content)
/* PROM register defines */
#define MS5611_REG_PROM 0xA0
#define MS5611_REG_PROM(_addr) (MS5611_REG_PROM | _addr)
#define MS5611_REG_PROMR 0xA0
#define MS5611_REG_PROM(_addr) (MS5611_REG_PROMR | _addr)
#define MS5611_REG_C1 MS5611_REG_PROM(ADDR1)
#define MS5611_REG_C2 MS5611_REG_PROM(ADDR2)
#define MS5611_REG_C3 MS5611_REG_PROM(ADDR3)
+69 -2
View File
@@ -27,6 +27,7 @@
// Peripherials
#include "peripherals/mpu60X0.h"
#include "peripherals/hmc58xx.h"
#include "peripherals/ms5611.h"
struct ImuAspirin2 imu_aspirin2;
@@ -181,6 +182,26 @@ static void mpu_configure(void)
(0 << 4) | // restart or stop/start from one slave to another: read -> write is always stop/start
(8 << 0) ); // 0=348kHz 8=256kHz, 9=500kHz
mpu_set( MPU60X0_REG_I2C_MST_DELAY,
(0 << 2) | // No Delay Slave 2
(1 << 3) ); // Delay Slave 3
#ifdef IMU_ASPIRIN_VERSION_2_1
// MS5611 Send Reset
mpu_set( MPU60X0_REG_I2C_SLV4_ADDR, (MS5611_ADDR0));
mpu_set( MPU60X0_REG_I2C_SLV4_DO, MS5611_REG_RESET);
mpu_set( MPU60X0_REG_I2C_SLV4_CTRL,
(1 << 7) | // Slave 4 enable
(0 << 6) | // Byte Swap
(1 << 5) | // Reg_Dis: do not write the register, just the data
(0 << 0) ); // Full Speed
mpu_wait_slave4_ready();
// Wait at least 2.8ms
#endif
// HMC5883 Magnetometer Configuration
@@ -210,8 +231,7 @@ static void mpu_configure(void)
mpu_set( MPU60X0_REG_I2C_SLV4_CTRL,
(1 << 7) | // Slave 4 enable
(0 << 6) | // Byte Swap
(0 << 0) ); // Full Speed
(3 << 0) ); // From now on a delayed rate of 1/4 is defined...
// HMC5883 Reading:
// a) write hmc-register to HMC
@@ -227,6 +247,53 @@ static void mpu_configure(void)
// Slave 0 Control:
#ifdef IMU_ASPIRIN_VERSION_2_1
#pragma note "Reading the MS5611"
/*
// Read MS5611 Calibration
mpu_set( MPU60X0_REG_I2C_SLV1_ADDR, (MS5611_ADDR0) | MPU60X0_SPI_READ);
mpu_set( MPU60X0_REG_I2C_SLV1_REG, MS5611_REG_ADCREAD);
// Put the enable command as last.
mpu_set( MPU60X0_REG_I2C_SLV1_CTRL,
(1 << 7) | // Slave 1 enable
(0 << 6) | // Byte Swap
(3 << 0) ); // Read 6 bytes
*/
// Full Rate Request For Pressure
mpu_set( MPU60X0_REG_I2C_SLV2_ADDR, (MS5611_ADDR0));
mpu_set( MPU60X0_REG_I2C_SLV2_DO, 0x48);
// Put the enable command as last.
mpu_set( MPU60X0_REG_I2C_SLV2_CTRL,
(1 << 7) | // Slave 2 enable
(0 << 6) | // Byte Swap
(1 << 5) | // Rig Dis: Write Only
(1 << 0) ); // Write 1 byte
// Reduced rate request For Temperature: Overwrites the Pressure Request
mpu_set( MPU60X0_REG_I2C_SLV3_ADDR, (MS5611_ADDR0));
mpu_set( MPU60X0_REG_I2C_SLV3_DO, 0x58);
// Put the enable command as last.
mpu_set( MPU60X0_REG_I2C_SLV3_CTRL,
(1 << 7) | // Slave 2 enable
(0 << 6) | // Byte Swap
(1 << 5) | // Rig Dis: Write Only
(1 << 0) ); // Write 1 byte
mpu_set( MPU60X0_REG_I2C_SLV1_ADDR, (MS5611_ADDR0) | MPU60X0_SPI_READ);
mpu_set( MPU60X0_REG_I2C_SLV1_REG, MS5611_REG_ADCREAD);
// Put the enable command as last.
mpu_set( MPU60X0_REG_I2C_SLV1_CTRL,
(1 << 7) | // Slave 1 enable
(0 << 6) | // Byte Swap
(3 << 0) ); // Read 6 bytes
#endif
#endif