📄 tmdlfgpo.c
字号:
} if(fgpoBufIndex == 2) { FgpoSetBaseAddr2(pInstance->instanceUnit, fgpoBufAddr); } DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_ChangeBuffer")); return TM_OK;} // tmdlFgpo_ChangeBuffer//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_GetTimestamp://// DESCRIPTION: This function gets the timestamp when a buffer is done.//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: This function can be called in ISR.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_GetTimestamp( tmInstance_t fgpoInstance, // I: Fgpo Instance UInt8 fgpoBufIndex, // I: the index of the buffer, value could be 1 or 2 pUInt32 pFgpoTimestamp) // O: the timestamp{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; UInt32 fgpoTimestamp; DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_GetTimestamp")); // Check input parameter. DBG_ASSERT(fgpoInstance != 0); // Check if already initialized DBG_ASSERT(pInstance->instanceKey == FGPO_SIGNATURE); DBG_ASSERT(fgpoBufIndex == 1 || fgpoBufIndex == 2); TMDL_FGPO_GET_UNIT_INFO(pInstance->instanceUnit, pFgpo_UnitInfo); // Return immediately when power is off if (pFgpo_UnitInfo->powerState == tmPowerOff) { return TMDL_ERR_FGPO_POWER_IS_OFF; } if(fgpoBufIndex == 1) { FgpoGetTimestamp1(pInstance->instanceUnit, (pUInt32)&fgpoTimestamp); } if(fgpoBufIndex == 2) { FgpoGetTimestamp2(pInstance->instanceUnit, (pUInt32)&fgpoTimestamp); } *pFgpoTimestamp = fgpoTimestamp; DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_GetTimestamp")); return TM_OK;} // tmdlFgpo_GetTimestamp//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_SetPowerState://// DESCRIPTION: This function set the fgpo instance power state//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: None.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_SetPowerState( tmInstance_t fgpoInstance, // I: Fgpo Instance ID tmPowerState_t fgpoPowerState) // I: Fgpo power state to enter{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_SetPowerState")); // Check input parameter. DBG_ASSERT(fgpoInstance != 0); // Check if already initialized DBG_ASSERT(pInstance->instanceKey == FGPO_SIGNATURE); TMDL_FGPO_GET_UNIT_INFO(pInstance->instanceUnit, pFgpo_UnitInfo); // Return immediately when same power state if (pFgpo_UnitInfo->powerState == fgpoPowerState) { return TM_OK; } if (fgpoPowerState == tmPowerOff) { // Power down the unit first FgpoIntfDisable(pInstance->instanceUnit); } else // fgpoPowerState == tmPowerOn || tmPowerSuspend || tmPowerStandby: { // Power up the unit first FgpoIntfEnable(pInstance->instanceUnit); } pFgpo_UnitInfo->powerState = fgpoPowerState; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_SetPowerState")); return TM_OK;} // tmdlFgpo_SetPowerState//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_GetPowerState://// DESCRIPTION: This function gets the fgpo instance power state//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: None.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_GetPowerState( tmInstance_t fgpoInstance, // I: Fgpo Instance ID ptmPowerState_t pFgpoPowerState) // O: Fgpo power state pointer{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; tmErrorCode_t tmRetVal=TM_OK; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_GetPowerState")); // Check input parameter. DBG_ASSERT(fgpoInstance != 0); DBG_ASSERT(pFgpoPowerState != Null); // Check if already initialized DBG_ASSERT(pInstance->instanceKey == FGPO_SIGNATURE); TMDL_FGPO_GET_UNIT_INFO(pInstance->instanceUnit, pFgpo_UnitInfo); *pFgpoPowerState = pFgpo_UnitInfo->powerState; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_GetPowerState")); return tmRetVal;} // tmdlFgpo_GetPowerState//-----------------------------------------------------------------------------// Internal functions://-----------------------------------------------------------------------------////-----------------------------------------------------------------------------// FUNCTION: FgpoIsr://// DESCRIPTION: This is the FGPO interrupt service routine//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: None//-----------------------------------------------------------------------------static void FgpoIsr(pVoid pFgpo_ContextArg){ tmdlFgpo_Event_t event; ptmdlFgpo_Unit_t pFgpo_UnitInfo=(ptmdlFgpo_Unit_t)pFgpo_ContextArg; tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)pFgpo_UnitInfo->pInstance; ptmCallback_t callbackFunction; UInt32 userData; DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERNAL_ENTER, "fgpoIsr")); // Get fgpo interrupt status FgpoGetIntStatus(pFgpo_UnitInfo->pInstance->instanceUnit, &event); event &= pInstance->eventMask; callbackFunction = pInstance->pCallBack; userData = pInstance->userData; if (event && callbackFunction) { callbackFunction(event, Null, userData); } FgpoIntClear(pFgpo_UnitInfo->pInstance->instanceUnit, event); DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERNAL_LEAVE, "fgpoIsr"));} // fgpoIsr//-----------------------------------------------------------------------------// FUNCTION: FgpoDbgInit://// DESCRIPTION: This function initializes tmDbg.//// RETURN: TM_OK//// NOTES: This is an internal function with no semaphore protection.//-----------------------------------------------------------------------------//static void FgpoDbgInit(void){ static Bool bInitDbg = True; if (bInitDbg) { DBG_REGISTER_MODULE(gtmDbgFgpoDevLib, "tmdlFgpo"); bInitDbg = False; }} // FgpoDbgInit//-----------------------------------------------------------------------------// FUNCTION: FgpoDbgDeInit://// DESCRIPTION: This function Deinitializes tmDbg.//// RETURN: TM_OK//// NOTES: This is an internal function with no semaphore protection.//-----------------------------------------------------------------------------// static void FgpoDbgDeInit(void){ static Bool bDeInitDbg = True; if (bDeInitDbg) { DBG_UNREGISTER_MODULE(gtmDbgFgpoDevLib); bDeInitDbg = False; }} // FgpoDbgDeInit//-----------------------------------------------------------------------------// FUNCTION: FgpoInit://// DESCRIPTION: This function gets the base of the FGPO hardware module registers.//// RETURN: TM_OK//// NOTES: None.//-----------------------------------------------------------------------------//static tmErrorCode_t FgpoInit(tmUnitSelect_t fgpoUnitSelect) // I: Unit number{ tmbslCoreModuleInfo_t moduleInfo; // Struct to store moduleInfo ptmdlFgpo_Unit_t pFgpo_UnitInfo; tmErrorCode_t tmRetVal=TM_OK; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERNAL_ENTER, "FgpoInit")); TMDL_FGPO_GET_UNIT_INFO(fgpoUnitSelect, pFgpo_UnitInfo); tmRetVal = tmbslCoreGetModuleInfo(FGPO_HWMODULE_ID, // moduleId: FGPO block fgpoUnitSelect, // Unit Number &moduleInfo); DBG_ASSERT(tmRetVal == TM_OK); pFgpo_UnitInfo->pRegs = (ptmdlFgpo_Regs_t)(moduleInfo.pMmioVirtAddr); // Always power up the unit first FgpoIntfEnable(fgpoUnitSelect); // and update the powerState in the unit info struct pFgpo_UnitInfo->powerState = tmPowerOn; FgpoReset(fgpoUnitSelect); DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERNAL_LEAVE, "FgpoInit")); return TM_OK;} // FgpoInit//-----------------------------------------------------------------------------// FUNCTION: FgpoGetIntStatus://// DESCRIPTION: Retrieves the current FGPO interrupt status//// RETURN: TM_OK//// NOTES: None.//-----------------------------------------------------------------------------static tmErrorCode_t FgpoGetIntStatus(tmUnitSelect_t fgpoUnitSelect, // I: Unit number ptmdlFgpo_Event_t pFgpoIntEvent) // I: Interrupt status{ ptmdlFgpo_Unit_t pFgpo_UnitInfo; union _FGPO_IR_STATUS fgpoIntStatus; DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERNAL_ENTER, "FgpoGetIntStatus")); TMDL_FGPO_GET_UNIT_INFO(fgpoUnitSelect, pFgpo_UnitInfo); fgpoIntStatus.u32 = pFgpo_UnitInfo->pRegs->FGPO_IR_STATUS.u32; *pFgpoIntEvent = (ptmdlFgpo_Event_t)tmdlFgpo_EvtNone; if (fgpoIntStatus.bits.Buf1Done) { *pFgpoIntEvent |= tmdlFgpo_EvtBuf1Done; } if (fgpoIntStatus.bits.Buf2Done) { *pFgpoIntEvent |= tmdlFgpo_EvtBuf2Done; } if (fgpoIntStatus.bits.Thresh1Reached) { *pFgpoIntEvent |= tmdlFgpo_EvtThresh1Reached; } if (fgpoIntStatus.bits.Thresh2Reached) { *pFgpoIntEvent |= tmdlFgpo_EvtThresh2Reached; } if (fgpoIntStatus.bits.UnderRun) { *pFgpoIntEvent |= tmdlFgpo_EvtBufUnderrun; } if (fgpoIntStatus.bits.MBErr) { *pFgpoIntEvent |= tmdlFgpo_EvtMbe; } DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERNAL_LEAVE, "FgpoGetIntStatus")); return TM_OK;} // FgpoGetIntStatus//-----------------------------------------------------------------------------// FUNCTION: FgpoIntEnable://// DESCRIPTION: Enable the FGPO interrupt specified by the fgpoInt mask.// fgpoInt contains all FGPO specific interrupts to be enabled.//// RETURN: TM_OK//// NOTES: None.//-----------------------------------------------------------------------------static tmErrorCode_t FgpoIntEnable(tmUnitSelect_t fgpoUnitSelect, // I: Unit number tmdlFgpo_Event_t fgpoIntEvent) // I: Interrupts to be enabled{ union _FGPO_IR_ENA fgpoIntEnable; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERNAL_ENTER, "FgpoIntEnable")); TMDL_FGPO_GET_UNIT_INFO(fgpoUnitSelect, pFgpo_UnitInfo); fgpoIntEnable.u32 = pFgpo_UnitInfo->pRegs->FGPO_IR_ENA.u32; if (fgpoIntEvent & tmdlFgpo_EvtBuf1Done) { fgpoIntEnable.bits.Buf1DoneEn = 1; } if (fgpoIntEvent & tmdlFgpo_EvtBuf2Done) { fgpoIntEnable.bits.Buf2DoneEn = 1; } if (fgpoIntEvent & tmdlFgpo_EvtThresh1Reached) { fgpoIntEnable.bits.Thresh1ReachedEn = 1; } if (fgpoIntEvent & tmdlFgpo_EvtThresh2Reached) { fgpoIntEnable.bits.Thresh2ReachedEn = 1; } if (fgpoIntEvent & tmdlFgpo_EvtBufUnderrun) { fgpoIntEnable.bits.UnderRunEn = 1; } if (fgpoIntEvent & tmdlFgpo_EvtMbe) { fgpoIntEnable.bits.MBErrEn = 1; } pFgpo_UnitInfo->pRegs->FGPO_IR_ENA.u32 = fgpoIntEnable.u32; DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERNAL_LEAVE, "FgpoIntEnable")); return TM_OK;} // FgpoIntEnable//-----------------------------------------------------------------------------// FUNCTION: FgpoIntDisable://// DESCRIPTION: Disables the FGPO interrupt specified by the fgpoInt mask.// fgpoInt contains all FGPO specific interrupts to be disabled.//// RETURN: TM_OK//// NOTES: None.//-----------------------------------------------------------------------------static tmErrorCode_t FgpoIntDisable(tmUnitSelect_t fgpoUnitSelect, // I: Unit number tmdlFgpo_Event_t fgpoIntEvent) // I: Interrupts to be disabled{ union _FGPO_IR_ENA fgpoIntEnable; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERNAL_ENTER, "FgpoIntDisable")); TMDL_FGPO_GET_UNIT_INFO(fgpoUnitSelect, pFgpo_UnitInfo); fgpoIntEnable.u32 = pFgpo_UnitInfo->pRegs->FGPO_IR_ENA.u32; if (fgpoIntEvent & tmdlFgpo_EvtBuf1Done) { fgpoIntEnable.bits.Buf1DoneEn = 0; } if (fgpoIntEvent & tmdlFgpo_EvtBuf2Done) { fgpoIntEnable.bits.Buf2DoneEn = 0; } if (fgpoIntEvent & tmdlFgpo_EvtThresh1Reached) { fgpoIntEnable.bits.Thresh1ReachedEn = 0; } if (fgpoIntEvent & tmdlFgpo_EvtThresh2Reached) { fgpoIntEnable.bits.Thresh2ReachedEn = 0; } if (fgpoIntEvent & tmdlFgpo_EvtBufUnderrun) { fgpoIntEnable.bits.UnderRunEn = 0; } if (fgpoIntEvent & tmdlFgpo_EvtMbe) { fgpoIntEnable.bits.MBErrEn = 0; } pFgpo_UnitInfo->pRegs->FGPO_IR_ENA.u32 = fgpoIntEnable.u32; DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERNAL_LEAVE, "FgpoIntDisable")); return TM_OK;} // FgpoIntDisable
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -