eive-obsw/linux/ipcore/Ptme.h

84 lines
2.4 KiB
C
Raw Permalink Normal View History

2021-09-19 12:27:48 +02:00
#ifndef LINUX_OBC_PTME_H_
#define LINUX_OBC_PTME_H_
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
2023-03-09 17:44:05 +01:00
#include <linux/ipcore/VirtualChannelIF.h>
2021-09-19 12:27:48 +02:00
#include <cstring>
#include <unordered_map>
2022-01-17 15:58:27 +01:00
#include "OBSWConfig.h"
2022-08-24 17:27:47 +02:00
#include "fsfw/returnvalues/returnvalue.h"
#include "linux/ipcore/PtmeIF.h"
2022-01-17 15:58:27 +01:00
2021-09-19 12:27:48 +02:00
/**
* @brief This class handles the interfacing to the telemetry (PTME) IP core.
*
* @details
* This module is responsible for the encoding of telemetry packets according to the CCSDS
* standards CCSDS 131.0-B-3 (TM Synchronization and channel coding) and CCSDS 132.0-B-2
* (TM Space Data Link Protocoll). The IP cores are implemented on the programmable logic and are
* accessible through the linux UIO driver.
2021-09-19 12:27:48 +02:00
*/
2022-08-24 17:27:47 +02:00
class Ptme : public PtmeIF, public SystemObject {
2022-01-17 15:58:27 +01:00
public:
using VcId_t = uint8_t;
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
/**
* @brief Constructor
*
* @param objectId
*/
Ptme(object_id_t objectId);
virtual ~Ptme();
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
ReturnValue_t initialize() override;
2023-10-13 09:20:51 +02:00
bool containsVc(uint8_t vcId) const override;
VirtualChannelIF* getVirtChannel(uint8_t vcId) override;
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
/**
* @brief This function adds the reference to a virtual channel interface to the vcInterface
* map.
*/
2023-03-09 17:44:05 +01:00
void addVcInterface(VcId_t vcId, VirtualChannelIF* vc);
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
private:
static const uint8_t INTERFACE_ID = CLASS_ID::PTME;
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
static const ReturnValue_t UNKNOWN_VC_ID = MAKE_RETURN_CODE(0xA0);
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
/**
* Configuration bits:
* bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00
* bit[2]: Set this bit to 1 to abort a transfered packet
* bit[3]: Signals to PTME the start of a new telemetry packet
*/
static const uint32_t PTME_CONFIG_START = 0x8;
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
/**
* Writing this word to the ptme base address signals to the PTME that a complete tm packet has
* been transferred.
*/
static const uint32_t PTME_CONFIG_END = 0x0;
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
/**
* Writing to this offset within the PTME memory space will insert data for encoding to the
* PTME IP core.
* The address offset is 0x400 (= 4 * 256)
*/
static const int PTME_DATA_REG_OFFSET = 256;
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
/** The file descriptor of the UIO driver */
int fd = 0;
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
uint32_t* ptmeBaseAddress = nullptr;
2021-09-19 12:27:48 +02:00
2023-03-09 17:44:05 +01:00
using VcInterfaceMap = std::unordered_map<VcId_t, VirtualChannelIF*>;
2022-01-17 15:58:27 +01:00
using VcInterfaceMapIter = VcInterfaceMap::iterator;
2021-09-19 12:27:48 +02:00
2022-01-17 15:58:27 +01:00
VcInterfaceMap vcInterfaceMap;
2021-09-19 12:27:48 +02:00
};
#endif /* LINUX_OBC_PTME_H_ */