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

📄 cspddk.h

📁 BGW211针对freescale的MX21的无线WIFI驱动(WINCE5.0)
💻 H
字号:
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
// Copyright (C) 2004-2006, Freescale Semiconductor, Inc. All Rights Reserved
// THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
// BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
// Freescale Semiconductor, Inc.
//
//------------------------------------------------------------------------------
//
//  Header:  drvlib.h
//
//  Provides definitions for DRVLIB.
//
//------------------------------------------------------------------------------

#ifndef __DRVLIB_H
#define __DRVLIB_H

//------------------------------------------------------------------------------
// MACRO DEFINITIONS 
//------------------------------------------------------------------------------
// Mutex used by GpioClass
#define GPIO_MUTEX_NAME             TEXT("GPIO_MUTEX")

// Name of mutex used by I2cClass
#define I2C_MUTEX_NAME              TEXT("I2C_MUTEX")
#define I2C_SEMAPHORE_NAME          TEXT("I2C_SEMAPHORE")

// Default settings to initialize I2C controller
#define I2C_SLAVE_ADDRESS_DEFAULT   0x28
#define I2C_CLOCK_DEFAULT           100000  // 100kHz

#define DRV_FUNCTION_ENTRY() \
    DEBUGMSG(ZONE_FUNCTION, (TEXT("++%s\r\n"), __WFUNCTION__))
#define DRV_FUNCTION_EXIT() \
    DEBUGMSG(ZONE_FUNCTION, (TEXT("--%s\r\n"), __WFUNCTION__))
    
#define ZONE_INFO           DEBUGZONE(0)
#define ZONE_FUNCTION       DEBUGZONE(1)
#define ZONE_WARN           DEBUGZONE(2)
#define ZONE_ERROR          DEBUGZONE(3)
#define ZONE_INIT			DEBUGZONE(4) 

//------------------------------------------------------------------------------
// ENUMERATIONS AND STRUCTURES 
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
//------------------------------------------------------------------------------
// FUNCTION PROTOTYPES
//------------------------------------------------------------------------------
extern UINT32 BSPDrvlibGetPERCLK1(void);
extern UINT32 BSPDrvlibGetPERCLK2(void);
extern UINT32 BSPDrvlibGet32kHzRefFreq(void);
extern UINT32 BSPDrvlibTimerGetClkSrc(void);

#ifdef __cplusplus
    }
#endif

//------------------------------------------------------------------------------
// EXTERN DECLARATIONS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// CLASS DEFINITIONS
//------------------------------------------------------------------------------
#ifdef __cplusplus

// GPIO class interface
class GpioClass {                                              

    public:
    GpioClass(void);
    ~GpioClass(void);

    UINT8 GetSignalState(   GPIO_PORT port, UINT32 signal);
    void SetSignalState(    GPIO_PORT port, 
                            UINT32 signal, 
                            UINT8 state,
                            BOOL bInPowerMode);
    UINT32 GpioClass::GetSignals(GPIO_PORT port, UINT32 signalMask);
    void SetSignals(    GPIO_PORT port, 
                        UINT32 signalMask, 
                        UINT32 stateMask);

    GPIO_INT_TYPE SetInterruptType( GPIO_PORT port, 
                                    UINT32 signal, 
                                    GPIO_INT_TYPE type);
    void EnableInterrupt( GPIO_PORT port, UINT32 signal, BOOL bInPowerMode);
    void DisableInterrupt(  GPIO_PORT port, UINT32 signal, BOOL bInPowerMode);
    void Display(void);

    private:
    inline void Lock(void) { WaitForSingleObject(m_mutex, INFINITE); };
    inline void Unlock(void) { ReleaseMutex(m_mutex); };

    HANDLE m_mutex;
    CSP_GPIO_REGS *m_pGpioReg;
};

// GPT class interface
class TimerClass {
    public:
    TimerClass(TIMERID_C TimerID);
    ~TimerClass(void);

    void StartTimer(void);
    void StopTimer(void);
    void EnableTimerInterrupt(void);
    void DisableTimerInterrupt(void);
    BOOL SetTimerDelay(TIMERMODE_C timerMode, UINT32 period, TIMERPERIODTYPE_C type);
    void TimerISRLoop(UINT32 timeout);
    BOOL TimerInit(void);
    void TimerDeInit(void);
    void inline SetISR(TIMERISR IsrRoutine) { ISR = IsrRoutine;}
    

    TIMERISR ISR;

    private:
    BOOL TimerHwResourceLock(BOOL bLock);
    TIMERID_C m_TimerID;
    DWORD m_sysintr;
    TIMERINTERRUPT_C m_intrType;    // reserved
    HANDLE irqevent;        // timer irq event handler
    HANDLE  hThread;        // thread handler
    CSP_GPT_REGS *ptimerReg;        // pointer to timer register
    BOOL timerMutexState;       // the flag shows if we got the mutex or not
    HANDLE  Mutex;
};

// CSPI class interface
class CspiClass {

    public:
    CspiClass(CSPIID_C CspiId);
    ~CspiClass();
    BOOL Configure(PCSPICONFIGDATA_T pData); 
    BOOL ChipSelect(CSPISSPORTID_C PortId);
    void CspiHwResourceLock(BOOL bLock);
    UINT8 Exchange(UINT32 *pTxBuf, UINT32 *pRxBuf, UINT8 NumOfWords);

    BOOL SetSwap(BOOL bSwap);
    BOOL StartDMAExchange(UINT8 mode);
    BOOL StopDMAExchange(UINT8 mode);
    UINT32 ReadRxFifo();
    BOOL IsRxFifoDataReady();
    BOOL IsExchangeOngoing();

    private:
    CSPIID_C Id;
    BOOL IsGetLock;
    CSP_CSPI_REGS *pCspiReg;
    HANDLE  csMutex[2];
    HANDLE  csEvent[2];
    BOOL Initialize(void);
    UINT32 CalculateDivRate(UINT32 dwFrequency);
    BOOL ConfigureSSPin(CSPISSPORTID_C PortId, BOOL enable);
};

// I2C class interface
class I2cClass {
   public:
      int GetErrorCode(void);
      
      void WriteMasterData(BYTE byAddress, BYTE* pbyDataBuffer, int iDataSize);
      void ReadMasterData(BYTE byAddress, BYTE* pbyRxDataBuffer, int iRxDataSize);
      
      BOOL inline IsLocked(void) { return lockAcquired; };
      
      void Lock(void);
      void Unlock(void);
      
      BOOL SetFrequency(DWORD dwFrequency);
      
      I2cClass(void);
      ~I2cClass(void);
      
   private:
      CSP_I2C_REGS *FpI2C;
      HANDLE FhMutex;
      HANDLE FhSemaphore;
      BOOL lockAcquired;
      UINT32 FiSrcFreq;

      BYTE FpbyRxDefaultBuffer[I2C_RXBUFFER_SIZE];
      BOOL FbMasterMode;        // TRUE: Master, FALSE: Slave
      volatile BOOL FbTxMode;       // TRUE: Tx,     FALSE: Rx
      volatile BOOL FbProcessTxMode;    // TRUE: Tx,     FALSE: Rx
      volatile BOOL FbProgress;     // TRUE: Progressing, FALSE: Terminated
      BYTE *FpbyTxBuffer, *FpbyRxBuffer;
      int FiTxBufferSize, FiRxBufferSize;
      volatile int FiTxProgressIndex, FiRxProgressIndex;
      volatile int FiErrorCode;
      
      BOOL Init(DWORD dwFrequency, BYTE byAddress);
      void Deinit(void);
      WORD ClockRateDivider(DWORD dwFrequency);
      
      void DoTransfer(void);
};


#endif /* ifdef _cplusplus */

#endif /* __DRVLIB_H */

//------------------------------------------------------------------------------
// END OF FILE
//------------------------------------------------------------------------------

⌨️ 快捷键说明

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