This commit is contained in:
@ -26,20 +26,20 @@ ReturnValue_t PapbVcInterface::initialize() {
|
||||
}
|
||||
|
||||
ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) {
|
||||
if (pollPapbBusySignal(0, 0) == returnvalue::OK) {
|
||||
if (pollPapbBusySignal(0) == returnvalue::OK) {
|
||||
startPacketTransfer();
|
||||
} else {
|
||||
return DirectTmSinkIF::IS_BUSY;
|
||||
}
|
||||
for (size_t idx = 0; idx < size; idx++) {
|
||||
if (pollPapbBusySignal(10, 10) == returnvalue::OK) {
|
||||
if (pollPapbBusySignal(5) == returnvalue::OK) {
|
||||
*(vcBaseReg + DATA_REG_OFFSET) = static_cast<uint32_t>(data[idx]);
|
||||
} else {
|
||||
abortPacketTransfer();
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
}
|
||||
if (pollPapbBusySignal(10, 10) == returnvalue::OK) {
|
||||
if (pollPapbBusySignal(5) == returnvalue::OK) {
|
||||
completePacketTransfer();
|
||||
} else {
|
||||
abortPacketTransfer();
|
||||
@ -52,11 +52,11 @@ void PapbVcInterface::startPacketTransfer() { *vcBaseReg = CONFIG_START; }
|
||||
|
||||
void PapbVcInterface::completePacketTransfer() { *vcBaseReg = CONFIG_END; }
|
||||
|
||||
ReturnValue_t PapbVcInterface::pollPapbBusySignal(uint32_t maxPollRetries,
|
||||
uint32_t retryDelayUs) const {
|
||||
ReturnValue_t PapbVcInterface::pollPapbBusySignal(uint32_t maxPollRetries) const {
|
||||
gpio::Levels papbBusyState = gpio::Levels::LOW;
|
||||
ReturnValue_t result;
|
||||
uint32_t busyIdx = 0;
|
||||
uint32_t nextDelay = 1;
|
||||
|
||||
while (true) {
|
||||
/** Check if PAPB interface is ready to receive data */
|
||||
@ -75,7 +75,10 @@ ReturnValue_t PapbVcInterface::pollPapbBusySignal(uint32_t maxPollRetries,
|
||||
return PAPB_BUSY;
|
||||
}
|
||||
|
||||
usleep(retryDelayUs);
|
||||
usleep(nextDelay);
|
||||
if (nextDelay * 2 <= MAX_DELAY_PAPB_POLLING_US) {
|
||||
nextDelay *= 2;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
@ -100,7 +103,7 @@ void PapbVcInterface::isVcInterfaceBufferEmpty() {
|
||||
return;
|
||||
}
|
||||
|
||||
bool PapbVcInterface::isBusy() const { return pollPapbBusySignal(0, 0) == PAPB_BUSY; }
|
||||
bool PapbVcInterface::isBusy() const { return pollPapbBusySignal(0) == PAPB_BUSY; }
|
||||
|
||||
void PapbVcInterface::cancelTransfer() { abortPacketTransfer(); }
|
||||
|
||||
|
@ -76,6 +76,8 @@ class PapbVcInterface : public VirtualChannelIF {
|
||||
*/
|
||||
static const int DATA_REG_OFFSET = 256;
|
||||
|
||||
static constexpr uint32_t MAX_DELAY_PAPB_POLLING_US = 4;
|
||||
|
||||
LinuxLibgpioIF* gpioComIF = nullptr;
|
||||
|
||||
/** Pulled to low when virtual channel not ready to receive data */
|
||||
@ -111,7 +113,7 @@ class PapbVcInterface : public VirtualChannelIF {
|
||||
*
|
||||
* @return returnvalue::OK when ready to receive data else PAPB_BUSY.
|
||||
*/
|
||||
ReturnValue_t pollPapbBusySignal(uint32_t maxPollRetries, uint32_t retryDelayUs) const;
|
||||
ReturnValue_t pollPapbBusySignal(uint32_t maxPollRetries) const;
|
||||
|
||||
/**
|
||||
* @brief This function can be used for debugging to check whether there are packets in
|
||||
|
Reference in New Issue
Block a user