DroneOS/Drivers/Source/drvMS5611.c
/**
 * Gets pressure, temperature and above sea level altitude estimate (asl).
 * Best called at 100hz. For every PRESSURE_PER_TEMP-1 pressure readings temp is read once.
 * Effective 50-90hz baro update and 50-10hz temperature update if called at 100hz.
 */
Gets pressure, temperature and above sea level altitude estimate (asl).
Best called at 100hz. For every PRESSURE_PER_TEMP-1 pressure readings temp is read once.
Effective 50-90hz baro update and 50-10hz temperature update if called at 100hz.
Gets pressure temperature and above sea level altitude estimate ( asl ) . Best called at 100hz . For every PRESSURE_PER_TEMP - 1 pressure readings temp is read once . Effective 50 - 90hz baro update and 50 - 10hz temperature update if called at 100hz .
void ms5611GetData(float* pressure, float* temperature, float* asl)
{
    int32_t tempPressureRaw, tempTemperatureRaw;
    uint32_t now = xTaskGetTickCount();
    if ((now - lastConv) < CONVERSION_TIME_MS)
    {
        return;
    }
    lastConv = now;
    if (readState == 0)
    {
        ++readState;
        tempTemperatureRaw = ms5611GetConversion(MS5611_D2 + MS5611_OSR_DEFAULT);
        tempDeltaT = ms5611CalcDeltaTemp(tempTemperatureRaw);
        *temperature = ms5611CalcTemp(tempDeltaT);
        ms5611StartConversion(MS5611_D1 + MS5611_OSR_DEFAULT);
    }
    else
    {
        ++readState;
        tempPressureRaw = ms5611GetConversion(MS5611_D1 + MS5611_OSR_DEFAULT);
        *pressure = ms5611CalcPressure(tempPressureRaw, tempDeltaT);
        *asl = ms5611PressureToAltitude(pressure);
        if (readState == PRESSURE_PER_TEMP){
            ms5611StartConversion(MS5611_D2 + MS5611_OSR_DEFAULT);
            readState = 0;
        }
        else
        {
            ms5611StartConversion(MS5611_D1 + MS5611_OSR_DEFAULT);
        }
    }
}
void ms5611GetData ( float * pressure , float * temperature , float * asl ) { int32_t tempPressureRaw , tempTemperatureRaw ; uint32_t now = xTaskGetTickCount ( ) ; if ( ( now - lastConv ) < CONVERSION_TIME_MS ) { return ; } lastConv = now ; if ( readState == 0 ) { ++ readState ; tempTemperatureRaw = ms5611GetConversion ( MS5611_D2 + MS5611_OSR_DEFAULT ) ; tempDeltaT = ms5611CalcDeltaTemp ( tempTemperatureRaw ) ; * temperature = ms5611CalcTemp ( tempDeltaT ) ; ms5611StartConversion ( MS5611_D1 + MS5611_OSR_DEFAULT ) ; } else { ++ readState ; tempPressureRaw = ms5611GetConversion ( MS5611_D1 + MS5611_OSR_DEFAULT ) ; * pressure = ms5611CalcPressure ( tempPressureRaw , tempDeltaT ) ; * asl = ms5611PressureToAltitude ( pressure ) ; if ( readState == PRESSURE_PER_TEMP ) { ms5611StartConversion ( MS5611_D2 + MS5611_OSR_DEFAULT ) ; readState = 0 ; } else { ms5611StartConversion ( MS5611_D1 + MS5611_OSR_DEFAULT ) ; } } }
Gets pressure, temperature and above sea level altitude estimate (asl).
Gets pressure temperature and above sea level altitude estimate ( asl ) .
// Dont reader faster than we can // read temp // cmd to read pressure // read pressure // cmd to read temp // cmd to read pressure