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

📄 wmdevicecontext.h

📁 pxa270平台 windows mobile 5.2 wm9713 触摸屏+音频驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
 */
#define WM_ADC_DATA_SIZE    sizeof( WM_ADC_DATA )

/*
 * Convert between handles and contexts.
 * If we make these macros we can easily change them later.
 */
#define WMHANDLE_TO_DEVICE( _handle ) ((WM_DEVICE_CONTEXT *)_handle)
#define WMDEVICE_TO_HANDLE( _device ) ((WM_DEVICE_HANDLE)_device)

/*
 * Global data.
 */

/*
 * Function prototypes
 */
#ifdef __cplusplus
extern "C" {
#endif

/*-----------------------------------------------------------------------------
 * Function:    WMInitDeviceContext
 *
 * Initialises and returns a pointer to the global device context for passing
 * to the Raw functions.
 *
 * This must in some way allocate space for the global data area g_pWMData
 * (definition in WMGlobals.h) so that the memory is common to all instances
 * of drivers using the Wolfson library.
 * 
 * Parameters:
 *      driverID	The driver ID (e.g. WM_DRIVER_AUDIO)
 *      devID       The device ID (e.g. WM_DEV_AC97_PRIMARY)
 *      ppContext   a variable to receive the pointer to the context structure.
 *
 * Returns:     WMSTATUS
 *        See WMStatus.h
 *---------------------------------------------------------------------------*/
WMSTATUS WMInitDeviceContext( WM_DRIVER_ID      driverID,
							  WM_DEVICE_ID      devID,
							  WM_DEVICE_CONTEXT **ppContext );


/*-----------------------------------------------------------------------------
 * Function:    WMLockLink
 *
 * Makes sure only one thing happens on the link at a time.
 *
 * Parameters:
 *      pDeviceContext      a pointer to the device context
 *
 * Returns:     WM_BOOL
 *        non-zero if successful, FALSE if couldn't lock in timeout.
 *---------------------------------------------------------------------------*/
#define WMLockLink( hDevice ) (												     \
       (NULL == WMHANDLE_TO_DEVICE( hDevice )->fnLockLink ||                    \
        !WMSystemCallsAllowed( hDevice ) ||                                     \
        WMHANDLE_TO_DEVICE( hDevice )->fnLockLink( hDevice, __FILE__, __LINE__ )\
        ? TRUE : FALSE )                                                        \
    )

/*-----------------------------------------------------------------------------
 * Function:    WMUnlockLink
 *
 * Releases the link lock again.
 *
 * Parameters:
 *      pDeviceContext      a pointer to the device context
 *
 * Returns:     void
 *---------------------------------------------------------------------------*/
#define WMUnlockLink( hDevice ) do {									\
    WM_DEVICE_CONTEXT *pDeviceContext = WMHANDLE_TO_DEVICE( hDevice );  \
    if ( pDeviceContext->fnUnlockLink &&                                \
         WMSystemCallsAllowed( hDevice )                                \
       )                                                                \
    {                                                                   \
        pDeviceContext->fnUnlockLink( hDevice, __FILE__, __LINE__ );    \
    }                                                                   \
} while (0)

/*-----------------------------------------------------------------------------
 * Function:    WMLockGlobalData
 *
 * Makes sure only one thread plays around with the global data at a time.
 *
 * Parameters:
 *      pDeviceContext      a pointer to the device context
 *
 * Returns:     WM_BOOL
 *        non-zero if successful, FALSE if couldn't lock in timeout.
 *---------------------------------------------------------------------------*/
#define WMLockGlobalData( hDevice ) (                                       \
       (NULL == WMHANDLE_TO_DEVICE( hDevice )->fnLockGlobalData ||          \
        !WMSystemCallsAllowed( hDevice ) ||                                 \
        WMHANDLE_TO_DEVICE( hDevice )->fnLockGlobalData( hDevice, __FILE__, __LINE__ )\
        ? TRUE : FALSE )                                                    \
    )

/*-----------------------------------------------------------------------------
 * Function:    WMUnlockGlobalData
 *
 * Releases the global data lock again.
 *
 * Parameters:
 *      pDeviceContext      a pointer to the device context
 *
 * Returns:     void
 *---------------------------------------------------------------------------*/
#define WMUnlockGlobalData( hDevice ) do {                                      \
    WM_DEVICE_CONTEXT *pDeviceContext = WMHANDLE_TO_DEVICE( hDevice );          \
    if ( pDeviceContext->fnUnlockGlobalData &&                                  \
         WMSystemCallsAllowed( hDevice )                                        \
       )                                                                        \
    {                                                                           \
        pDeviceContext->fnUnlockGlobalData( hDevice, __FILE__, __LINE__ );      \
    }                                                                           \
} while (0)

/*-----------------------------------------------------------------------------
 * Function:    WMAtomicIncrement
 *
 * Thread-safe increment.
 * 
 * Note: this relies on an atomic increment function being provided in the
 * device context.  If no such function is available, this will turn into
 * a normal increment.  In this case it is possible for increments and
 * decrements to occasionally get missed if two occur simultaneously.
 *
 * Parameters:
 *      hDevice     handle to the device.
 *      pCounter    a pointer to the counter.
 *
 * Returns:     WMAtomic_t
 *        The value after incrementing.
 *---------------------------------------------------------------------------*/
#define WMAtomicIncrement( hDevice, pCounter ) (                            \
       ( NULL == WMHANDLE_TO_DEVICE( hDevice )->fnAtomicIncrement ) ?       \
        ++(*pCounter) :                                                     \
        WMHANDLE_TO_DEVICE( hDevice )->fnAtomicIncrement( (WMAtomic_t *)pCounter ) \
    )

/*-----------------------------------------------------------------------------
 * Function:    WMAtomicDecrement
 *
 * Thread-safe decrement.
 * 
 * Note: this relies on an atomic decrement function being provided in the
 * device context.  If no such function is available, this will turn into
 * a normal decrement.  In this case it is possible for increments and
 * decrements to occasionally get missed if two occur simultaneously.
 *
 * Parameters:
 *      hDevice     handle to the device.
 *      pCounter    a pointer to the counter.
 *
 * Returns:     WMAtomic_t
 *        The value after decrementing.
 *---------------------------------------------------------------------------*/
#define WMAtomicDecrement( hDevice, pCounter ) (                            \
       ( NULL == WMHANDLE_TO_DEVICE( hDevice )->fnAtomicDecrement ) ?       \
        --(*pCounter) :                                                     \
        WMHANDLE_TO_DEVICE( hDevice )->fnAtomicDecrement( (WMAtomic_t *)pCounter ) \
    )

#ifdef __cplusplus
}   /* extern "C" */
#endif

#endif	/* __WMDEVICECONTEXT_H__ */
/*------------------------------ END OF FILE ---------------------------------*/

⌨️ 快捷键说明

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