integration complete
This commit is contained in:
@@ -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,40 +171,46 @@ 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
|
||||
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
|
||||
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
|
||||
static const uint8_t OM0 = 5; //XY operating mode bit 5
|
||||
static const uint8_t OM1 = 6; //XY operating mode bit 6
|
||||
static const uint8_t TEMP_EN = 7; //Temperature sensor enable enabled = 1
|
||||
/* CTRL_REG1 bits */
|
||||
static const uint8_t ST = 0; // Self test enable bit, 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
|
||||
static const uint8_t OM0 = 5; // XY operating mode bit 5
|
||||
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
|
||||
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_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
|
||||
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
|
||||
static const uint8_t LP = 5; //low-power mode
|
||||
/* CTRL_REG3 bits */
|
||||
static const uint8_t MD0 = 0; //Operating mode bit 0
|
||||
static const uint8_t MD1 = 1; //Operating mode bit 1
|
||||
//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
|
||||
static const uint8_t OMZ0 = 2; //Z operating mode bit 2
|
||||
static const uint8_t OMZ1 = 3; //Z operating mode bit 3
|
||||
/* 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
|
||||
static const uint8_t BDU = 6; //Block data update
|
||||
static const uint8_t FAST_READ = 7; //Fast read enabled = 1
|
||||
/* CTRL_REG5 bits */
|
||||
static const uint8_t BDU = 6; //Block data update
|
||||
static const uint8_t FAST_READ = 7; //Fast read enabled = 1
|
||||
|
||||
//Single SPIcommand has 2 bytes, first for adress, second for content
|
||||
size_t singleComandSize = 2;
|
||||
@@ -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
|
||||
|
Reference in New Issue
Block a user