static DSL_int_t DSL_DRV_LED_Sim( DSL_DRV_ThreadParams_t *param) { DSL_int_t nOsRet = 0; DSL_Error_t nErrCode = DSL_SUCCESS; DSL_Context_t *pContext = (DSL_Context_t *)param->nArg1; DSL_uint16_t nPollTimeout = 0; /* begin polling ... */ stop_led_module = 0; nPollTimeout = pContext->nDataLedSimControlData.nBlinkTimeout; while (!stop_led_module) { DSL_DRV_WAIT_EVENT_TIMEOUT(pContext->dataLedSimEvent, nPollTimeout); if (pContext->nDataLedSimControlData.nLedBehavior == DAL_DATA_LED_BLINK) { /* Trigger Data LED to blink*/ DSL_DRV_LED_Flash(); } nPollTimeout = pContext->nDataLedSimControlData.nBlinkTimeout; } nOsRet = DSL_DRV_ErrorToOS(nErrCode); DSL_DEBUG(DSL_DBG_MSG, (pContext, "DSL[%02d]: OUT - DSL_DRV_LED_Poll thread"DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); return nOsRet; }
static DSL_int_t DSL_CEOC_Thread(DSL_DRV_ThreadParams_t *param) { DSL_Error_t nErrCode = DSL_SUCCESS; DSL_int_t nOsRet = 0; DSL_Context_t *pContext = (DSL_Context_t*)param->nArg1; DSL_LineStateValue_t nCurrentState = DSL_LINESTATE_UNKNOWN; DSL_CEOC_Message_t ceocMsg; DSL_uint16_t protIdent = 0x0; /* Check DSL CPE context pointer*/ if( pContext == DSL_NULL || DSL_CEOC_CONTEXT(pContext) == DSL_NULL ) return -1; /* Check if the CEOC was initialized*/ if( DSL_CEOC_CONTEXT(pContext)->bInit != DSL_TRUE ) { DSL_DEBUG(DSL_DBG_ERR, (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module not initialized!" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); return -1; } DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun = DSL_TRUE; DSL_DEBUG(DSL_DBG_MSG, (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC thread started"DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); /* main CEOC module Task*/ while( DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun ) { DSL_DRV_WAIT_EVENT_TIMEOUT( DSL_CEOC_CONTEXT(pContext)->ceocThread.waitEvent, DSL_CEOC_CONTEXT(pContext)->ceocThread.nThreadPollTime); if (DSL_DRV_SIGNAL_PENDING) break; /* Only proceed if the specified line is in SHOWTIME state*/ DSL_CTX_READ_SCALAR(pContext, nErrCode, nLineState, nCurrentState); /* Only proceed if the specified line is in SHOWTIME state*/ if ((nCurrentState != DSL_LINESTATE_SHOWTIME_TC_SYNC) && (nCurrentState != DSL_LINESTATE_SHOWTIME_NO_SYNC)) { continue; } /* Clear message length*/ ceocMsg.length = 0x0; if( DSL_CEOC_DEV_MessageReceive(pContext, &protIdent, &ceocMsg) < DSL_SUCCESS ) { DSL_DEBUG(DSL_DBG_ERR, (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC message receive failed!" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); nErrCode = DSL_ERROR; break; } if( !ceocMsg.length ) { /* No data available, continue polling*/ continue; } /* EOC message available. Write the received message to the internal FIFO*/ if( DSL_CEOC_FifoMessageWrite(pContext, protIdent, &ceocMsg) < DSL_SUCCESS ) { DSL_DEBUG(DSL_DBG_ERR, (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC message write failed!"DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); nErrCode = DSL_ERROR; break; } /* Proceed message for the Internal CEOC API*/ #ifdef INCLUDE_DSL_CEOC_INTERNAL_API if( DSL_CEOC_CallbackHandle(pContext,protIdent,&ceocMsg) < DSL_SUCCESS ) { DSL_DEBUG(DSL_DBG_ERR, (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CallBack Handle failed!!" DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); nErrCode = DSL_ERROR; break; } #endif } /* Clear CEOC module bRun flag*/ DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun = DSL_FALSE; nOsRet = DSL_DRV_ErrorToOS(nErrCode); DSL_DEBUG(DSL_DBG_MSG, (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC thread stoped"DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); return nOsRet; }
/* Led Thread Main function */ static DSL_int_t DSL_DRV_LED_Poll( DSL_DRV_ThreadParams_t *param) { DSL_uint32_t flags = 0; DSL_int_t nOsRet = 0; DSL_Error_t nErrCode = DSL_SUCCESS; DSL_Context_t *pContext = (DSL_Context_t *)param->nArg1; DSL_LineStateValue_t nCurrentState = DSL_LINESTATE_UNKNOWN; /* begin polling ... */ stop_led_module = 0; while (!stop_led_module) { /* Wake up every 10s */ while (!(stop_led_module || pContext->bLedNeedToFlash) && !(DSL_DRV_WAIT_EVENT_TIMEOUT(pContext->ledPollingEvent, 10000))); /* -ERESTARTSYS or condition evaluates to true */ /* Only proceed if the specified line is in SHOWTIME state*/ DSL_CTX_READ_SCALAR(pContext, nErrCode, nLineState, nCurrentState); if( nErrCode != DSL_SUCCESS ) { DSL_DEBUG(DSL_DBG_ERR, (pContext, "DSL[%02d]: ERROR - [%s %d]: Failed to get " "current line state!"DSL_DRV_CRLF, DSL_DEV_NUM(pContext), __func__, __LINE__)); spin_lock_irqsave(&dsl_led_lock, flags); stop_led_module = 1; pContext->bLedNeedToFlash = DSL_FALSE; spin_unlock_irqrestore(&dsl_led_lock, flags); break; } /* Only proceed if the specified line is in SHOWTIME state*/ if ((nCurrentState != DSL_LINESTATE_SHOWTIME_TC_SYNC) && (nCurrentState != DSL_LINESTATE_SHOWTIME_NO_SYNC)) { spin_lock_irqsave(&dsl_led_lock, flags); pContext->bLedNeedToFlash = DSL_FALSE; spin_unlock_irqrestore(&dsl_led_lock, flags); continue; } if (pContext->bLedNeedToFlash && (pContext->bLedStatusOn == DSL_FALSE)) { /* FLASH */ /* use GPIO9 for TR68 data led off. */ if (DSL_DRV_DANUBE_CmvWrite(pContext, DSL_CMV_GROUP_INFO, DSL_CMV_ADDRESS_INFO_GPIO_CONTROL, 5, 1, &flash) != DSL_SUCCESS) { DSL_DEBUG(DSL_DBG_ERR, (pContext, "[%s %d]: CMV Write fail!" DSL_DRV_CRLF, __func__, __LINE__)); } /* Let it flash for 1 second */ if (!stop_led_module) { nErrCode = (DSL_Error_t)DSL_DRV_WAIT_EVENT_TIMEOUT(pContext->ledPollingEvent, 1000); if (nErrCode >= DSL_SUCCESS) { spin_lock_irqsave(&dsl_led_lock, flags); pContext->bLedStatusOn = DSL_TRUE; pContext->bLedNeedToFlash = DSL_FALSE; spin_unlock_irqrestore(&dsl_led_lock, flags); } } } if ((pContext->bLedNeedToFlash == DSL_FALSE) && pContext->bLedStatusOn) { /* ON */ /* use GPIO9 for TR68 data led off. */ if (DSL_DRV_DANUBE_CmvWrite(pContext, DSL_CMV_GROUP_INFO, DSL_CMV_ADDRESS_INFO_GPIO_CONTROL, 5, 1, &on) != DSL_SUCCESS) { DSL_DEBUG(DSL_DBG_ERR, (pContext, "[%s %d]: CMV Write fail!" DSL_DRV_CRLF, __func__, __LINE__)); } spin_lock_irqsave(&dsl_led_lock, flags); pContext->bLedStatusOn = DSL_FALSE; spin_unlock_irqrestore(&dsl_led_lock, flags); } } nOsRet = DSL_DRV_ErrorToOS(nErrCode); DSL_DEBUG(DSL_DBG_MSG, (pContext, "DSL[%02d]: OUT - DSL_DRV_LED_Poll thread"DSL_DRV_CRLF, DSL_DEV_NUM(pContext))); return nOsRet; }