📄 tmdlfgpo.c
字号:
} // tmdlFgpo_Close//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_GetInstanceSetup://// DESCRIPTION: get current setup or default setup if not initialized.//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: None.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_GetInstanceSetup( tmInstance_t fgpoInstance, // I: instance ptmdlFgpo_InstanceSetup_t *ppFgpoSetup) // O: ptr to instance setup struct ptr{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_GetInstanceSetup")); // Check input parameter. DBG_ASSERT(fgpoInstance != 0); DBG_ASSERT(ppFgpoSetup != Null); // Check if already initialized DBG_ASSERT(pInstance->instanceKey == FGPO_SIGNATURE); 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; } // fill in setup struct in instance struct *ppFgpoSetup = &pInstance->setup; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_GetInstanceSetup")); return TM_OK;} // tmdlFgpo_GetInstanceSetup//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_InstanceSetup://// DESCRIPTION: setup the Fgpo instance//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: None.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_InstanceSetup( tmInstance_t fgpoInstance, // I: instance ptmdlFgpo_InstanceSetup_t pFgpoSetup) // I: ptr to new setup structure{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_InstanceSetup")); // Check input parameter. DBG_ASSERT(fgpoInstance != 0); DBG_ASSERT(pFgpoSetup != Null); DBG_ASSERT(pFgpoSetup->samplesPerRec >= gFgpo_Caps.minSamplePerRec); DBG_ASSERT(pFgpoSetup->samplesPerRec <= gFgpo_Caps.maxSamplePerRec); DBG_ASSERT(pFgpoSetup->recGap >= gFgpo_Caps.minRecGap); DBG_ASSERT(pFgpoSetup->recGap <= gFgpo_Caps.maxRecGap); DBG_ASSERT(pFgpoSetup->bufGap >= gFgpo_Caps.minBufGap); DBG_ASSERT(pFgpoSetup->bufGap <= gFgpo_Caps.maxBufGap); DBG_ASSERT(pFgpoSetup->thresh1 >= gFgpo_Caps.minThresh); DBG_ASSERT(pFgpoSetup->thresh1 <= gFgpo_Caps.maxThresh); DBG_ASSERT(pFgpoSetup->thresh2 >= gFgpo_Caps.minThresh); DBG_ASSERT(pFgpoSetup->thresh2 <= gFgpo_Caps.maxThresh); // Check if already initialized DBG_ASSERT(pInstance->instanceKey == FGPO_SIGNATURE); 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; } // fill in setup struct in instance struct pInstance->setup = *pFgpoSetup; pInstance->setupDone = True; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_InstanceSetup")); return TM_OK;} // tmdlFgpo_InstanceSetup//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_RegisterCallback://// DESCRIPTION: This Function allows the user to register callback function for// given events.//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: There is only one register callback function per instance.//// This function should be called for the first time before// the function tmdlFgpo_Start.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_RegisterCallback( tmInstance_t fgpoInstance, // I: Fgpo Instance ptmCallback_t pFgpoCallBack, // I: callback function pointer UInt32 fgpoUserData) // I: user data{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_RegisterCallback")); // 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 power is off if (pFgpo_UnitInfo->powerState == tmPowerOff) { return TMDL_ERR_FGPO_POWER_IS_OFF; } // Save Call back and user data info pInstance->pCallBack = pFgpoCallBack; pInstance->userData = fgpoUserData; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_RegisterCallback")); return TM_OK;} // tmdlFgpo_RegisterCallback//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_SetEventMask://// DESCRIPTION: This Function allows the user to select the FGPO events that// needs to be notified and handled by the callback function.//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: All events are disabled by default. If all events are disabled// the callback function will be disabled by default.//// This function should be called for the first time before the// function tmdlFgpo_Start.//// This function is only usable if the corresponding// tmdlFgpo_RegisterCallback function has been called with a// non-Null callback function pointer.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_SetEventMask( tmInstance_t fgpoInstance, // I: Fgpo Instance UInt32 fgpoEventMask) // I: A bit wise OR of the events when the // callback function should be called.{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_SetEventMask")); // 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 power is off if (pFgpo_UnitInfo->powerState == tmPowerOff) { return TMDL_ERR_FGPO_POWER_IS_OFF; } // Save eventMask pInstance->eventMask = fgpoEventMask; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_SetEventMask")); return TM_OK;} // tmdlFgpo_SetEventMask//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_Start://// DESCRIPTION: This function starts the FGPO instance.//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: This function may only be called after tmdlFgpo_RegisterCallback,// tmdlFgpo_SetEventMask and tmdlFgpo_InstanceSetup has been called.//// Set FGPO_CTL/OUTPUT_ENABLE_1 or OUTPUT_ENABLE_2//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_Start(tmInstance_t fgpoInstance) // I: Fgpo Instance to start.{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_Start")); // Check input parameter. DBG_ASSERT(fgpoInstance != 0); // Check if already initialized DBG_ASSERT(pInstance->instanceKey == FGPO_SIGNATURE); // Check if tmdlFgpo_InstanceSetup was called prior to tmdlFgpo_Start DBG_ASSERT(pInstance->setupDone == True); // Check if tmdlFgpo_SetEventMask was called prior to tmdlFgpo_Start DBG_ASSERT(pInstance->eventMask != 0); // Check if tmdlFgpo_RegisterCallback was called prior to tmdlFgpo_Start DBG_ASSERT(pInstance->pCallBack != Null); 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; } // Clear the events FgpoIntClear(pInstance->instanceUnit, (tmdlFgpo_Event_t)pInstance->eventMask); // Enable the events FgpoIntEnable(pInstance->instanceUnit, (tmdlFgpo_Event_t)pInstance->eventMask); // Setup FGPO hw unit with fgpoInstance.setup FgpoSetup(pInstance->instanceUnit, (ptmdlFgpo_InstanceSetup_t)&pInstance->setup); FgpoOutputEnable(pInstance->instanceUnit); DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_Start")); return TM_OK;} // tmdlFgpo_Start//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_Stop://// DESCRIPTION: This function stops the FGPO instance.//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: This function may only be called after a tmdlFgpo_Start has been// called.//// Reset FGPO_CTL/OUTPUT_ENABLE_1 or OUTPUT_ENABLE_2//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_Stop(tmInstance_t fgpoInstance) // I: Fgpo Instance to stop.{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_Stop")); // 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 power is off if (pFgpo_UnitInfo->powerState == tmPowerOff) { return TMDL_ERR_FGPO_POWER_IS_OFF; } // Disable the events FgpoIntDisable(pInstance->instanceUnit, (tmdlFgpo_Event_t)pInstance->eventMask); FgpoOutputDisable(pInstance->instanceUnit); DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_Stop")); return TM_OK;} // tmdlFgpo_Stop//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_InstanceConfig://// DESCRIPTION: This function configures the Fgpo instance based on the// specific Fgpo configuration command and the associated// data structure.//// RETURN: TM_OK -->if command is supported// TMDL_ERR_FGPO_NOT_SUPPORTED --> if command is not supported//// NOTES: There currently only two runtime configurable parameters in the FGPO// Device Library. It will return TM_OK, if one of these commands are asked to set.// Otherwise it will return TMDL_ERR_FGPO_NOT_SUPPORTED//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_InstanceConfig( tmInstance_t fgpoInstance, // I: Fgpo Instance to configure. UInt32 fgpoCfgCmd, // I: Fgpo instance configuration command. pVoid fgpoCfgData) // I: Fgpo instance configuration data.{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_InstanceConfig")); // 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 power is off if (pFgpo_UnitInfo->powerState == tmPowerOff) { return TMDL_ERR_FGPO_POWER_IS_OFF; } if((fgpoCfgCmd&SET_RECORD_PER_BUFFER)==SET_RECORD_PER_BUFFER) { pFgpo_UnitInfo->pRegs->FGPO_SIZE.u32= *((pUInt32) (fgpoCfgData)); } else if ((fgpoCfgCmd&SET_STRIDE_SIZE)==SET_STRIDE_SIZE) { pFgpo_UnitInfo->pRegs->FGPO_STRIDE.u32 = *(((pUInt32)fgpoCfgData)); } else { return TMDL_ERR_FGPO_NOT_SUPPORTED; } DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_InstanceConfig")); return TM_OK;} // tmdlFgpo_InstanceConfig//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_GetNumOfRec://// DESCRIPTION: This function retrieves the number of records or messages in buffers.//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: This function can be called in ISR.// Calling this function while the associated buffer is active may not// return the actual transfer count( can be less than or equal to the// actual count) due to clock domain crossing. The best time to retrieve// the transfer count is during the associated BUFnFULL isr as the counter// is not updated during this time.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_GetNumOfRec( tmInstance_t fgpoInstance, // I: Fgpo Instance UInt8 fgpoBufIndex, // I: the index of the buffer, value could be 1 or 2 pUInt32 pFgpoNumOfRec) // O: the number of records or messages in the buffer{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_GetNumOfRec")); // 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) { FgpoGetNumOfRec1((tmUnitSelect_t)pInstance->instanceUnit, (pUInt32)pFgpoNumOfRec); } if(fgpoBufIndex == 2) { FgpoGetNumOfRec2((tmUnitSelect_t)pInstance->instanceUnit, (pUInt32)pFgpoNumOfRec); } DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_GetNumOfRec")); return TM_OK;} // tmdlFgpo_GetNumOfRec//-----------------------------------------------------------------------------// FUNCTION: tmdlFgpo_ChangeBuffer://// DESCRIPTION: This function changes the buffer that the FGPO instance uses.//// RETURN: tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES: This function can be called in ISR.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_ChangeBuffer( tmInstance_t fgpoInstance, // I: Fgpo Instance UInt8 fgpoBufIndex, // I: the index of the buffer to change, value could be 1 or 2 UInt32 fgpoBufAddr) // I: the physical address of the new buffer{ tmdlFgpo_Instance_t *pInstance=(tmdlFgpo_Instance_t *)fgpoInstance; ptmdlFgpo_Unit_t pFgpo_UnitInfo; DBG_ISR_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_ChangeBuffer")); // 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) { FgpoSetBaseAddr1(pInstance->instanceUnit, fgpoBufAddr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -