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

📄 wmdevicecontext.h

📁 pxa270平台 windows mobile 5.2 wm9713 触摸屏+音频驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
/*-----------------------------------------------------------------------------
 * Copyright (c) Wolfson Microelectronics plc.  All rights reserved.
 *
 * This software as well as any related documentation is furnished under 
 * license and may only be used or copied in accordance with the terms of the 
 * license. The information in this file is furnished for informational use 
 * only, is subject to change without notice, and should not be construed as 
 * a commitment by Wolfson Microelectronics plc. Wolfson Microelectronics plc
 * assumes no responsibility or liability for any errors or inaccuracies that
 * may appear in this document or any software that may be provided in
 * association with this document. 
 *
 * Except as permitted by such license, no part of this document may be 
 * reproduced, stored in a retrieval system, or transmitted in any form or by 
 * any means without the express written consent of Wolfson Microelectronics plc. 
 *
 * $Id: WMDeviceContext.h 2828 2006-04-06 14:11:45Z ian $
 *
 * The library is divided into two sets of functions.  One set, "Raw", have
 * no global data and make no system calls.  The other set build upon the
 * Raw functions to provide further functionality and ease of use.
 *
 * This file defines the information which has to be provided to the Raw
 * functions as working storage.
 *
 * Warning:
 *  This driver is specifically written for Wolfson Codecs. It is not a 
 *  general CODEC device driver.
 *
 *---------------------------------------------------------------------------*/
#ifndef __WMDEVICECONTEXT_H__
#define __WMDEVICECONTEXT_H__

/*
 * Include files
 */
#include "WMTypes.h"
#include "WMAudio.h"
#include "WMPower.h"
#include "WMPlatform_OS.h"

/*
 * Definitions
 */
typedef struct tagWM_DEVICE_CONTEXT WM_DEVICE_CONTEXT;
typedef struct tagWM_SHARED_DATA  WM_SHARED_DATA;
typedef struct tagWM_ADC_DATA  WM_ADC_DATA;
typedef struct tagWM_CHIPDEF WM_CHIPDEF;

typedef void (*SleepFn)					( int millisecs );
typedef int (*LockFn)					( WM_DEVICE_HANDLE hDevice,
                                          const char *file,
                                          int line
                                        );
typedef void (*UnlockFn)                ( WM_DEVICE_HANDLE hDevice,
                                          const char *file,
                                          int line
                                        );
typedef WMAtomic_t (*IncrementFn)		( WMAtomic_t *pCounter );
typedef WMAtomic_t (*DecrementFn)		( WMAtomic_t *pCounter );
typedef WMSTATUS (*InitFn)              ( WM_DEVICE_HANDLE hDevice );
typedef void (*ShutdownFn)              ( WM_DEVICE_HANDLE hDevice );
typedef WMSTATUS (*CodecReadFn)         ( WM_DEVICE_HANDLE hDevice,
                                          WM_REGTYPE reg,
                                          WM_REGVAL *pValue );
typedef WMSTATUS (*CodecWriteFn)        ( WM_DEVICE_HANDLE hDevice,
                                          WM_REGTYPE reg,
                                          WM_REGVAL value );    
typedef WMSTATUS (*InitDeviceIdFn)		( WM_DEVICE_HANDLE hDevice );
typedef WMSTATUS (*CodecResetFn)        ( WM_DEVICE_HANDLE hDevice );

/*
 * The device context structure which the general functions expect to work with.
 * Platform-specific code can append its own members (e.g. mapped register
 * addresses) to this.
 * 
 * v_pWMData        - pointer to general global shared memory (if available).
 * v_pADCData       - pointer to ADC global shared memory (if available).
 *                    Note: if v_pWMData is available, this should be
 *                    &v_pWMData->adcData.
 * fnSleep          - function which sleeps for a given number of milliseconds,
 *                    Optional.
 * fnLock           - function which synchronises access to the Auxiliary ADC
 *                    shared memory area,
 *                    Optional.
 * fnUnlock         - function which releases the Auxiliary ADC shared memory
 *                    area again,
 *                    Optional.
 * fnIncrement      - function which performs an atomic increment,
 *                    Optional.
 * fnDecrement      - function which performs an atomic decrement,
 *                    Optional.
 * fnLinkInit       - Function that initialises the codecs control link.
 * fnLinkShutdown   - Function that shuts down the codecs control link.
 * fnTouchInit      - Function that initialises the touch subsystem,
 *                  - Optional.
 * fnCodecRead      - Function that reads a given codecs register.
 *                  - Optional.
 * fnCodecWrite     - Function that writes to a given codecs register.
 * fnInitDeviceId   - Function that initialises the codecs device type and revision.
 *                  - Optional.
 * fnCodecReset     - Function that will perform a cold reset of the device.
 *                    It will also reset the link (if necessary) and reset all 
 *                    registers to default values.
 * fnCodecWake      - Function that will wake up the device and link (if necessary) and
 *                  - preserve the state of the registers before the device was put to
 *                    sleep.
 *                    Optional.
 * deviceType       - the ID of the device - e.g. 0x4C12 for WM9712.
 * deviceID         - the precedence of the device - e.g. WM_DEV_AC97_PRIMARY.
 *                    Note: this is not necessarily the device ID passed in on
 *                    the call to WMOpenDevice.  I2S device IDs will get changed
 *                    to either WM_DEV_I2S_PRIMARY or WM_DEV_I2S_SECONDARY.  To
 *                    find out which I2S device, look at deviceType instead.
 * flags            - Device context flags - set up by the appropriate 
 *                    GetDeviceContext function.
 */
#if WM_AUXADC
#   define VOLATILE_WM_ADC_DATA  volatile WM_ADC_DATA            *v_pADCData;
#else
#   define VOLATILE_WM_ADC_DATA  
#endif

#define WM_DEVICE_CONTEXT_HEADER                            \
    volatile WM_SHARED_DATA       *v_pWMData;               \
    VOLATILE_WM_ADC_DATA                                    \
                                                            \
    SleepFn                         fnSleep;                \
    LockFn                          fnLockLink;             \
    UnlockFn                        fnUnlockLink;           \
    LockFn                          fnLockGlobalData;       \
    UnlockFn                        fnUnlockGlobalData;     \
    IncrementFn                     fnAtomicIncrement;      \
    DecrementFn                     fnAtomicDecrement;      \
    InitFn                          fnLinkInit;				\
	ShutdownFn					    fnLinkShutdown;			\
    InitFn                          fnTouchInit;            \
	CodecReadFn						fnCodecRead;			\
	CodecWriteFn					fnCodecWrite;			\
	InitDeviceIdFn				    fnInitDeviceId;         \
    CodecResetFn                    fnCodecReset;           \
    CodecResetFn                    fnCodecWake;            \
                                                            \
    unsigned short                  flags;                  \
    unsigned char                   preventSyscallCount;    \
    unsigned char                   activeDrivers;          \
                                                            \
    WMMutex_t                       linkMutex;              \
    WMMutex_t                       globalsMutex;           \
                                                            \
    WM_DEVICE_ID                    deviceID;               \
    WM_CHIPTYPE                     deviceType;             \
    WM_CHIPREV                      revision;               \
	WM_2WIRE_ADDR					codecAddress;           \
    WM_STREAM_ID                    defaultOutputStream;    \
    WM_STREAM_ID                    defaultInputStream;     \
    const WM_CHIPDEF                *pChipDef;

struct tagWM_DEVICE_CONTEXT
{
    WM_DEVICE_CONTEXT_HEADER      /* See above */
    /* Platform-specific stuff comes here */
};

/* 
 * Device context flags.
 */
#define DEVICE_CONTEXT_INITIALISED  0x0001  /* The device context is initialised */
#define DEVICE_INITIALISED          0x0004  /* The device is initialised */
#define DEVICE_TYPE_NEEDS_CHECKING  0x0008  /* The device type was provided by user */

/*
 * The size of the ADC data.

⌨️ 快捷键说明

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