mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-ms56xx.git
synced 2025-06-09 17:46:00 +00:00
Add gitignore
This commit is contained in:
parent
726e7f6de0
commit
c5eb409d79
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
cmake-build-debug
|
||||
CMakeLists.txt
|
||||
.idea
|
@ -20,9 +20,25 @@ namespace sta {
|
||||
|
||||
MS5607(SpiDevice* device, OsrLevel osr=OsrLevel::_1024);
|
||||
|
||||
// Getter for pressure
|
||||
// Request Calculation of uncompensated pressure
|
||||
// Takes a few ms -> Call, then do sth. else, then get Pressure with function
|
||||
// If calculation already running, do nothing
|
||||
void requestAdcReadout(uint32_t curTime);
|
||||
|
||||
// Function to get Pressure
|
||||
// Parameter should be Temperature in Celsius * 100 (e.g. 20.3 deg. C -> 2030)
|
||||
// If currently still processing, use old value
|
||||
// If currently not processing, start processing to minmize potential wating times
|
||||
int32_t getPressure(int32_t temp, uint32_t curTime);
|
||||
|
||||
// Parameterless version of function above
|
||||
// Calls getTemperature, to get temp
|
||||
// NOT RECOMMENDED
|
||||
int32_t getPressure();
|
||||
|
||||
// Getter for temperature
|
||||
// Deprecated because of time constrains
|
||||
// NOT RECOMMENDED
|
||||
int32_t getTemperature();
|
||||
|
||||
void changeOsrLevel(OsrLevel newOsr) {
|
||||
@ -38,6 +54,12 @@ namespace sta {
|
||||
this->device_->beginTransmission();
|
||||
}
|
||||
|
||||
// Last Presure Value meassured; Used to give any output if still calculating ADC
|
||||
int32_t lastPresVal;
|
||||
// Value to store, when adc was started
|
||||
// On STM32 with HAL_GetTick() (Gives ms since startup)
|
||||
uint32_t adcStartTime;
|
||||
|
||||
// STA internal object for SPi abstraction
|
||||
SpiDevice* device_;
|
||||
OsrLevel osr_;
|
||||
@ -57,7 +79,10 @@ namespace sta {
|
||||
// Request pure ADC converted values from the sensor
|
||||
// Calculations with offset required
|
||||
uint32_t readPressure();
|
||||
|
||||
// Read temp should not be used, rather give temp from e.g. SCA3300 as parameter to readPres
|
||||
uint32_t readTemp();
|
||||
|
||||
// Calculate pure ADC values to final pressure/temperature values
|
||||
int32_t calculatePressure(uint32_t d1, int32_t dT);
|
||||
int32_t calculateTemperature(uint32_t d2);
|
||||
@ -67,7 +92,16 @@ namespace sta {
|
||||
|
||||
// Constants for waiting
|
||||
const char RESET_DELAY = 2800; // in uS
|
||||
const char ADC_DELAY = 8220; // in uS; not sure if thats correct since the datasheet doesn't say anything explicitly
|
||||
|
||||
// Function to get the delay times needed for different OSR Levels
|
||||
// Values not found in datasheet (facepalm)
|
||||
// Thus partly googled, partly tested out
|
||||
static uint8_t delayTimes(OsrLevel level) {
|
||||
switch (level) {
|
||||
case _256:
|
||||
return
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace sta {
|
||||
MS5607::MS5607(SpiDevice* device, OsrLevel level) {
|
||||
this->device_ = device;
|
||||
this->osr_ = level;
|
||||
this->lastPresVal = -1;
|
||||
|
||||
// Reset device on start-up
|
||||
this->reset();
|
||||
@ -11,6 +12,20 @@ namespace sta {
|
||||
this->readPROM();
|
||||
}
|
||||
|
||||
void MS5607::requestAdcReadout() {
|
||||
// Get current state of calculation
|
||||
|
||||
|
||||
this->device_->beginTransmission();
|
||||
this->device_->transfer(MS5607::Operations::D1_CONVERSION + 2*this->osr_);
|
||||
this->device_->endTransmission();
|
||||
}
|
||||
|
||||
int32_t MS5607::getPressure(int32_t temp) {
|
||||
|
||||
}
|
||||
|
||||
// DEPRECATED
|
||||
int32_t MS5607::getPressure() {
|
||||
// Get pure ADC value from the sensor
|
||||
uint32_t d1 = readPressure();
|
||||
@ -24,6 +39,7 @@ namespace sta {
|
||||
return calculatePressure(d1, dT);
|
||||
}
|
||||
|
||||
// DON'T USE
|
||||
uint32_t MS5607::readPressure() {
|
||||
// Request pressure value conversion
|
||||
this->device_->beginTransmission();
|
||||
@ -32,7 +48,14 @@ namespace sta {
|
||||
|
||||
// Wait for ADC to finish
|
||||
// Could do sth. else and schedule continuation with scheduler in RTOS
|
||||
delayUs(MS5607::ADC_DELAY);
|
||||
uint8_t buf[1] = { 0 };
|
||||
do {
|
||||
*buf = 0;
|
||||
uint8_t tx[1] = { 0b11111110 };
|
||||
this->device_->beginTransmission();
|
||||
this->device_->transfer(tx, buf, 1);
|
||||
this->device_->endTransmission();
|
||||
} while (*buf == 0x00);
|
||||
|
||||
// Request readout of ADC value
|
||||
uint8_t d1Arr[3];
|
||||
@ -52,12 +75,14 @@ namespace sta {
|
||||
// Probably problems with type conversions
|
||||
// If we used Rust...
|
||||
int32_t MS5607::calculatePressure(uint32_t d1, int32_t dT) {
|
||||
int64_t offset = ( ((uint32_t)this->off) << 17) + ( ( ((uint32_t)this->tco) * dT ) >> 6);
|
||||
int64_t sensitivity = ( ((uint32_t)this->sens) << 16) + ( ( ((uint32_t)this->tcs) * dT ) >> 7);
|
||||
int64_t offset = ( ((uint64_t)this->off) << 17) + ( ( ((uint64_t)this->tco) * dT ) >> 6);
|
||||
int64_t sensitivity = ( ((uint64_t)this->sens) << 16) + ( ( ((uint64_t)this->tcs) * dT ) >> 7);
|
||||
int32_t pres = ( (( ((uint64_t)d1) * sensitivity) >> 21) - offset ) >> 15;
|
||||
return pres;
|
||||
}
|
||||
|
||||
// NOT RECOMMENDED
|
||||
// USE TEMP FROM SCA3300 OR STH. ELSE
|
||||
int32_t MS5607::getTemperature() {
|
||||
// Get pure ADC value from the sensor
|
||||
uint32_t d2 = readTemp();
|
||||
@ -65,6 +90,7 @@ namespace sta {
|
||||
return calculateTemperature(d2);
|
||||
}
|
||||
|
||||
// OLD; DON'T USE
|
||||
uint32_t MS5607::readTemp() {
|
||||
// Request ADC conversion of temperature
|
||||
this->device_->beginTransmission();
|
||||
@ -73,7 +99,15 @@ namespace sta {
|
||||
|
||||
// Wait for ADC to finish
|
||||
// Could do sth. else and schedule continuation with scheduler in RTOS
|
||||
delayUs(MS5607::ADC_DELAY);
|
||||
uint8_t buf[1] = { 0 };
|
||||
do {
|
||||
*buf = 0;
|
||||
uint8_t tx[1] = { 0b11111110 };
|
||||
this->device_->beginTransmission();
|
||||
this->device_->transfer(tx, buf, 1);
|
||||
this->device_->endTransmission();
|
||||
} while (*buf == 0x00);
|
||||
|
||||
|
||||
// Request ADC readout
|
||||
uint8_t d2Arr[3];
|
||||
|
Loading…
x
Reference in New Issue
Block a user