⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tmdlfgpo.c

📁 PNX1500上视频输出VCP的源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* * Copyright (c) 2003, 2004 Koninklijke Philips Electronics N V. All rights * reserved. * * This source code and any compilation or derivative thereof is the proprietary * information of Koninklijke Philips Electronics N V and is confidential in * nature. Under no circumstances is this software to be exposed to or placed * under an Open Source License of any type without the express written * permission of Koninklijke Philips Electronics N V. * * ############################################################################# * * Module: %name: tmdlFgpo.c % %version: ds08#8 % * * %date_created: Fri Aug 11 12:30:16 2006 % %created_by: bog % * * %date_modified: Wed Dec 14 13:36:33 2005 % %derived_by: bog % * * ############################################################################# *///-----------------------------------------------------------------------------// Standard include files://-----------------------------------------------------------------------------//#include <tmNxTypes.h>#include <tmNxCompId.h>#include <tmNxModId.h>#include <tmosal.h>#include <tmStdLib.h>#include <tmbslCore.h>#include <tmFlags.h>#include <tmDbg.h>//-----------------------------------------------------------------------------// Project include files://-----------------------------------------------------------------------------//#include <tmdlFgpo014c.h>#include "tmdlFgpoLocal.h"#include <tmdlFgpo.h>//-----------------------------------------------------------------------------// Types and defines://-----------------------------------------------------------------------------//#define FGPO_HWMODULE_ID FGPO_14C_MOD_ID // FGPO Module IDDBG_UNIT(gtmDbgFgpoDevLib)//-----------------------------------------------------------------------------// Global data://-----------------------------------------------------------------------------//// default setup structurestatic const tmdlFgpo_InstanceSetup_t gFgpo_Setup={    (tmdlFgpo_Mode_t)tmdlFgpo_RecOutput,    (tmdlFgpo_DataStart_t)tmdlFgpo_StartPulseOnFirstData,    (tmdlFgpo_DataStop_t)tmdlFgpo_MsgStopPulseOnLastData,    (tmdlFgpo_ExtRecSync_t)tmdlFgpo_ExtRecSyncNo,    (tmdlFgpo_ExtBufSync_t)tmdlFgpo_ExtBufSyncNo,    (UInt32)1,    (UInt32)1,    (tmdlFgpo_SampleSize_t)tmdlFgpo_SampleSize32Bit,    (UInt32)1024,    (UInt32)1024,    (UInt32)1,    (UInt32)1,    (Bool)False,    (Bool)False,    (Bool)False,    (UInt32)TMDL_FGPO_BUFBASE_NULL,    (UInt32)TMDL_FGPO_BUFBASE_NULL,    (UInt32)4096};// capabilities structurestatic const tmdlFgpo_Capabilities_t gFgpo_Caps={    sizeof(tmdlFgpo_Capabilities_t),    {        (UInt32)TMDL_FGPO_COMPATIBILITY_NR,        (UInt32)TMDL_FGPO_MAJOR_VERSION_NR,        (UInt32)TMDL_FGPO_MINOR_VERSION_NR    },    (UInt32)TMDL_FGPO_NUM_SUPPORTED_INSTANCES,    1,    16777215,    2,    16777215,    1,    16777215,    1,    16777215,    1,    16777215};#define PNX1500     1#define PNX1700     1#if (PNX1500 || PNX1700)// Number of Fgpo Units#define TMDL_FGPO_NUM_UNITS 1static tmdlFgpo_Unit_t gFgpo_UnitInfo[TMDL_FGPO_NUM_UNITS]={    Null,                       // FGPO interrupt handle    tmPowerOff,                 // FGPO power state    0,                          // Current instance    Null,                       // Pointer to FGPO registers    0                           // Number of open instances for particular unit};#define TMDL_FGPO_GET_UNIT_INFO(fgpoUnitNo, pFgpo_UnitInfo)  \{                                                            \    if (fgpoUnitNo < 0 || fgpoUnitNo > TMDL_FGPO_NUM_UNITS)  \        return TMDL_ERR_FGPO_BAD_UNIT_NUM;                   \    pFgpo_UnitInfo = &gFgpo_UnitInfo[fgpoUnitNo];                 \}#else#error THIS CPU IS NOT SUPPORTED#endif//-----------------------------------------------------------------------------// Exported    functions://-----------------------------------------------------------------------------////-----------------------------------------------------------------------------// FUNCTION:    tmdlFgpo_GetNumberOfUnits://// DESCRIPTION: This Function returns the number of FGPO units in the system.//// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES:       None.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_GetNumberOfUnits(                           pUInt32 pFgpoUnitCount)  // O: FGPO Unit Count pointer{    static UInt32 fgpoNumberOfUnits=0;    FgpoDbgInit();    DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_GetNumberOfUnits"));    *pFgpoUnitCount = TMDL_FGPO_NUM_UNITS;    DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_GetNumberOfUnits"));    return (TM_OK);}//-----------------------------------------------------------------------------// FUNCTION:    tmdlFgpo_GetSWVersion://// DESCRIPTION: Get the FGPO DevLib interface compatiblity number, major version//              and minor version.//// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES:       None.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_GetSWVersion(                  ptmSWVersion_t pFgpoVersionInfo)  // O: Fgpo Version Info pointer{    // Register with debug unit.    FgpoDbgInit();    DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_GetSWVersion"));    // Check input parameter.    DBG_ASSERT(pFgpoVersionInfo != Null)    // Fill in Device library version numbers    pFgpoVersionInfo->compatibilityNr = TMDL_FGPO_COMPATIBILITY_NR;    pFgpoVersionInfo->majorVersionNr = TMDL_FGPO_MAJOR_VERSION_NR;    pFgpoVersionInfo->minorVersionNr = TMDL_FGPO_MINOR_VERSION_NR;    DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_GetSWVersion"));    return( TM_OK );}//-----------------------------------------------------------------------------// FUNCTION:    tmdlFgpo_GetCapabilities://// DESCRIPTION: This function returns the capabilites of Fgpo Unit tmUnit0.//// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES:       See defintion of the structure tmdlFgpoCapabilities_t for more//              details.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_GetCapabilities(                    const tmdlFgpo_Capabilities_t(**ppFgpoCaps))  // O: Fgpo capabilites ptr ptr{    return tmdlFgpo_GetCapabilitiesM(ppFgpoCaps, tmUnit0);}//-----------------------------------------------------------------------------// FUNCTION:    tmdlFgpo_GetCapabilitiesM://// DESCRIPTION: This function returns the capabilites of Fgpo Unit fgpoUnitID.//// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES:       See defintion of the structure tmdlFgpoCapabilities_t for more//              details.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_GetCapabilitiesM(                    const tmdlFgpo_Capabilities_t(**ppFgpoCaps),  // O: Fgpo capabilites ptr ptr                    tmUnitSelect_t fgpoUnitID)                    // I: Fgpo Unit Number{    // Register with debug unit.    FgpoDbgInit();    DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_GetCapabilities"));    // Check input parameter    DBG_ASSERT(ppFgpoCaps != Null);    // Check unit number    DBG_ASSERT(fgpoUnitID <= TMDL_FGPO_NUM_UNITS);    *ppFgpoCaps = &gFgpo_Caps;    DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_GetCapabilities"));    return TM_OK;}//-----------------------------------------------------------------------------// FUNCTION:    tmdlFgpo_Open://// DESCRIPTION: This function opens Fgpo Unit tmUnit0 for access//// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES:       The Fgpo Instance returned from the function will be passed in//              as a parameter in subsequent device library function calls.//              Use the tmdlFgpo_Close function to close the Fgpo instance and//              free system resources after all Fgpo instance access have been//              completed.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_Open(    tmInstance_t *pFgpoInstance)  // O: Fgpo instance for access{    return tmdlFgpo_OpenM(pFgpoInstance, tmUnit0);}//-----------------------------------------------------------------------------// FUNCTION:    tmdlFgpo_OpenM://// DESCRIPTION: This function opens Fgpo Unit fgpoUnitID for access//// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES:       The Fgpo Instance returned from the function will be passed in//              as a parameter in subsequent device library function calls.//              Use the tmdlFgpo_Close function to close the Fgpo instance and//              free system resources after all Fgpo instance access have been//              completed.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_OpenM(tmInstance_t *pFgpoInstance,  // O: Fgpo instance for access.                             tmUnitSelect_t fgpoUnitID)    // I: Fgpo Unit Number{    tmErrorCode_t fgpoStatus;    ptmdlFgpo_Instance_t pInstance;    ptmdlFgpo_Unit_t pFgpo_UnitInfo;    tmosalIntDescriptor_t fgpoIntDescriptor;    tmErrorCode_t tmRetVal=TM_OK;    char intName[8];    // Register with debug unit.    FgpoDbgInit();    DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_ENTER, "tmdlFgpo_Open"));    // Check unit number    DBG_ASSERT(fgpoUnitID < TMDL_FGPO_NUM_UNITS);    DBG_ASSERT(pFgpoInstance != Null);    TMDL_FGPO_GET_UNIT_INFO(fgpoUnitID, pFgpo_UnitInfo);    tmRetVal = tmosalSystemMutexEnter();    DBG_ASSERT(tmRetVal == TM_OK);    {    // Can't open further instance    if (pFgpo_UnitInfo->numCurrentInstances >= TMDL_FGPO_NUM_SUPPORTED_INSTANCES)    {        DBG_PRINT((gtmDbgFgpoDevLib, DBG_LEVEL_1, \                   "pFgpo_UnitInfo->numCurrentInstances(%d) \>= TMDL_FGPO_NUM_SUPPORTED_INSTANCES", \                   pFgpo_UnitInfo->numCurrentInstances));        tmRetVal = tmosalSystemMutexExit();        DBG_ASSERT(tmRetVal == TM_OK);        tmRetVal = TMDL_ERR_FGPO_NO_INSTANCE;        return tmRetVal;    }    if (pFgpo_UnitInfo->numCurrentInstances == 0)  // if no instance created yet    {        // Initialize Unit        FgpoInit(fgpoUnitID);        sprintf(intName, "FGPO%d", fgpoUnitID);        // Create the FGPO interrupt.        tmRetVal = tmosalIntCreate(intName,                   // Name of the interrupt source                                   &pFgpo_UnitInfo->intHdl,                                   tmosalIntCreateFlagNone);        DBG_ASSERT(tmRetVal == TM_OK);        // Get default setup        tmRetVal = tmosalIntInstanceGetSetup(pFgpo_UnitInfo->intHdl, &fgpoIntDescriptor);        DBG_ASSERT(tmRetVal == TM_OK);        // Prepare interrupt descriptor        fgpoIntDescriptor.pHandler         = FgpoIsr;        fgpoIntDescriptor.pContextArgument = pFgpo_UnitInfo;        fgpoIntDescriptor.enabled          = True;        fgpoIntDescriptor.interruptible    = True;        // Setup interrupt instance        tmRetVal = tmosalIntInstanceSetup(pFgpo_UnitInfo->intHdl, &fgpoIntDescriptor);        DBG_ASSERT(tmRetVal == TM_OK);    // Initialize clocks// TODO    }        pFgpo_UnitInfo->numCurrentInstances++;    }    tmRetVal = tmosalSystemMutexExit();    DBG_ASSERT(tmRetVal == TM_OK);    if (!(pInstance = malloc(sizeof(tmdlFgpo_Instance_t))))    {        DBG_PRINT((gtmDbgFgpoDevLib, DBG_LEVEL_1, "Instance malloc failed\n"));        tmRetVal = TMDL_ERR_FGPO_ALLOCATION_FAILURE;        return tmRetVal;    }    pInstance->instanceUnit = (tmUnitSelect_t)fgpoUnitID;    pInstance->instanceKey  = FGPO_SIGNATURE;    pInstance->setupDone    = False;    pInstance->pCallBack    = Null;    pInstance->userData     = 0;    pInstance->eventMask    = 0;    memcpy(&pInstance->setup, &gFgpo_Setup, sizeof(gFgpo_Setup));    pFgpo_UnitInfo->pInstance = (ptmdlFgpo_Instance_t)pInstance;    // return the instance    *pFgpoInstance = (tmInstance_t)pInstance;    DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_Open"));    return tmRetVal;}  // tmdlFgpo_Open//-----------------------------------------------------------------------------// FUNCTION:    tmdlFgpo_Close://// DESCRIPTION: This function deallocates the specified FGPO instance created by//              tmdlFgpo_Open.//// RETURN:      tmErrorCode_t: Status of operation (TM_OK = PASS)//// NOTES:       Any active Fgpo software or hardware operations will be//              disabled. After the Fgpo instance is closed, the instance//              number is no longer valid and cannot be used for device//              library function calls.//-----------------------------------------------------------------------------//tmErrorCode_t tmdlFgpo_Close(tmInstance_t fgpoInstance)   // I: Fgpo Instance to close.{    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_Close"));    // Check input parameters    DBG_ASSERT(fgpoInstance != 0);    // Check if instance initialized    DBG_ASSERT(pInstance->instanceKey == FGPO_SIGNATURE);    TMDL_FGPO_GET_UNIT_INFO(pInstance->instanceUnit, pFgpo_UnitInfo);    pFgpo_UnitInfo->pInstance = (ptmdlFgpo_Instance_t)0;    // Set incorrect instance key value    pInstance->instanceKey = 0;    // Set setup flag to false    pInstance->setupDone = False;    // free allocated instance memory    free((pVoid)fgpoInstance);    tmRetVal = tmosalSystemMutexEnter();    DBG_ASSERT(tmRetVal == TM_OK);    // decrease the number of instances    pFgpo_UnitInfo->numCurrentInstances--;    if (pFgpo_UnitInfo->numCurrentInstances == 0)  // if no instance created yet    {        // Leave hardware in known state        FgpoReset(pInstance->instanceUnit);        // Destroy interrupt        tmRetVal = tmosalIntDestroy(pFgpo_UnitInfo->intHdl);        DBG_ASSERT(tmRetVal == TM_OK);        pFgpo_UnitInfo->intHdl = 0;    }    tmRetVal = tmosalSystemMutexExit();    DBG_ASSERT(tmRetVal == TM_OK);    DBG_PRINT((gtmDbgFgpoDevLib, DBG_INTERFACE_LEAVE, "tmdlFgpo_Close"));	FgpoDbgDeInit();    return TM_OK;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -