rm3100 continued
This commit is contained in:
@ -1,7 +1,10 @@
|
||||
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_
|
||||
#define MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_
|
||||
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <fsfw/serialize/SerialLinkedListAdapter.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace RM3100 {
|
||||
@ -24,9 +27,11 @@ static constexpr uint8_t CMM_VALUE = SET_CMM_CMZ | SET_CMM_CMY | SET_CMM_CMX |
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Cycle count register
|
||||
/*----------------------------------------------------------------------------*/
|
||||
// Default value (200)
|
||||
static constexpr uint8_t CYCLE_COUNT_VALUE = 0xC8;
|
||||
|
||||
static constexpr uint8_t GAIN = CYCLE_COUNT_VALUE / 100 * 38;
|
||||
static constexpr float DEFAULT_GAIN = static_cast<float>(CYCLE_COUNT_VALUE) /
|
||||
100 * 38;
|
||||
static constexpr uint8_t CYCLE_COUNT_START_REGISTER = 0x04;
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@ -48,13 +53,74 @@ static constexpr uint8_t REVID_REGISTER = 0x36;
|
||||
// Range in Microtesla. 1 T equals 10000 Gauss (for comparison with LIS3 MGM)
|
||||
static constexpr uint16_t RANGE = 800;
|
||||
|
||||
static constexpr DeviceCommandId_t CONFIGURE_CMM = 3;
|
||||
static constexpr DeviceCommandId_t READ_CMM = 4;
|
||||
static constexpr DeviceCommandId_t READ_DATA = 0;
|
||||
|
||||
//static constexpr DeviceCommandId_t CONFIGURE_CYC
|
||||
static constexpr DeviceCommandId_t CONFIGURE_CMM = 1;
|
||||
static constexpr DeviceCommandId_t READ_CMM = 2;
|
||||
|
||||
static constexpr DeviceCommandId_t CONFIGURE_TMRC = 5;
|
||||
static constexpr DeviceCommandId_t READ_TMRC = 6;
|
||||
static constexpr DeviceCommandId_t CONFIGURE_TMRC = 3;
|
||||
static constexpr DeviceCommandId_t READ_TMRC = 4;
|
||||
|
||||
static constexpr DeviceCommandId_t CONFIGURE_CYCLE_COUNT = 5;
|
||||
static constexpr DeviceCommandId_t READ_CYCLE_COUNT = 6;
|
||||
|
||||
class CycleCountCommand: public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
CycleCountCommand(bool oneCycleCount = true): oneCycleCount(oneCycleCount) {
|
||||
setLinks(oneCycleCount);
|
||||
}
|
||||
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) override {
|
||||
ReturnValue_t result = SerialLinkedListAdapter::deSerialize(buffer,
|
||||
size, streamEndianness);
|
||||
if(oneCycleCount) {
|
||||
cycleCountY = cycleCountX;
|
||||
cycleCountZ = cycleCountX;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
SerializeElement<uint16_t> cycleCountX;
|
||||
SerializeElement<uint16_t> cycleCountY;
|
||||
SerializeElement<uint16_t> cycleCountZ;
|
||||
|
||||
private:
|
||||
void setLinks(bool oneCycleCount) {
|
||||
setStart(&cycleCountX);
|
||||
if(not oneCycleCount) {
|
||||
cycleCountX.setNext(&cycleCountY);
|
||||
cycleCountY.setNext(&cycleCountZ);
|
||||
}
|
||||
}
|
||||
|
||||
bool oneCycleCount;
|
||||
};
|
||||
|
||||
static constexpr uint32_t MGM_DATASET_ID = READ_DATA;
|
||||
|
||||
enum MgmPoolIds: lp_id_t {
|
||||
FIELD_STRENGTH_X,
|
||||
FIELD_STRENGTH_Y,
|
||||
FIELD_STRENGTH_Z,
|
||||
};
|
||||
|
||||
class Rm3100PrimaryDataset: public StaticLocalDataSet<3 * sizeof(float)> {
|
||||
public:
|
||||
Rm3100PrimaryDataset(HasLocalDataPoolIF* hkOwner):
|
||||
StaticLocalDataSet(hkOwner, MGM_DATASET_ID) {}
|
||||
|
||||
Rm3100PrimaryDataset(object_id_t mgmId):
|
||||
StaticLocalDataSet(sid_t(mgmId, MGM_DATASET_ID)) {}
|
||||
|
||||
// Field strengths in micro Tesla.
|
||||
lp_var_t<float> fieldStrengthX = lp_var_t<float>(sid.objectId,
|
||||
FIELD_STRENGTH_X, this);
|
||||
lp_var_t<float> fieldStrengthY = lp_var_t<float>(sid.objectId,
|
||||
FIELD_STRENGTH_Y, this);
|
||||
lp_var_t<float> fieldStrengthZ = lp_var_t<float>(sid.objectId,
|
||||
FIELD_STRENGTH_Z, this);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user