mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-ms56xx.git
synced 2025-08-06 13:27:34 +00:00
Small cleanup and new methods
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
// Needed for sta/endian.hpp
|
||||
#define STA_MCU_LITTLE_ENDIAN
|
||||
|
||||
// Needed for sta/stm32/delay.hpp
|
||||
#define STA_PLATFORM_STM32
|
||||
#define STA_STM32_DELAY_US_TIM
|
@@ -1,15 +1,27 @@
|
||||
#ifndef STA_SENSORS_MS5607_HPP
|
||||
#define STA_SENSORS_MS5607_HPP
|
||||
|
||||
#include<sta/spi/device.hpp>
|
||||
#include<sta/endian.hpp>
|
||||
#include<sta/stm32/delay.hpp>
|
||||
#include <sta/bus/spi/device.hpp>
|
||||
#include <sta/endian.hpp>
|
||||
#include <sta/stm32/delay.hpp>
|
||||
|
||||
namespace sta {
|
||||
// Class to represent a MS5607 pressure sensor which is used with SPI
|
||||
class MS5607 {
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Driver class for communicating with the MS56xx pressure sensor via SPI.
|
||||
*
|
||||
*/
|
||||
class MS56xx {
|
||||
public:
|
||||
// Different OSR levels for the sensor
|
||||
/**
|
||||
* @brief Signature for delay msec function.
|
||||
*/
|
||||
using DelayMsFunc = void (*)(uint32_t);
|
||||
|
||||
/**
|
||||
* @brief Different OSR levels for the sensor
|
||||
*
|
||||
*/
|
||||
enum OsrLevel {
|
||||
_256 = 0,
|
||||
_512 = 1,
|
||||
@@ -18,7 +30,35 @@ namespace sta {
|
||||
_4096 = 4
|
||||
};
|
||||
|
||||
MS5607(SpiDevice* device, OsrLevel osr=OsrLevel::_1024);
|
||||
/**
|
||||
* @brief Driver class for the MS56xx pressure sensor series.
|
||||
*
|
||||
* @param device The SPI device for bus communication.
|
||||
* @param osr The output sampling rate for the sensor.
|
||||
*/
|
||||
MS56xx(SPIDevice * device, DelayMsFunc delay, osr=OsrLevel::_1024);
|
||||
|
||||
/**
|
||||
* @brief Initialize the driver. Computes the pressure value at altitude 0.
|
||||
*
|
||||
* @return True if successful, false otherwise.
|
||||
*/
|
||||
bool init();
|
||||
|
||||
/**
|
||||
* @brief Set the Pressure Reference object
|
||||
*
|
||||
* @param pressRef The reference pressure value measured at a reference altitude.
|
||||
* @param altRef The reference altitude for the reference pressure.
|
||||
*/
|
||||
void setPressureReference(float pressRef, float altRef);
|
||||
|
||||
/**
|
||||
* @brief Estimate the current altitude based on the pressure readings.
|
||||
*
|
||||
* @return float The altitude estimate in meters.
|
||||
*/
|
||||
float getAltitudeEstimate();
|
||||
|
||||
// Request Calculation of uncompensated pressure
|
||||
// Takes a few ms -> Call, then do sth. else, then get Pressure with function
|
||||
@@ -65,7 +105,8 @@ namespace sta {
|
||||
bool presRead;
|
||||
|
||||
// STA internal object for SPi abstraction
|
||||
SpiDevice* device_;
|
||||
SPIDevice * device_;
|
||||
DelayMsFunc delay_;
|
||||
OsrLevel osr_;
|
||||
|
||||
// 6 Different constants; Includes Offsets, references etc.
|
Reference in New Issue
Block a user