ptme bridge wip

This commit is contained in:
Jakob Meier 2021-05-27 13:07:57 +02:00
parent 9c0045dbd9
commit d60bf5e037
6 changed files with 100 additions and 84 deletions

@ -1 +1 @@
Subproject commit 6341da22123166ac5fafdbc09e823d7464f769e5
Subproject commit 7724fdc389c48fc3c52ba94c7c7d9fe4530f1996

View File

@ -24,6 +24,7 @@ debugging. */
#define TEST_SUS_HANDLER 1
#define TEST_PLOC_HANDLER 0
#define TEST_CCSDS_BRIDGE 1
#define PERFORM_PTME_TEST 1
#define TE0720 1
#define TE0720_HEATER_TEST 0

View File

@ -26,7 +26,8 @@ ReturnValue_t CCSDSIPCoreBridge::initialize() {
* Map uio device in virtual address space
* PROT_WRITE: Map uio device in writable only mode
*/
ptmeBaseAddress = mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
ptmeBaseAddress = static_cast<uint32_t*>(mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0));
if (ptmeBaseAddress == MAP_FAILED) {
sif::error << "CCSDSIPCoreBridge::initialize: Failed to map uio address" << std::endl;
@ -38,6 +39,86 @@ ReturnValue_t CCSDSIPCoreBridge::initialize() {
ReturnValue_t CCSDSIPCoreBridge::handleTm() {
#if PERFORM_PTME_TEST == 1
return sendTestFrame();
#else
return TmTcBridge::handleTm();
#endif
}
ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t * data, size_t dataLen) {
if(pollPapbBusySignal() == RETURN_OK) {
startPacketTransfer();
}
for(size_t idx = 0; idx < dataLen; idx++) {
if(pollPapbBusySignal() == RETURN_OK) {
*(ptmeBaseAddress + PTME_DATA_REG_OFFSET) = static_cast<uint32_t>(*(data + idx));
}
else {
sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen
<< " data" << std::endl;
return RETURN_FAILED;
}
}
if(pollPapbBusySignal() == RETURN_OK) {
endPacketTransfer();
}
return RETURN_OK;
}
void CCSDSIPCoreBridge::startPacketTransfer() {
*ptmeBaseAddress = PTME_CONFIG_START;
}
void CCSDSIPCoreBridge::endPacketTransfer() {
*ptmeBaseAddress = PTME_CONFIG_END;
}
ReturnValue_t CCSDSIPCoreBridge::pollPapbBusySignal() {
int papbBusyState = 0;
ReturnValue_t result = RETURN_OK;
/** Check if PAPB interface is ready to receive data */
result = gpioComIF->readGpio(papbBusyId, &papbBusyState);
if (result != RETURN_OK) {
sif::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: Failed to read papb busy signal"
<< std::endl;
return RETURN_FAILED;
}
if (!papbBusyState) {
sif::debug << "CCSDSIPCoreBridge::pollPapbBusySignal: PAPB busy" << std::endl;
return PAPB_BUSY;
}
return RETURN_OK;
}
void CCSDSIPCoreBridge::isPtmeBufferEmpty() {
ReturnValue_t result = RETURN_OK;
int papbEmptyState = 1;
result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState);
if (result != RETURN_OK) {
sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Failed to read papb empty signal"
<< std::endl;
return;
}
if (papbEmptyState == 1) {
sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is empty" << std::endl;
}
else {
sif::debug << "CCSDSIPCoreBridge::isPtmeBufferEmpty: Buffer is not empty" << std::endl;
}
return;
}
ReturnValue_t CCSDSIPCoreBridge::sendTestFrame() {
/** Size of one complete transfer frame data field amounts to 1105 bytes */
uint8_t testPacket[1105];
@ -50,79 +131,6 @@ ReturnValue_t CCSDSIPCoreBridge::handleTm() {
if(result != RETURN_OK) {
return result;
}
return RETURN_OK;
}
ReturnValue_t CCSDSIPCoreBridge::sendTm(const uint8_t * data, size_t dataLen) {
if(pollPapbSignal() == RETURN_OK) {
ptmeBufferEmpty();
startPacketTransfer();
}
for(size_t idx = 0; idx < dataLen; idx++) {
if(pollPapbSignal() == RETURN_OK) {
*(static_cast<uint32_t*>(ptmeBaseAddress) + PTME_DATA_REG_OFFSET) =
static_cast<uint32_t>(*(data + idx));
}
else {
sif::debug << "CCSDSIPCoreBridge::sendTm: Only written " << idx - 1 << " of " << dataLen
<< " data" << std::endl;
return RETURN_FAILED;
}
}
if(pollPapbSignal() == RETURN_OK) {
ptmeBufferEmpty();
endPacketTransfer();
}
return RETURN_OK;
}
void CCSDSIPCoreBridge::startPacketTransfer() {
*(static_cast<uint32_t*>(ptmeBaseAddress)) = PTME_CONFIG_START;
}
void CCSDSIPCoreBridge::endPacketTransfer() {
*(static_cast<uint32_t*>(ptmeBaseAddress)) = PTME_CONFIG_END;
}
ReturnValue_t CCSDSIPCoreBridge::pollPapbSignal() {
int papbBusyState = 0;
ReturnValue_t result = RETURN_OK;
/** Check if PAPB interface is ready to receive data */
result = gpioComIF->readGpio(papbBusyId, &papbBusyState);
if (result != RETURN_OK) {
sif::debug << "CCSDSIPCoreBridge::pollPapbSignal: Failed to read papb busy signal"
<< std::endl;
return RETURN_FAILED;
}
if (!papbBusyState) {
sif::debug << "CCSDSIPCoreBridge::pollPapbSignal: PAPB busy" << std::endl;
return PAPB_BUSY;
}
return RETURN_OK;
}
void CCSDSIPCoreBridge::ptmeBufferEmpty() {
ReturnValue_t result = RETURN_OK;
int papbEmptyState = 1;
result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState);
if (result != RETURN_OK) {
sif::debug << "CCSDSIPCoreBridge::ptmeBufferEmpty: Failed to read papb empty signal"
<< std::endl;
return;
}
if (papbEmptyState == 1) {
sif::debug << "CCSDSIPCoreBridge::ptmeBufferEmpty: Buffer is empty" << std::endl;
}
else {
sif::debug << "CCSDSIPCoreBridge::ptmeBufferEmpty: Buffer is not empty" << std::endl;
}
return;
}

View File

@ -5,6 +5,7 @@
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
#include <string.h>
#include "OBSWConfig.h"
/**
* @brief This class handles the interfacing to the telemetry (PTME) and telecommand (PDEC) IP
@ -38,8 +39,8 @@ public:
protected:
/**
* Overwriting this function for testing purpose. Function is periodically called in
* performOperation.
* Overwriting this function to provide the capability of testing the PTME IP Core
* implementation.
*/
virtual ReturnValue_t handleTm() override;
@ -73,8 +74,9 @@ private:
/**
* 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 = 0x400;
static const int PTME_DATA_REG_OFFSET = 256;
LinuxLibgpioIF* gpioComIF = nullptr;
@ -90,8 +92,7 @@ private:
/** The file descriptor of the UIO driver */
int fd;
/** PTME base address */
void* ptmeBaseAddress = nullptr;
uint32_t* ptmeBaseAddress = nullptr;
/**
* @brief This function sends the config byte to the PTME IP Core to initiate a packet
@ -111,13 +112,19 @@ private:
*
* @return RETURN_OK when ready to receive data else PAPB_BUSY.
*/
ReturnValue_t pollPapbSignal();
ReturnValue_t pollPapbBusySignal();
/**
* @brief This function can be used for debugging to check wheter there are packets in
* the packet buffer of the PTME or not.
*/
void ptmeBufferEmpty();
void isPtmeBufferEmpty();
/**
* @brief This function sends a complete telemetry transfer frame data field (1105 bytes)
* to the input of the PTME IP Core. Can be used to test the implementation.
*/
ReturnValue_t sendTestFrame();
};
#endif /* MISSION_OBC_CCSDSIPCOREBRIDGE_H_ */

2
thirdparty/etl vendored

@ -1 +1 @@
Subproject commit c308dc427b7a34e54f33860fb2e244564b2740b4
Subproject commit 0efecca700c6d0847f91b5540638571ba298c793

2
tmtc

@ -1 +1 @@
Subproject commit 06750809cb52044392e0683896538a652f11a512
Subproject commit 574a3e92074d9d4d0335dad3ddc5962e1369f5d5