integration complete

This commit is contained in:
Robin Müller 2020-09-30 22:00:37 +02:00 committed by Robin.Mueller
parent 9fd27801f6
commit 862f029448
4 changed files with 81 additions and 99 deletions

View File

@ -17,6 +17,7 @@ enum: uint8_t {
PUS_SERVICE_6,
PUS_SERVICE_8,
PUS_SERVICE_23,
MGM_LIS3MDL
};
}

2
fsfw

@ -1 +1 @@
Subproject commit 916a374c19549744f6413799ca7bb0a66c5b54e0
Subproject commit 44340aa506737c1b489ef20774c42d5ef55bb7bd

View File

@ -44,11 +44,10 @@ ReturnValue_t MGMHandlerLIS3MDL::setupMGM() {
}
ReturnValue_t MGMHandlerLIS3MDL::buildNormalDeviceCommand(
DeviceCommandId_t *id) { //defines CommandID of MGM in normal operation and build command from command
DeviceCommandId_t *id) {
//defines CommandID of MGM in normal operation and build command from command
*id = READALL_MGM;
return buildCommandFromCommand(*id, NULL, 0);
}
ReturnValue_t MGMHandlerLIS3MDL::buildCommandFromCommand(
@ -80,7 +79,7 @@ ReturnValue_t MGMHandlerLIS3MDL::buildCommandFromCommand(
return setOperatingMode(commandData, commandDataLen);
}
default:
lastSentCommand = NO_COMMAND;
lastSentCommand = DeviceHandlerIF::NO_COMMAND;
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
}
@ -110,7 +109,7 @@ ReturnValue_t MGMHandlerLIS3MDL::buildTransitionDeviceCommand(
}
ReturnValue_t MGMHandlerLIS3MDL::scanForReply(const uint8_t *start,
uint32_t len, DeviceCommandId_t *foundId, uint32_t *foundLen) {
size_t len, DeviceCommandId_t *foundId, size_t *foundLen) {
*foundLen = len;
if (len == TOTAL_NR_OF_ADRESSES + 1) {
*foundLen = len;
@ -149,7 +148,6 @@ ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id,
break;
}
case READALL_MGM: {
//DataSet mySet;
registers[0] = *(packet + 33);
registers[1] = *(packet + 34);
@ -183,18 +181,6 @@ ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id,
float z_value = (float) z_value_raw * sensitivity;
float temp_value = 25.0 + (((float) temp_value_raw) / 8.0);
// PoolVector<float, 3> mgm_measurement(mgmMagneticPoolId, &mySet,
// PoolVariableIF::VAR_WRITE);
// PoolVariable<float> mgm_temperature(mgmTempPoolId, &mySet,
// PoolVariableIF::VAR_WRITE);
// mgm_measurement[0] = x_value;
// mgm_measurement[1] = y_value;
// mgm_measurement[2] = z_value;
//
// mgm_temperature = temp_value;
// handleDeviceTM(&mySet, id);
break;
}
@ -339,19 +325,21 @@ ReturnValue_t MGMHandlerLIS3MDL::setOperatingMode(const uint8_t *commandData,
}
void MGMHandlerLIS3MDL::fillCommandAndReplyMap() {
/*Actually SPI answers directly, but as commanding ArduinoBoard the communication could be delayed
* SPI always has to be triggered, so there could be no periodic answer of the device, the device has
* to asked with a command, so periodic is zero.
/*
* Regarding ArduinoBoard:
* Actually SPI answers directly, but as commanding ArduinoBoard the
* communication could be delayed
* SPI always has to be triggered, so there could be no periodic answer of
* the device, the device has to asked with a command, so periodic is zero.
*
* We dont read single registers, we just expect special
* reply from he Readall_MGM
*/
insertInCommandAndReplyMap(READALL_MGM, 1, 0);
insertInCommandAndReplyMap(SETUP_MGM, 1, 0);
insertInCommandAndReplyMap(IDENTIFY_DEVICE, 1, 0);
insertInCommandAndReplyMap(TEMP_SENSOR_ENABLE, 1, 0);
insertInCommandAndReplyMap(ACCURACY_OP_MODE_SET, 1, 0);
insertInCommandAndReplyMap(READALL_MGM, 1);
insertInCommandAndReplyMap(SETUP_MGM, 1);
insertInCommandAndReplyMap(IDENTIFY_DEVICE, 1);
insertInCommandAndReplyMap(TEMP_SENSOR_ENABLE, 1);
insertInCommandAndReplyMap(ACCURACY_OP_MODE_SET, 1);
}
ReturnValue_t MGMHandlerLIS3MDL::prepareRegisterWrite() {
@ -369,20 +357,7 @@ ReturnValue_t MGMHandlerLIS3MDL::prepareRegisterWrite() {
}
void MGMHandlerLIS3MDL::setNormalDatapoolEntriesInvalid() {
// DataSet mySet;
// PoolVector<float, 3> mgmMeasurements(mgmMagneticPoolId, &mySet,
// PoolVariableIF::VAR_WRITE);
// PoolVariable<float> mgmTemperature(mgmTempPoolId, &mySet,
// PoolVariableIF::VAR_WRITE);
//
// mgmMeasurements[0] = 0;
// mgmMeasurements[1] = 0;
// mgmMeasurements[2] = 0;
//
// mgmTemperature = 999;
// mySet.commit(PoolVariableIF::INVALID);
// TODO: use new distributed datapools here.
}
void MGMHandlerLIS3MDL::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {

View File

@ -2,7 +2,7 @@
#define MISSION_DEVICEHANDLING_MGMLIS3MDLHANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <subsystemIdRanges.h>
/**
* @brief Device handler object for the LIS3MDL 3-axis magnetometer
@ -23,17 +23,12 @@ public:
static const uint8_t INTERFACE_ID = CLASS_ID::MGM_LIS3MDL;
static const DeviceCommandId_t SETUP_MGM = 0x00;
static const DeviceCommandId_t READALL_MGM = 0x01;
static const DeviceCommandId_t IDENTIFY_DEVICE = 0x02;
static const DeviceCommandId_t TEMP_SENSOR_ENABLE = 0x03;
static const DeviceCommandId_t ACCURACY_OP_MODE_SET = 0x04;
// This Command is needed to use for lastSentCommand, if there is no
// command set, you have to set this.
static const DeviceCommandId_t NO_COMMAND = 0xffffffff;
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::MGM_LIS3MDL;
//Notifies a command to change the setup parameters
static const Event CHANGE_OF_SETUP_PARAMETER = MAKE_EVENT(0, SEVERITY::LOW);
@ -45,22 +40,24 @@ public:
protected:
/** DeviceHandlerBase overrides */
virtual void doShutDown();
virtual void doStartUp();
virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom);
virtual uint32_t getTransitionDelayMs(Mode_t from, Mode_t to);
virtual void doShutDown() override;
virtual void doStartUp() override;
virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
virtual uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
virtual ReturnValue_t buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
size_t commandDataLen);
virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id);
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id);
virtual ReturnValue_t scanForReply(const uint8_t *start, uint32_t len,
DeviceCommandId_t *foundId, uint32_t *foundLen);
size_t commandDataLen) override;
virtual ReturnValue_t buildTransitionDeviceCommand(
DeviceCommandId_t *id) override;
virtual ReturnValue_t buildNormalDeviceCommand(
DeviceCommandId_t *id) override;
virtual ReturnValue_t scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) override;
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet);
virtual void fillCommandAndReplyMap();
virtual void modeChanged(void);
void setNormalDatapoolEntriesInvalid();
const uint8_t *packet) override;
virtual void fillCommandAndReplyMap() override;
virtual void modeChanged(void) override;
void setNormalDatapoolEntriesInvalid() override;
private:
/*------------------------------------------------------------------------*/
@ -122,12 +119,15 @@ private:
virtual ReturnValue_t setOperatingMode(const uint8_t *commandData,
size_t commandDataLen);
static const uint8_t NR_OF_CTRL_REGISTERS = 5; //Number of all control registers
static const uint8_t NR_OF_REGISTERS = 19; //Number of registers in the MGM
static const uint8_t TOTAL_NR_OF_ADRESSES = 52; //Total number of adresses for all registers
//Number of all control registers
static const uint8_t NR_OF_CTRL_REGISTERS = 5;
//Number of registers in the MGM
static const uint8_t NR_OF_REGISTERS = 19;
//Total number of adresses for all registers
static const uint8_t TOTAL_NR_OF_ADRESSES = 52;
static const uint8_t SETUP_REPLY = 6;
static const uint8_t SINGLE_COMMAND_ANSWER_LEN = 2; //Length a sindgle command SPI answer
//static const uint8_t LIS3MDL_IDENTIFIER = 0b00111101; //Identifier for Device
//Length a sindgle command SPI answer
static const uint8_t SINGLE_COMMAND_ANSWER_LEN = 2;
/*------------------------------------------------------------------------*/
/* Register adresses */
@ -171,13 +171,16 @@ private:
/*------------------------------------------------------------------------*/
/* Initialize Setup Register set bits
/*------------------------------------------------------------------------*/
//general transfer bits
static const uint8_t RW_BIT = 7; //Read=1 / Write=0 Bit
static const uint8_t MS_BIT = 6; //Continous Read/Write Bit, increment adress
/* General transfer bits */
// Read=1 / Write=0 Bit
static const uint8_t RW_BIT = 7;
// Continous Read/Write Bit, increment adress
static const uint8_t MS_BIT = 6;
//CTRL_REG1 bits
/* CTRL_REG1 bits */
static const uint8_t ST = 0; // Self test enable bit, enabled = 1
static const uint8_t FAST_ODR = 1; //Enable rates higher than 80 Hz enabled = 1
// Enable rates higher than 80 Hz enabled = 1
static const uint8_t FAST_ODR = 1;
static const uint8_t DO0 = 2; // Output data rate bit 2
static const uint8_t DO1 = 3; // Output data rate bit 3
static const uint8_t DO2 = 4; // Output data rate bit 4
@ -185,24 +188,27 @@ private:
static const uint8_t OM1 = 6; // XY operating mode bit 6
static const uint8_t TEMP_EN = 7; // Temperature sensor enable enabled = 1
//CTRL_REG2 bits
static const uint8_t SOFT_RST = 2; //reset configuration registers and user registers
/* CTRL_REG2 bits */
//reset configuration registers and user registers
static const uint8_t SOFT_RST = 2;
static const uint8_t REBOOT = 3; //reboot memory content
static const uint8_t FSO = 5; //full-scale selection bit 5
static const uint8_t FS1 = 6; //full-scale selection bit 6
//CTRL_REG3 bits
/* CTRL_REG3 bits */
static const uint8_t MD0 = 0; //Operating mode bit 0
static const uint8_t MD1 = 1; //Operating mode bit 1
static const uint8_t SIM = 2; //SPI serial interface mode selection enabled = 3-wire-mode
//SPI serial interface mode selection enabled = 3-wire-mode
static const uint8_t SIM = 2;
static const uint8_t LP = 5; //low-power mode
//CTRL_REG4 bits
static const uint8_t BLE = 1; //big/little endian data selection enabled = MSb at lower adress
/* CTRL_REG4 bits */
//big/little endian data selection enabled = MSb at lower adress
static const uint8_t BLE = 1;
static const uint8_t OMZ0 = 2; //Z operating mode bit 2
static const uint8_t OMZ1 = 3; //Z operating mode bit 3
//CTRL_REG5 bits
/* CTRL_REG5 bits */
static const uint8_t BDU = 6; //Block data update
static const uint8_t FAST_READ = 7; //Fast read enabled = 1
@ -212,8 +218,8 @@ private:
uint8_t commandBuffer[TOTAL_NR_OF_ADRESSES + 1];
/**
* We want to save the registers we set, so we dont have to read the registers
* when we want to change something
* We want to save the registers we set, so we dont have to read the
* registers when we want to change something.
* --> everytime we change set a register we have to save it
*/
uint8_t registers[NR_OF_CTRL_REGISTERS];
@ -222,7 +228,7 @@ private:
* As this is a SPI Device, we get the Answer of the last sent command in
* the next read cycle, so we could check the command for identification.
*/
DeviceCommandId_t lastSentCommand = 0xffffffff;
DeviceCommandId_t lastSentCommand = DeviceHandlerIF::NO_COMMAND;
/**
* We always update all registers together, so this method updates