nvm enable command

This commit is contained in:
2022-05-05 19:18:39 +02:00
parent 9bd5595999
commit 5911ca79b5
3 changed files with 75 additions and 19 deletions

View File

@ -55,15 +55,16 @@ static const DeviceCommandId_t LOGGING_CLEAR_COUNTERS = 55;
static const DeviceCommandId_t LOGGING_SET_TOPIC = 56;
static const DeviceCommandId_t REQUEST_ADC_REPORT = 57;
static const DeviceCommandId_t RESET_PL = 58;
static const DeviceCommandId_t ENABLE_NVMS = 59;
/** Reply IDs */
static const DeviceCommandId_t ACK_REPORT = 50;
static const DeviceCommandId_t EXE_REPORT = 51;
static const DeviceCommandId_t HK_REPORT = 52;
static const DeviceCommandId_t BOOT_STATUS_REPORT = 53;
static const DeviceCommandId_t LATCHUP_REPORT = 54;
static const DeviceCommandId_t LOGGING_REPORT = 55;
static const DeviceCommandId_t ADC_REPORT = 56;
static const DeviceCommandId_t ACK_REPORT = 100;
static const DeviceCommandId_t EXE_REPORT = 101;
static const DeviceCommandId_t HK_REPORT = 102;
static const DeviceCommandId_t BOOT_STATUS_REPORT = 103;
static const DeviceCommandId_t LATCHUP_REPORT = 104;
static const DeviceCommandId_t LOGGING_REPORT = 105;
static const DeviceCommandId_t ADC_REPORT = 106;
// Size of complete space packet (6 byte header + size of data + 2 byte CRC)
static const uint16_t SIZE_ACK_REPORT = 14;
@ -122,6 +123,7 @@ static const uint16_t APID_SET_ADC_THRESHOLD = 0xE3;
static const uint16_t APID_GET_LATCHUP_STATUS_REPORT = 0xD9;
static const uint16_t APID_COPY_ADC_DATA_TO_MRAM = 0xDA;
static const uint16_t APID_REQUEST_ADC_REPORT = 0xDB;
static const uint16_t APID_ENABLE_NVMS = 0xF0;
static const uint16_t APID_RUN_AUTO_EM_TESTS = 0xF2;
static const uint16_t APID_WIPE_MRAM = 0xF3;
static const uint16_t APID_DUMP_MRAM = 0xF4;
@ -357,6 +359,50 @@ class MPSoCBootSelect : public SpacePacket {
}
};
/**
* @brief This class creates the command to enable or disable the NVMs connected to the
* supervisor.
*/
class EnableNvms : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param mem The memory to boot from: NVM0 (0), NVM1 (1)
* @param bp0 Partition pin 0
* @param bp1 Partition pin 1
* @param bp2 Partition pin 2
*/
EnableNvms(uint8_t nvm01, uint8_t nvm3)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, DEFAULT_SEQUENCE_COUNT),
nvm01(nvm01),
nvm3(nvm3) {
initPacket();
}
private:
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint8_t DATA_FIELD_LENGTH = 4;
static const uint8_t CRC_OFFSET = 2;
uint8_t nvm01 = 0;
uint8_t nvm3 = 0;
void initPacket() {
*(this->localData.fields.buffer) = nvm01;
*(this->localData.fields.buffer + 1) = nvm3;
/* Calculate crc */
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
/* Add crc to packet data field of space packet */
size_t serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief This class generates the space packet to update the time of the PLOC supervisor.
*/
@ -1664,13 +1710,7 @@ class BootStatusReport : public StaticLocalDataSet<BOOT_REPORT_SET_ENTRIES> {
*/
class HkSet : public StaticLocalDataSet<HK_SET_ENTRIES> {
public:
enum class SocState {
OFF = 0,
BOOTING = 1,
OPERATIONAL = 3,
SHUTDOWN = 4
};
enum class SocState { OFF = 0, BOOTING = 1, OPERATIONAL = 3, SHUTDOWN = 4 };
HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {}