ptme bridge wip
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user