Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::MS5803 Class Reference

#include <MS5803.h>

Inheritance diagram for Boardcore::MS5803:
Collaboration diagram for Boardcore::MS5803:

Public Types

enum  FSMStates { STATE_INIT = 0 , STATE_SAMPLED_TEMP , STATE_SAMPLED_PRESS }
 
enum  MS5803Registers : uint8_t {
  REG_RESET = 0x1E , REG_CONVERT_D1_256 = 0x40 , REG_CONVERT_D1_512 = 0x42 , REG_CONVERT_D1_1024 = 0x44 ,
  REG_CONVERT_D1_2048 = 0x46 , REG_CONVERT_D1_4096 = 0x48 , REG_CONVERT_D2_256 = 0x50 , REG_CONVERT_D2_512 = 0x52 ,
  REG_CONVERT_D2_1024 = 0x54 , REG_CONVERT_D2_2048 = 0x56 , REG_CONVERT_D2_4096 = 0x58 , REG_ADC_READ = 0x00 ,
  REG_PROM_SENS_MASK = 0xA2 , REG_PROM_OFF_MASK = 0xA4 , REG_PROM_TCS_MASK = 0xA6 , REG_PROM_TCO_MASK = 0xA8 ,
  REG_PROM_TREF_MASK = 0xAA , REG_PROM_TEMPSENS_MASK = 0xAC
}
 
- Public Types inherited from Boardcore::Sensor< MS5803Data >
using DataType
 

Public Member Functions

 MS5803 (SPIBusInterface &spiBus, miosix::GpioPin cs, SPIBusConfig spiConfig={}, uint16_t temperatureDivider=1)
 
bool init () override
 Initialize the sensor.
 
bool selfTest () override
 Check if the sensor is working.
 
- Public Member Functions inherited from Boardcore::Sensor< MS5803Data >
 Sensor ()
 
 Sensor (Sensor &&other)
 
virtual ~Sensor ()
 
void sample () override
 Sample the sensor.
 
virtual MS5803Data getLastSample ()
 
- Public Member Functions inherited from Boardcore::AbstractSensor
virtual ~AbstractSensor ()
 
SensorErrors getLastError ()
 Get last error for debugging purposes. Avoid silent fails.
 

Static Public Attributes

static constexpr uint8_t TIMEOUT = 5
 

Protected Member Functions

MS5803Data sampleImpl () override
 

Additional Inherited Members

- Protected Attributes inherited from Boardcore::Sensor< MS5803Data >
DataType lastSample
 
miosix::FastMutex mutex
 
- Protected Attributes inherited from Boardcore::AbstractSensor
SensorErrors lastError = SensorErrors::NO_ERRORS
 

Detailed Description

Definition at line 34 of file MS5803.h.

Member Enumeration Documentation

◆ FSMStates

Enumerator
STATE_INIT 
STATE_SAMPLED_TEMP 
STATE_SAMPLED_PRESS 

Definition at line 37 of file MS5803.h.

◆ MS5803Registers

Enumerator
REG_RESET 
REG_CONVERT_D1_256 
REG_CONVERT_D1_512 
REG_CONVERT_D1_1024 
REG_CONVERT_D1_2048 
REG_CONVERT_D1_4096 
REG_CONVERT_D2_256 
REG_CONVERT_D2_512 
REG_CONVERT_D2_1024 
REG_CONVERT_D2_2048 
REG_CONVERT_D2_4096 
REG_ADC_READ 
REG_PROM_SENS_MASK 
REG_PROM_OFF_MASK 
REG_PROM_TCS_MASK 
REG_PROM_TCO_MASK 
REG_PROM_TREF_MASK 
REG_PROM_TEMPSENS_MASK 

Definition at line 44 of file MS5803.h.

Constructor & Destructor Documentation

◆ MS5803()

Boardcore::MS5803::MS5803 ( SPIBusInterface & spiBus,
miosix::GpioPin cs,
SPIBusConfig spiConfig = {},
uint16_t temperatureDivider = 1 )

Definition at line 31 of file MS5803.cpp.

Member Function Documentation

◆ init()

bool Boardcore::MS5803::init ( )
overridevirtual

Initialize the sensor.

Returns
boolean value indicating whether the operation succeded or not

Implements Boardcore::AbstractSensor.

Definition at line 39 of file MS5803.cpp.

◆ sampleImpl()

MS5803Data Boardcore::MS5803::sampleImpl ( )
overrideprotectedvirtual

Implements a state machines composed of 3 states:

  1. Command pressure sample
  2. Read Pressure sample & command temperature sample
  3. Read temperature sample & command pressure sample

After the first call to sample() (state 1), the machine transitions between states 2 and 3: The effective sampling rate is half the rate at which this function is called. Example: call sample() at 100 Hz -> Pressure & Temperature sample Rate = 50 Hz

Implements Boardcore::Sensor< MS5803Data >.

Definition at line 63 of file MS5803.cpp.

◆ selfTest()

bool Boardcore::MS5803::selfTest ( )
overridevirtual

Check if the sensor is working.

Returns
boolean indicating whether the sensor is correctly working or not

Implements Boardcore::AbstractSensor.

Definition at line 61 of file MS5803.cpp.

Member Data Documentation

◆ TIMEOUT

constexpr uint8_t Boardcore::MS5803::TIMEOUT = 5
staticconstexpr

Definition at line 73 of file MS5803.h.


The documentation for this class was generated from the following files: