Updated driver code; tested on MS5611

This commit is contained in:
dario
2024-04-13 17:43:16 +02:00
parent 90a04b4ee5
commit 5519e3664a
2 changed files with 89 additions and 86 deletions

View File

@@ -12,13 +12,13 @@
* @brief MS56xx address when the CS pin is connected to GND.
*
*/
#define MS56XX_ADDRESS_CS_LOW 0x1110111
#define MS56XX_ADDRESS_CS_LOW (uint8_t)0x77
/**
* @brief MS56xx address when the CS pin is connected to VDD.
*
*/
#define MS56XX_ADDRESS_CS_HIGH 0x1110110
#define MS56XX_ADDRESS_CS_HIGH (uint8_t)0x76
namespace sta
@@ -73,7 +73,7 @@ namespace sta
*/
enum Operations {
RESET = 0x1E,
READ_PROM = 0xA2,
READ_PROM = 0xA0,
D1_CONVERSION = 0x40,
D2_CONVERSION = 0x50,
ADC_RESULT = 0x00
@@ -159,6 +159,14 @@ namespace sta
*/
void readPROM();
/**
* @brief Initialize the constants used for conversion.
*
* @note This code was taken from https://github.com/RobTillaart/MS5611
*
*/
void initConstants(bool mathMode = 0);
/**
* @brief Convert the pressure value given in Pa to a different unit.
*
@@ -201,16 +209,6 @@ namespace sta
* @return true if successful, false otherwise.
*/
bool busRead(uint8_t reg, uint8_t * buffer, size_t length);
/**
* @brief Write data to one of the sensor's registers.
*
* @param reg The register to write to.
* @param buffer The buffer of data to write to the register.
* @param length The number of bytes to write.
* @return true if successful, false otherwise.
*/
bool busWrite(uint8_t reg, uint8_t * buffer, size_t length);
private:
// STA internal object for SPi abstraction
Device * device_;
@@ -221,13 +219,8 @@ namespace sta
// Pressure at sealevel. Use the standard atmosphere per default.
float sealevel_ = 1013.25;
// 6 Different constants; Includes Offsets, references etc.
uint16_t sensibility_;
uint16_t offset_;
uint16_t tempSensCoeff_;
uint16_t tempOffsetCoeff_;
uint16_t refTemp_;
uint16_t tempCoeff_;
// The different constants; Includes Offsets, references etc.
float C_[8];
// Constants for waiting
const uint32_t RESET_DELAY = 2800; // in uS