mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-ms56xx.git
synced 2025-06-10 01:55:59 +00:00
Updated data handling
This commit is contained in:
parent
5519e3664a
commit
d013fbe62b
@ -71,7 +71,8 @@ namespace sta
|
||||
* @brief All possible commands to send to the sensor
|
||||
*
|
||||
*/
|
||||
enum Operations {
|
||||
enum Operations
|
||||
{
|
||||
RESET = 0x1E,
|
||||
READ_PROM = 0xA0,
|
||||
D1_CONVERSION = 0x40,
|
||||
@ -79,6 +80,12 @@ namespace sta
|
||||
ADC_RESULT = 0x00
|
||||
};
|
||||
|
||||
enum DataType
|
||||
{
|
||||
PRESSURE,
|
||||
TEMPERATURE
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief SPI driver for the MS56xx pressure sensor series.
|
||||
*
|
||||
|
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user