Comment code

This commit is contained in:
Theodor Teslia
2023-03-18 14:43:10 +01:00
parent e5181b23cd
commit 265245e6ef
2 changed files with 45 additions and 8 deletions

View File

@@ -6,8 +6,10 @@
#include<sta/stm32/delay.hpp>
namespace sta {
// Class to represent a MS5607 pressure sensor which is used with SPI
class MS5607 {
public:
// Different OSR levels for the sensor
enum OsrLevel {
_256 = 0,
_512 = 1,
@@ -18,17 +20,25 @@ namespace sta {
MS5607(SpiDevice* device, OsrLevel osr=OsrLevel::_1024);
// Getter for pressure
int32_t getPressure();
// Getter for temperature
int32_t getTemperature();
void changeOsrLevel(OsrLevel newOsr) { this->osr_ = newOsr; }
void changeOsrLevel(OsrLevel newOsr) {
// Don't I need to write this to the sensor?
this->osr_ = newOsr;
}
private:
// STA internal object for SPi abstraction
SpiDevice* device_;
OsrLevel osr_;
// 6 Different constants; Includes Offsets, references etc.
uint16_t sens, off, tcs, tco, t_ref, tempsens;
// All possible commands to send to the sensor
enum Operations {
RESET = 0x1E,
READ_PROM = 0xA2,
@@ -37,17 +47,18 @@ namespace sta {
ADC_RESULT = 0x00
};
// Request pure ADC converted values from the sensor
// Calculations with offset required
uint32_t readPressure();
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);
void reset();
void readPROM();
// Take first bytes from buffer, swap them and store those in uint16_t
static uint16_t uint_8BufferTouint16_t(uint8_t* buffer);
// 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
};