2021-07-13 08:32:14 +02:00
|
|
|
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
|
|
|
|
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
#include <fsfw/action/MinMaxParameter.h>
|
|
|
|
#include <fsfw/action/TemplateAction.h>
|
|
|
|
#include <fsfw/introspection/Enum.h>
|
|
|
|
|
2022-03-27 13:07:18 +02:00
|
|
|
#include "MPSoCReturnValuesIF.h"
|
|
|
|
#include "OBSWConfig.h"
|
2022-07-27 22:03:41 +02:00
|
|
|
#include "PlocMPSoCCommonDefinitions.h"
|
2022-03-27 13:07:18 +02:00
|
|
|
#include "eive/definitions.h"
|
2022-03-27 10:44:32 +02:00
|
|
|
#include "fsfw/globalfunctions/CRC.h"
|
|
|
|
#include "fsfw/serialize/SerializeAdapter.h"
|
|
|
|
#include "fsfw/tmtcpacket/SpacePacket.h"
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMPSoCHandler;
|
2022-03-21 16:21:51 +01:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
FSFW_ENUM(PlocMpSoCCommands, DeviceCommandId_t,
|
|
|
|
((NONE, 0, "No Command"))((TC_MEM_WRITE, 1, "Write to Memory"))(
|
|
|
|
(TC_MEM_READ, 2, "Read from Memory"))((ACK_REPORT, 3, ""))((EXE_REPORT, 5, ""))(
|
|
|
|
(TM_MEMORY_READ_REPORT, 6, ""))((TC_FLASHWRITE, 9, "Write Flash"))(
|
|
|
|
(TC_FLASHDELETE, 10, "Delete Flash"))((TC_REPLAY_START, 11, "Start Replay"))(
|
|
|
|
(TC_REPLAY_STOP, 12, "Stop Replay"))((TC_REPLAY_WRITE_SEQUENCE, 13,
|
|
|
|
"Write Sequence"))((TC_DOWNLINK_PWR_ON, 14,
|
|
|
|
"Set Downlink Power On"))(
|
|
|
|
(TC_DOWNLINK_PWR_OFF, 15, "Set Downlink Power Off"))((TC_MODE_REPLAY, 16,
|
|
|
|
"Set Replay Mode"))(
|
|
|
|
(TC_CAM_CMD_SEND, 17, "Set Replay Mode"))((TC_MODE_IDLE, 18, "Set Idle Mode"))(
|
|
|
|
(TM_CAM_CMD_RPT, 19, ""))((SET_UART_TX_TRISTATE, 20, "Set UART TX to Tristate"))(
|
|
|
|
(RELEASE_UART_TX, 21, "Release UART TX"))((OBSW_RESET_SEQ_COUNT, 50,
|
|
|
|
"Reset OBSW Reset Sequence Count")))
|
2022-05-25 18:38:54 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCMemWriteAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCMemWriteAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCMemWriteAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_MEM_WRITE){};
|
2022-03-26 20:47:25 +01:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
Parameter<uint32_t> address = Parameter<uint32_t>::createParameter(this, "Memory Address");
|
|
|
|
Parameter<uint32_t> memoryData = Parameter<uint32_t>::createParameter(this, "Data to be written");
|
2022-01-05 11:26:01 +01:00
|
|
|
};
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCMemReadAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCMemReadAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCMemReadAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_MEM_READ){};
|
2022-01-06 18:05:21 +01:00
|
|
|
};
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCFlashDeleteAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCFlashDeleteAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCFlashDeleteAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_FLASHDELETE){};
|
2022-01-03 08:01:55 +01:00
|
|
|
};
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCReplayStartAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCReplayStartAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCReplayStartAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_REPLAY_START){};
|
2022-01-05 11:26:01 +01:00
|
|
|
};
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCReplayStopAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCReplayStopAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCReplayStopAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_REPLAY_STOP){};
|
2022-01-03 08:01:55 +01:00
|
|
|
};
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCReplayWriteSequenceAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCReplayWriteSequenceAction,
|
|
|
|
PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCReplayWriteSequenceAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE){};
|
2022-03-21 08:35:28 +01:00
|
|
|
};
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCDownlinkPwrOnAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCDownlinkPwrOnAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCDownlinkPwrOnAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_DOWNLINK_PWR_ON){};
|
2022-03-21 16:21:51 +01:00
|
|
|
};
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCDownlinkPwrOffAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCDownlinkPwrOffAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCDownlinkPwrOffAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_DOWNLINK_PWR_OFF){};
|
2022-01-06 10:12:08 +01:00
|
|
|
};
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCModeReplayAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCModeReplayAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCModeReplayAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_MODE_REPLAY){};
|
2022-01-06 18:05:21 +01:00
|
|
|
};
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCCamCmdSendAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCCamCmdSendAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCCamCmdSendAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_CAM_CMD_SEND){};
|
2022-03-21 11:05:41 +01:00
|
|
|
};
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCModeIdleAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCModeIdleAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCModeIdleAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_MODE_IDLE){};
|
|
|
|
};
|
2022-03-26 20:47:25 +01:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCFlashWriteAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCFlashWriteAction, PlocMpSoCCommands> {
|
|
|
|
public:
|
|
|
|
PlocMpSoCFlashWriteAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::TC_FLASHWRITE){};
|
|
|
|
};
|
2022-03-26 20:47:25 +01:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCUartTxTristateAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCUartTxTristateAction, PlocMpSoCCommands> {
|
|
|
|
public:
|
|
|
|
PlocMpSoCUartTxTristateAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::SET_UART_TX_TRISTATE){};
|
2022-03-21 16:21:51 +01:00
|
|
|
};
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCReleaseUartTxAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCReleaseUartTxAction, PlocMpSoCCommands> {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCReleaseUartTxAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::RELEASE_UART_TX){};
|
|
|
|
};
|
2022-03-21 16:21:51 +01:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
class PlocMpSoCObswResetSeqCountAction
|
|
|
|
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCObswResetSeqCountAction, PlocMpSoCCommands> {
|
|
|
|
public:
|
|
|
|
PlocMpSoCObswResetSeqCountAction(PlocMPSoCHandler *owner)
|
|
|
|
: TemplateAction(owner, PlocMpSoCCommands::OBSW_RESET_SEQ_COUNT){};
|
2022-03-21 16:21:51 +01:00
|
|
|
};
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
namespace mpsoc {
|
|
|
|
|
2022-03-21 16:21:51 +01:00
|
|
|
/**
|
2022-07-27 22:03:41 +02:00
|
|
|
* @brief This class helps to generate the space packet to write data to a memory address within
|
|
|
|
* the PLOC.
|
2022-03-21 16:21:51 +01:00
|
|
|
*/
|
2022-07-27 22:03:41 +02:00
|
|
|
class TcMemWrite : public TcBase {
|
2022-03-26 20:47:25 +01:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief Constructor
|
|
|
|
*/
|
2022-07-27 22:03:41 +02:00
|
|
|
TcMemWrite(uint16_t sequenceCount) : TcBase(apid::TC_MEM_WRITE, sequenceCount) {}
|
2022-03-26 20:47:25 +01:00
|
|
|
|
|
|
|
protected:
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t initPacket(void *actionIn) {
|
|
|
|
auto action = dynamic_cast<PlocMpSoCMemWriteAction *>(actionIn);
|
2022-03-26 20:47:25 +01:00
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
2022-07-27 22:03:41 +02:00
|
|
|
// faking until framework code is ready
|
|
|
|
// uint16_t length = action->memoryData.length;
|
|
|
|
uint16_t dataLength = 1;
|
|
|
|
result = lengthCheck(dataLength);
|
2022-03-26 20:47:25 +01:00
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
uint8_t *pointer = this->localData.fields.buffer;
|
|
|
|
size_t size = 0;
|
|
|
|
size_t maxSize = PACKET_MAX_SIZE;
|
|
|
|
SerializeAdapter::serialize(&action->address.value, &pointer, &size, maxSize,
|
|
|
|
SerializeIF::Endianness::BIG);
|
|
|
|
SerializeAdapter::serialize(&dataLength, &pointer, &size, maxSize,
|
|
|
|
SerializeIF::Endianness::BIG);
|
|
|
|
std::memcpy(pointer, &action->memoryData.value, dataLength);
|
|
|
|
this->setPacketDataLength(dataLength * sizeof(action->memoryData.value) + FIX_LENGTH - 1);
|
2022-03-26 20:47:25 +01:00
|
|
|
return result;
|
|
|
|
}
|
2022-03-21 16:21:51 +01:00
|
|
|
|
2022-03-26 20:47:25 +01:00
|
|
|
private:
|
2022-07-27 22:03:41 +02:00
|
|
|
// Min length consists of 4 byte data (1 word)
|
|
|
|
static const size_t MIN_COMMAND_DATA_LENGTH = 1;
|
|
|
|
static const size_t FIX_LENGTH = 8;
|
2022-03-21 16:21:51 +01:00
|
|
|
|
2022-03-26 20:47:25 +01:00
|
|
|
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
2022-07-27 22:03:41 +02:00
|
|
|
if (commandDataLen < MIN_COMMAND_DATA_LENGTH) {
|
|
|
|
sif::warning << "TcMemWrite: Command has invalid length " << commandDataLen << std::endl;
|
2022-04-22 14:09:08 +02:00
|
|
|
return INVALID_LENGTH;
|
|
|
|
}
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
2022-04-20 21:33:39 +02:00
|
|
|
};
|
2022-03-26 20:47:25 +01:00
|
|
|
} // namespace mpsoc
|
2021-07-13 08:32:14 +02:00
|
|
|
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */
|