コード例 #1
0
//------------------------------------------------------------------------------
tOplkError pdoucal_getRxPdo(BYTE** ppPdo_p, UINT channelId_p, WORD pdoSize_p)
{
    OPLK_ATOMIC_T    readBuf;
    UNUSED_PARAMETER(pdoSize_p);    // Used to avoid compiler warning if OPLK_DCACHE_INVALIDATE is not set

    // Invalidate data cache for addressed txChannelInfo
    OPLK_DCACHE_INVALIDATE(&(pPdoMem_l->rxChannelInfo[channelId_p]), sizeof(tPdoBufferInfo));

    if (pPdoMem_l->rxChannelInfo[channelId_p].newData)
    {
        readBuf = pPdoMem_l->rxChannelInfo[channelId_p].readBuf;
        OPLK_ATOMIC_EXCHANGE(&pPdoMem_l->rxChannelInfo[channelId_p].cleanBuf,
                             readBuf,
                             pPdoMem_l->rxChannelInfo[channelId_p].readBuf);
        pPdoMem_l->rxChannelInfo[channelId_p].newData = 0;

        // Flush data cache for variables changed in this function
        OPLK_DCACHE_FLUSH(&(pPdoMem_l->rxChannelInfo[channelId_p].readBuf), sizeof(OPLK_ATOMIC_T));
        OPLK_DCACHE_FLUSH(&(pPdoMem_l->rxChannelInfo[channelId_p].newData), sizeof(UINT8));
    }

    readBuf = pPdoMem_l->rxChannelInfo[channelId_p].readBuf;
    *ppPdo_p = pTripleBuf_l[readBuf] + pPdoMem_l->rxChannelInfo[channelId_p].channelOffset;

    OPLK_DCACHE_INVALIDATE(*ppPdo_p, pdoSize_p);

    return kErrorOk;
}
コード例 #2
0
ファイル: timesyncu.c プロジェクト: Questio/openPOWERLINK_V2
//------------------------------------------------------------------------------
static tTimesyncSocTime* getSocTime(void)
{
    tTimesyncSocTimeTripleBuf*  pTripleBuf;
    OPLK_ATOMIC_T               readBuf;

    pTripleBuf = &pSharedMemory_l->socTime;

    OPLK_DCACHE_INVALIDATE(pTripleBuf, sizeof(*pTripleBuf));

    if (pTripleBuf->newData)
    {
        // Switch triple buffer because there is new data available!
        readBuf = pTripleBuf->read;
        OPLK_ATOMIC_EXCHANGE(&pTripleBuf->clean, readBuf, pTripleBuf->read);

        pTripleBuf->newData = 0;

        OPLK_DCACHE_FLUSH(&pTripleBuf->clean, sizeof(pTripleBuf->clean));
        OPLK_DCACHE_FLUSH(&pTripleBuf->read, sizeof(pTripleBuf->read));
        OPLK_DCACHE_FLUSH(&pTripleBuf->newData, sizeof(pTripleBuf->newData));
    }

    readBuf = pTripleBuf->read;

    // Return reference to read buffer
    return &pTripleBuf->aTripleBuf[readBuf];
}
コード例 #3
0
//------------------------------------------------------------------------------
void errhndkcal_getMnCycTimeExceedThresholdCnt(UINT32* pThresholdCnt_p)
{
    // Check parameter validity
    ASSERT(pThresholdCnt_p != NULL);

    OPLK_DCACHE_INVALIDATE(&pErrHndObjects_l->mnCycTimeExceed, sizeof(tErrorObject));

    *pThresholdCnt_p = pErrHndObjects_l->mnCycTimeExceed.thresholdCnt;
}
コード例 #4
0
//------------------------------------------------------------------------------
void errhndkcal_getCnCrcThresholdCnt(UINT32* pThresholdCnt_p)
{
    // Check parameter validity
    ASSERT(pThresholdCnt_p != NULL);

    OPLK_DCACHE_INVALIDATE(&pErrHndObjects_l->cnCrcErr, sizeof(tErrorObject));

    *pThresholdCnt_p = pErrHndObjects_l->cnCrcErr.thresholdCnt;
}
コード例 #5
0
//------------------------------------------------------------------------------
void errhndkcal_getMnCnLossPresThresholdCnt(UINT nodeIdx_p,
                                            UINT32* pThresholdCnt_p)
{
    // Check parameter validity
    ASSERT(pThresholdCnt_p != NULL);

    OPLK_DCACHE_INVALIDATE(&pErrHndObjects_l->aMnCnLossPres[nodeIdx_p], sizeof(tErrorObject));

    *pThresholdCnt_p = pErrHndObjects_l->aMnCnLossPres[nodeIdx_p].thresholdCnt;
}
コード例 #6
0
//------------------------------------------------------------------------------
BYTE* pdoucal_getTxPdoAdrs(UINT channelId_p)
{
    OPLK_ATOMIC_T    wi;
    BYTE*            pPdo;

    // Invalidate data cache for addressed txChannelInfo
    OPLK_DCACHE_INVALIDATE(&(pPdoMem_l->txChannelInfo[channelId_p]), sizeof(tPdoBufferInfo));

    wi = pPdoMem_l->txChannelInfo[channelId_p].writeBuf;
    //TRACE("%s() channelId:%d wi:%d\n", __func__, channelId_p, wi);
    pPdo = pTripleBuf_l[wi] + pPdoMem_l->txChannelInfo[channelId_p].channelOffset;
    return pPdo;
}
コード例 #7
0
//------------------------------------------------------------------------------
void errhndkcal_getMnCrcError(UINT32* pCumulativeCnt_p,
                              UINT32* pThresholdCnt_p,
                              UINT32* pThreshold_p)
{
    // Check parameter validity
    ASSERT(pCumulativeCnt_p != NULL);
    ASSERT(pThresholdCnt_p != NULL);
    ASSERT(pThreshold_p != NULL);

    OPLK_DCACHE_INVALIDATE(&pErrHndObjects_l->mnCrcErr, sizeof(tErrorObject));

    *pCumulativeCnt_p = pErrHndObjects_l->mnCrcErr.cumulativeCnt;
    *pThresholdCnt_p = pErrHndObjects_l->mnCrcErr.thresholdCnt;
    *pThreshold_p = pErrHndObjects_l->mnCrcErr.threshold;
}
コード例 #8
0
//------------------------------------------------------------------------------
tOplkError timesynck_setSocTime(const tTimesyncSocTime* pSocTime_p)
{
    tTimesyncSocTimeTripleBuf*  pTripleBuf;
    OPLK_ATOMIC_T               writeBuf;
    tTimesyncSocTime*           pBuffer;

    // Check parameter validity
    ASSERT(pSocTime_p != NULL);

    if (timesynckInstance_l.pSharedMemory == NULL)
    {
        // Looks like the CAL has no SoC time forward support, but feature is
        // enabled!
        DEBUG_LVL_ERROR_TRACE("%s Pointer to shared memory is invalid!\n",
                              __func__);
        return kErrorNoResource;
    }

    pTripleBuf = &timesynckInstance_l.pSharedMemory->kernelToUserSocTime;

    OPLK_DCACHE_INVALIDATE(pTripleBuf, sizeof(*pTripleBuf));

    writeBuf = pTripleBuf->write;
    pBuffer = &pTripleBuf->aTripleBuf[writeBuf];

    OPLK_MEMCPY(pBuffer, pSocTime_p, sizeof(*pBuffer));

    OPLK_ATOMIC_EXCHANGE(&pTripleBuf->clean, writeBuf, pTripleBuf->write);

    pTripleBuf->newData = 1;

    OPLK_DCACHE_FLUSH(&pTripleBuf->clean, sizeof(pTripleBuf->clean));
    OPLK_DCACHE_FLUSH(&pTripleBuf->write, sizeof(pTripleBuf->write));
    OPLK_DCACHE_FLUSH(&pTripleBuf->newData, sizeof(pTripleBuf->newData));

    return kErrorOk;
}
//------------------------------------------------------------------------------
tOplkError pdoucal_setTxPdo(UINT8 channelId_p,
                            void* pPdo_p,
                            size_t pdoSize_p)
{
    OPLK_ATOMIC_T    temp;

    UNUSED_PARAMETER(pPdo_p);       // Used to avoid compiler warning if OPLK_DCACHE_FLUSH is not set
    UNUSED_PARAMETER(pdoSize_p);    // Used to avoid compiler warning if OPLK_DCACHE_FLUSH is not set

    OPLK_DCACHE_FLUSH(pPdo_p, pdoSize_p);

    DEBUG_LVL_PDO_TRACE("%s() chan:%d wi:%d\n",
                        __func__,
                        channelId_p,
                        pPdoMem_l->txChannelInfo[channelId_p].writeBuf);

    // Invalidate data cache already done in pdoucal_getTxPdoAdrs()
    OPLK_DCACHE_INVALIDATE(&pPdoMem_l->txChannelInfo[channelId_p],
                           sizeof(tPdoBufferInfo));
    temp = pPdoMem_l->txChannelInfo[channelId_p].writeBuf;
    OPLK_ATOMIC_EXCHANGE(&pPdoMem_l->txChannelInfo[channelId_p].cleanBuf,
                         temp,
                         pPdoMem_l->txChannelInfo[channelId_p].writeBuf);
    pPdoMem_l->txChannelInfo[channelId_p].newData = 1;

    // Flush data cache for variables changed in this function
    OPLK_DCACHE_FLUSH(&pPdoMem_l->txChannelInfo[channelId_p],
                      sizeof(tPdoBufferInfo));

    DEBUG_LVL_PDO_TRACE("%s() chan:%d new wi:%d\n",
                        __func__,
                        channelId_p,
                        pPdoMem_l->txChannelInfo[channelId_p].writeBuf);

    return kErrorOk;
}