eive-obsw/mission/acs/gyroAdisHelpers.h

185 lines
6.4 KiB
C
Raw Normal View History

2021-05-24 00:31:47 +02:00
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_
2021-05-24 01:20:44 +02:00
#include <cstddef>
2022-01-17 15:58:27 +01:00
#include "fsfw/datapoollocal/StaticLocalDataSet.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
2023-02-26 14:55:33 +01:00
namespace adis1650x {
2023-02-26 14:55:33 +01:00
enum class BurstModes {
BURST_16_BURST_SEL_0,
BURST_16_BURST_SEL_1,
BURST_32_BURST_SEL_0,
BURST_32_BURST_SEL_1
};
size_t prepareReadCommand(const uint8_t* regList, size_t len, uint8_t* outBuf, size_t maxLen);
BurstModes burstModeFromMscCtrl(uint16_t mscCtrl);
double rangMdlToSensitivity(uint16_t rangMdl);
enum class Type : uint8_t { ADIS16505, ADIS16507 };
2021-05-24 00:31:47 +02:00
2021-05-24 01:20:44 +02:00
static constexpr size_t MAXIMUM_REPLY_SIZE = 64;
2021-05-26 13:11:48 +02:00
static constexpr uint8_t WRITE_MASK = 0b1000'0000;
2021-05-24 20:33:59 +02:00
2023-01-18 17:51:54 +01:00
// Ranges in deg / s
static constexpr double RANGE_UNSET = 0.0;
static constexpr double RANGE_1BMLZ = 125.0;
static constexpr double RANGE_2BMLZ = 500.0;
static constexpr double RANGE_3BMLZ = 2000.0;
// Sensitivities in deg/s/LSB
static constexpr double SENSITIVITY_UNSET = 0.0;
static constexpr double SENSITIVITY_1BMLZ = 0.00625;
static constexpr double SENSITIVITY_2BMLZ = 0.025;
static constexpr double SENSITIVITY_3BMLZ = 0.1;
2023-01-18 13:43:28 +01:00
enum RangMdlBitfield {
RANGE_125_1BMLZ = 0b00,
RANGE_500_2BMLZ = 0b01,
RESERVED = 0b10,
RANGE_2000_3BMLZ = 0b11
};
static constexpr uint32_t ACCELEROMETER_RANGE_16507 = 392;
static constexpr float ACCELEROMETER_RANGE_16505 = 78.4;
2021-05-24 20:33:59 +02:00
2021-05-24 20:57:12 +02:00
static constexpr uint32_t STALL_TIME_MICROSECONDS = 16;
static constexpr uint16_t PROD_ID_16507 = 16507;
static constexpr uint16_t PROD_ID_16505 = 16505;
2021-05-24 20:33:59 +02:00
static constexpr std::array<uint8_t, 2> BURST_READ_ENABLE = {0x68, 0x00};
2021-05-26 13:30:12 +02:00
static constexpr dur_millis_t START_UP_TIME = 310;
static constexpr dur_millis_t SW_RESET_BREAK = 255;
static constexpr dur_millis_t FACTORY_CALIBRATION_BREAK = 136;
static constexpr dur_millis_t FLASH_MEMORY_UPDATE_BREAK = 70;
static constexpr dur_millis_t FLASH_MEMORY_TEST_BREAK = 30;
static constexpr dur_millis_t SELF_TEST_BREAK = 24;
2021-05-24 20:33:59 +02:00
static constexpr uint8_t DIAG_STAT_REG = 0x02;
static constexpr uint8_t FILTER_CTRL_REG = 0x5c;
2023-01-18 13:43:28 +01:00
static constexpr uint8_t RANG_MDL_REG = 0x5e;
2021-05-24 20:33:59 +02:00
static constexpr uint8_t MSC_CTRL_REG = 0x60;
static constexpr uint8_t DEC_RATE_REG = 0x64;
static constexpr uint8_t GLOB_CMD = 0x68;
static constexpr uint8_t PROD_ID_REG = 0x72;
static constexpr DeviceCommandId_t READ_SENSOR_DATA = 0;
static constexpr DeviceCommandId_t READ_OUT_CONFIG = 1;
static constexpr DeviceCommandId_t SELF_TEST_SENSORS = 2;
static constexpr DeviceCommandId_t SELF_TEST_MEMORY = 3;
static constexpr DeviceCommandId_t UPDATE_NV_CONFIGURATION = 4;
static constexpr DeviceCommandId_t SELECT_BURST_READ_MODE = 5;
static constexpr DeviceCommandId_t RESET_SENSOR_CONFIGURATION = 30;
static constexpr DeviceCommandId_t SW_RESET = 31;
static constexpr DeviceCommandId_t PRINT_CURRENT_CONFIGURATION = 32;
2023-02-26 14:55:33 +01:00
static constexpr DeviceCommandId_t REQUEST = 0x70;
static constexpr DeviceCommandId_t REPLY = 0x77;
2021-05-24 20:57:12 +02:00
static constexpr uint16_t BURST_32_BIT = 1 << 9;
static constexpr uint16_t BURST_SEL_BIT = 1 << 8;
static constexpr uint16_t LIN_ACCEL_COMPENSATION_BIT = 1 << 7;
static constexpr uint16_t POINT_PERCUSSION_COMPENSATION_BIT = 1 << 6;
2023-01-18 13:43:28 +01:00
static constexpr size_t CONFIG_READOUT_SIZE = 12 + 2;
2021-05-25 13:53:03 +02:00
static constexpr size_t SENSOR_READOUT_SIZE = 20 + 2;
2021-05-24 20:33:59 +02:00
static constexpr uint32_t ADIS_DATASET_ID = READ_SENSOR_DATA;
static constexpr uint32_t ADIS_CFG_DATASET_ID = READ_OUT_CONFIG;
2023-04-19 15:31:45 +02:00
static constexpr uint16_t FILT_CTRL = 0x0000;
static constexpr uint16_t DEC_RATE = 0x0013;
2022-01-17 15:58:27 +01:00
enum GlobCmds : uint8_t {
FACTORY_CALIBRATION = 0b0000'0010,
SENSOR_SELF_TEST = 0b0000'0100,
FLASH_MEMORY_UPDATE = 0b0000'1000,
FLASH_MEMORY_TEST = 0b0001'0000,
SOFTWARE_RESET = 0b1000'0000
2021-05-26 13:11:48 +02:00
};
2022-01-17 15:58:27 +01:00
enum PrimaryPoolIds : lp_id_t {
ANG_VELOC_X,
ANG_VELOC_Y,
ANG_VELOC_Z,
ACCELERATION_X,
ACCELERATION_Y,
ACCELERATION_Z,
TEMPERATURE,
DIAG_STAT_REGISTER,
FILTER_SETTINGS,
2023-01-18 13:43:28 +01:00
RANG_MDL,
2022-01-17 15:58:27 +01:00
MSC_CTRL_REGISTER,
DEC_RATE_REGISTER,
2021-05-24 20:33:59 +02:00
};
2022-01-17 15:58:27 +01:00
enum FilterSettings : uint8_t {
NO_FILTER = 0,
TWO_TAPS = 1,
FOUR_TAPS = 2,
EIGHT_TAPS = 3,
SIXTEEN_TAPS = 4,
THIRTYTWO_TAPS = 5,
SIXTYFOUR_TAPS = 6
2021-05-24 20:33:59 +02:00
};
2023-02-26 14:55:33 +01:00
} // namespace adis1650x
2022-01-17 15:58:27 +01:00
class AdisGyroPrimaryDataset : public StaticLocalDataSet<8> {
public:
/** Constructor for data users like controllers */
AdisGyroPrimaryDataset(object_id_t adisId)
2023-02-26 14:55:33 +01:00
: StaticLocalDataSet(sid_t(adisId, adis1650x::ADIS_DATASET_ID)) {
2022-01-17 15:58:27 +01:00
setAllVariablesReadOnly();
}
/* Angular velocities in degrees per second (DPS) */
2023-02-26 14:55:33 +01:00
lp_var_t<double> angVelocX = lp_var_t<double>(sid.objectId, adis1650x::ANG_VELOC_X, this);
lp_var_t<double> angVelocY = lp_var_t<double>(sid.objectId, adis1650x::ANG_VELOC_Y, this);
lp_var_t<double> angVelocZ = lp_var_t<double>(sid.objectId, adis1650x::ANG_VELOC_Z, this);
lp_var_t<double> accelX = lp_var_t<double>(sid.objectId, adis1650x::ACCELERATION_X, this);
lp_var_t<double> accelY = lp_var_t<double>(sid.objectId, adis1650x::ACCELERATION_Y, this);
lp_var_t<double> accelZ = lp_var_t<double>(sid.objectId, adis1650x::ACCELERATION_Z, this);
lp_var_t<float> temperature = lp_var_t<float>(sid.objectId, adis1650x::TEMPERATURE, this);
2022-01-17 15:58:27 +01:00
private:
2023-02-26 14:55:33 +01:00
friend class GyrAdis1650XHandler;
friend class GyroAdisDummy;
2022-01-17 15:58:27 +01:00
/** Constructor for the data creator */
AdisGyroPrimaryDataset(HasLocalDataPoolIF* hkOwner)
2023-02-26 14:55:33 +01:00
: StaticLocalDataSet(hkOwner, adis1650x::ADIS_DATASET_ID) {}
2021-05-24 20:33:59 +02:00
};
2022-01-17 15:58:27 +01:00
class AdisGyroConfigDataset : public StaticLocalDataSet<5> {
public:
/** Constructor for data users like controllers */
AdisGyroConfigDataset(object_id_t adisId)
2023-02-26 14:55:33 +01:00
: StaticLocalDataSet(sid_t(adisId, adis1650x::ADIS_CFG_DATASET_ID)) {
2022-01-17 15:58:27 +01:00
setAllVariablesReadOnly();
}
lp_var_t<uint16_t> diagStatReg =
2023-02-26 14:55:33 +01:00
lp_var_t<uint16_t>(sid.objectId, adis1650x::DIAG_STAT_REGISTER, this);
lp_var_t<uint8_t> filterSetting =
2023-02-26 14:55:33 +01:00
lp_var_t<uint8_t>(sid.objectId, adis1650x::FILTER_SETTINGS, this);
lp_var_t<uint16_t> rangMdl = lp_var_t<uint16_t>(sid.objectId, adis1650x::RANG_MDL, this);
lp_var_t<uint16_t> mscCtrlReg =
2023-02-26 14:55:33 +01:00
lp_var_t<uint16_t>(sid.objectId, adis1650x::MSC_CTRL_REGISTER, this);
lp_var_t<uint16_t> decRateReg =
2023-02-26 14:55:33 +01:00
lp_var_t<uint16_t>(sid.objectId, adis1650x::DEC_RATE_REGISTER, this);
2022-01-17 15:58:27 +01:00
private:
2023-02-26 14:55:33 +01:00
friend class GyrAdis1650XHandler;
2022-01-17 15:58:27 +01:00
/** Constructor for the data creator */
AdisGyroConfigDataset(HasLocalDataPoolIF* hkOwner)
2023-02-26 14:55:33 +01:00
: StaticLocalDataSet(hkOwner, adis1650x::ADIS_CFG_DATASET_ID) {}
2021-05-24 20:33:59 +02:00
};
2021-05-24 00:31:47 +02:00
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ */