//------------------------------------------------------------------------------
tOplkError processEvents(tOplkApiEventType EventType_p,
                         tOplkApiEventArg* pEventArg_p,
                         void* pUserArg_p)
{
    tOplkError          ret = kErrorOk;

    UNUSED_PARAMETER(pUserArg_p);

    switch (EventType_p)
    {
        case kOplkApiEventNmtStateChange:
            ret = processStateChangeEvent(EventType_p, pEventArg_p, pUserArg_p);
            break;

        case kOplkApiEventCriticalError:
        case kOplkApiEventWarning:
            ret = processErrorWarningEvent(EventType_p, pEventArg_p, pUserArg_p);
            break;

        case kOplkApiEventLed:
            /* POWERLINK S/E LED needs to be changed */
            switch (pEventArg_p->ledEvent.ledType)
            {
                case kLedTypeStatus:
                    gpio_setStatusLed(pEventArg_p->ledEvent.fOn);
                    break;

                case kLedTypeError:
                    gpio_setErrorLed(pEventArg_p->ledEvent.fOn);
                    break;

                default:
                    break;
            }
            break;

        default:
            break;
    }

    // call user event call back
    if ((ret == kErrorOk) && (pfnEventCb_l != NULL))
        ret = pfnEventCb_l(EventType_p, pEventArg_p, pUserArg_p);

    return ret;
}
//------------------------------------------------------------------------------
tOplkError processEvents(tOplkApiEventType EventType_p, tOplkApiEventArg* pEventArg_p, void* pUserArg_p)
{
    tOplkError          ret = kErrorOk;

    UNUSED_PARAMETER(pUserArg_p);

    // check if NMT_GS_OFF is reached
    switch (EventType_p)
    {
        case kOplkApiEventNmtStateChange:
            ret = processStateChangeEvent(EventType_p, pEventArg_p, pUserArg_p);
            break;

        case kOplkApiEventCriticalError:
        case kOplkApiEventWarning:
            ret = processErrorWarningEvent(EventType_p, pEventArg_p, pUserArg_p);
            break;

        case kOplkApiEventHistoryEntry:
            ret = processHistoryEvent(EventType_p, pEventArg_p, pUserArg_p);
            break;

        case kOplkApiEventNode:
            ret = processNodeEvent(EventType_p, pEventArg_p, pUserArg_p);
            break;

#ifdef CONFIG_INCLUDE_CFM
        case kOplkApiEventCfmProgress:
            ret = processCfmProgressEvent(EventType_p, pEventArg_p, pUserArg_p);
            break;

        case kOplkApiEventCfmResult:
            ret = processCfmResultEvent(EventType_p, pEventArg_p, pUserArg_p);
            break;
#else
        // Configuration Manager is not available,
        // so process SDO events
        case kOplkApiEventSdo:
            ret = processSdoEvent(EventType_p, pEventArg_p, pUserArg_p);
            break;
#endif

        case kOplkApiEventLed:
            /* POWERLINK S/E LED needs to be changed */
            switch (pEventArg_p->ledEvent.ledType)
            {
                case kLedTypeStatus:
                    gpio_setStatusLed(pEventArg_p->ledEvent.fOn);
                    break;

                case kLedTypeError:
                    gpio_setErrorLed(pEventArg_p->ledEvent.fOn);
                    break;

                default:
                    break;
            }
            break;

        default:
            break;
    }

    // call user event call back
    if ((ret == kErrorOk) && (pfnEventCb_l != NULL))
        ret = pfnEventCb_l(EventType_p, pEventArg_p, pUserArg_p);

    return ret;
}