mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-ms56xx.git
synced 2025-09-28 22:37:33 +00:00
Updated data handling
This commit is contained in:
@@ -42,6 +42,16 @@ namespace sta
|
||||
return true;
|
||||
}
|
||||
|
||||
void MS56xx::requestData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool MS56xx::hasData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MS56xx::setOsr(OsrLevel osr)
|
||||
{
|
||||
osr_ = osr;
|
||||
@@ -53,28 +63,32 @@ namespace sta
|
||||
delay_(MS56xx::RESET_DELAY);
|
||||
}
|
||||
|
||||
void MS56xx::requestData(DataType type, bool blocking = false)
|
||||
{
|
||||
Operations op = type == DataType::PRESSURE ? D1_CONVERSION : D2_CONVERSION;
|
||||
|
||||
// Request the ADC to read new data.
|
||||
busCommand(op + 2*this->osr_);
|
||||
|
||||
if (blocking)
|
||||
{
|
||||
delay_(osrDelay());
|
||||
}
|
||||
}
|
||||
|
||||
float MS56xx::getPressure(Unit unit /* = Unit::hPa */)
|
||||
{
|
||||
// Request the ADC to read temperature values.
|
||||
busCommand(MS56xx::Operations::D1_CONVERSION + 2*this->osr_);
|
||||
|
||||
// 8.22 ms conversion according to the datasheet.
|
||||
delay_(osrDelay());
|
||||
// Request the ADC to read pressure values.
|
||||
requestData(PRESSURE, true);
|
||||
|
||||
uint8_t buffer[3] = { 0x00, 0x00, 0x00 };
|
||||
busRead(MS56xx::Operations::ADC_RESULT, buffer, 3);
|
||||
|
||||
// Difference between actual and reference temperature.
|
||||
uint32_t D1 = buffer[0] << 16 | buffer[1] << 8 | buffer[2];
|
||||
|
||||
// Request the ADC to read pressure values.
|
||||
busCommand(MS56xx::Operations::D2_CONVERSION + 2*this->osr_);
|
||||
|
||||
// 8.22 ms conversion according to the datasheet.
|
||||
delay_(osrDelay());
|
||||
// Request the ADC to read temperature values.
|
||||
requestData(PRESSURE, true);
|
||||
|
||||
busRead(MS56xx::Operations::ADC_RESULT, buffer, 3);
|
||||
|
||||
uint32_t D2 = buffer[0] << 16 | buffer[1] << 8 | buffer[2];
|
||||
|
||||
float dT = D2 - C_[5];
|
||||
|
Reference in New Issue
Block a user