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

📄 ser16552.h.bak

📁 2440 wince uart source code
💻 BAK
字号:
//
// 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.
//

#ifndef __SER16552_H__
#define __SER16552_H__

#ifdef __cplusplus
extern "C" {
#endif

#define S16552_Tacs	(0x3)	// 4clk
#define S16552_Tcos	(0x3)	// 4clk
#define S16552_Tacc	(0x7)	// 14clk
#define S16552_Tcoh	(0x3)	// 1clk
#define S16552_Tah	(0x3)	// 4clk
#define S16552_Tacp	(0x3)	// 6clk
#define S16552_PMC	(0x3)	// normal(1data)

typedef struct  {
     	 unsigned int      	rFCR;			// @field FIFO control state. 
        unsigned int 		rIIR;			// @field State of Interrupt Identification Register. 
        unsigned int 		rLSR;			// @field Line Status Register. 
        unsigned int 		rMSR;			// @field Modem Status Register. 
        
        unsigned int 		rIER;			// @field Interrupt Enable Register. 
        unsigned int 		rLCR;			// @field Line Control Register. 
        unsigned int 		rMCR;			// @field Modem Control Register. 
        unsigned int 		rScratch;	
}UART016552reg,UART116552reg;
    
//liujianyong ser_add begin 2003-5-7*****************2003-6-24 10:09 wangyongqiang com34
/*typedef struct __LOOKUP_SER_TBL {
        ULONG   Size;
        PPAIRS  Table;
    } LOOKUP_SER_TBL, *PLOOKUP_SER_TBL;

*/ 
 
__inline
VOID
ReadMSRq(
       PSER16550_INFO  pHWHead
       );

//liujianyong ser_add end 2003-5-7****************** 2003-6-24 10:09 wangyongqiang com34


  /*  

    typedef struct __LS_SER_HW_INFO
    {
         // Store volatile pointers to each SA1100 Serial registers 
        volatile struct uart *pUART;
		volatile struct SA1111DBRegisterBlock *pSA1111BDReg;

		// We have an event callback into the MDD
        EVENT_FUNC EventCallback; // This callback exists in MDD
        PVOID        pMddHead;  // This is the first parm to callback
        
         // Keep a copy of DCB since we rely on may of its parms
        DCB         dcb;        // @field Device Control Block (copy of DCB in MDD)
         // And the same thing applies for CommTimeouts
        COMMTIMEOUTS CommTimeouts;  // @field Copy of CommTimeouts structure

		BOOL		PowerDownFlag;
		volatile struct uart uartPowerRegs;

		BOOL		bIr;
        
         // Misc fields used by ser16550 library
        ULONG		OpenCount;	    // @field Count of simultaneous opens. 
        PLOOKUP_TBL pBaudTable;     // @field Pointer to Baud Table
        ULONG		DroppedBytes;	// @field Number of dropped bytes 
        HANDLE		FlushDone;		// @field Handle to flush done event.
        BOOL		CTSFlowOff;		// @field Flag - CTS flow control state. 
        BOOL		DSRFlowOff;		// @field Flag - DSR flow control state. 
		BOOL		AddTXIntr;		// @field Flag - Fake a TX intr.
        COMSTAT		Status; 		// @field Bitfield representing Win32 comm status. 
        ULONG		CommErrors;		// @field Bitfield representing Win32 comm error status. 
        ULONG		ModemStatus;	// @field Bitfield representing Win32 modem status. 
        CRITICAL_SECTION	TransmitCritSec; // @field Protects UART TX FIFO from simultaneous access
		ULONG		ChipID;			// @field Chip identifier (CHIP_ID_16550 or CHIP_ID_16450) 
        
        UINT8 MSR;
		UINT8 PrevMSR;
        DWORD dwIOBase;
    } SER_HW_INFO, *PSER_HW_INFO;
*/
//extern const LOOKUP_TBL  LS_BaudTable;

//extern const LOOKUP_SER_TBL  SER_BaudTable;
//liujianyong ser_add 2003-5-9*******************2003-6-24 10:09 wangyongqiang com34


// Macros to read/write serial registers.
//define INB(pInfo, reg) (READ_PORT_UCHAR((UCHAR *)((pInfo)->reg)))
//#define OUTB(pInfo, reg, value) (WRITE_PORT_UCHAR((UCHAR *)((pInfo)->reg), (unsigned char)(value)))
// Modified macros for ULONGs instead of UCHARs
// In Cotulla's 16550 UART, we always do 32 bit reads/writes,
// even though the actual data is in the least significant byte only. 
//#define INB(pInfo, reg)			( (*((pInfo)->reg)) & 0xff) 
//#define OUTB(pInfo, reg, value)	( *((pInfo)->reg) = ((value) & 0xff)   )

#define INB(pInfo, reg) (READ_PORT_UCHAR((UCHAR *)((pInfo)->reg)))
#define OUTB(pInfo, reg, value) (WRITE_PORT_UCHAR((UCHAR *)((pInfo)->reg), (unsigned char)(value)))

typedef struct __SER_16550_INFO {
        // Put lib struct first so we can easily cast pointers
        SER16550_INFO  ser16550;

        // now hardware specific info
        DWORD       dwIOBase;       // @field IO Base Address - unmapped
        DWORD       dwIOLen;        // @field IO Length
        DWORD       dwIRQ;          // @field Interrupt number for this peripheral
        DWORD       dwDevIndex;     // @field Index of device

        PUCHAR      pBaseAddress;   // @field Start of serial registers - mapped
     	
        UINT8       cOpenCount;     // @field Count of concurrent opens
        COMMPROP    CommProp;       // @field Pointer to CommProp structure.
        PVOID       pMddHead;       // @field First arg to mdd callbacks.
        BOOL        fIRMode;        // @field Boolean, are we running in IR mode?
   #ifdef EXAMINE_BOOTARGS
        PBOOT_ARGS  pBootArgs;      // @field Pointer to global boot args struct
    #endif    
            PHWOBJ      pHWObj;         // @field Pointer to PDDs HWObj structure
 } SER_16552_INFO, *PSER_16552_INFO;


//liujianyong ser_add begin 2003-5-9**************************************2003-6-24 10:09 wangyongqiang com34
   VOID SL_Initq(
        PVOID   pHead, //  points to device head
        PUCHAR  pRegBase, // Pointer to 16550 register base
        UINT8   RegStride, // Stride amongst the 16550 registers
        EVENT_FUNC EventCallback, // This callback exists in MDD
        PVOID   pMddHead,   // This is the first parm to callback
        PLOOKUP_TBL pBaudTable  // Pointer to baud rate table
        );
    BOOL SL_PostInitq(
        PVOID   pHead 
        );
    VOID SL_Deinitq(
        PVOID   pHead //  points to device head
        );
    VOID SL_Openq(
        PVOID   pHead 
        );
    VOID SL_Closeq(
        PVOID   pHead
        );
    VOID SL_ClearDTRq(
        PVOID   pHead 
        );
    VOID SL_SetDTRq(
        PVOID   pHead 
        );
    VOID SL_ClearRTSq(
        PVOID   pHead 
        );
    VOID SL_SetRTSq(
        PVOID   pHead 
        );
    VOID SL_ClearBreakq(
        PVOID   pHead 
        );
    VOID SL_SetBreakq(
        PVOID   pHead 
        );
    VOID SL_ClearBreakq(
        PVOID   pHead 
        );
    VOID SL_SetBreakq(
        PVOID   pHead
        );
    ULONG SL_GetByteNumberq(
        PVOID   pHead	     
        );
    VOID SL_DisableXmitq(
        PVOID   pHead	
        );
    VOID SL_EnableXmitq(
        PVOID   pHead	
        );
    BOOL SL_SetBaudRateq(
        PVOID   pHead,
        ULONG   BaudRate	//      ULONG representing decimal baud rate.
        );
    BOOL SL_SetDCBq(
        PVOID   pHead,	
        LPDCB   lpDCB       //     Pointer to DCB structure
        );
    ULONG SL_SetCommTimeoutsq(
        PVOID   pHead,	
        LPCOMMTIMEOUTS   lpCommTimeouts //  Pointer to CommTimeout structure
        );
    ULONG SL_GetRxBufferSizeq(
        PVOID pHead
        );
    PVOID SL_GetRxStartq(
        PVOID   pHead
        );
    INTERRUPT_TYPE SL_GetInterruptTypeq(
        PVOID pHead
        );
    ULONG SL_RxIntrq(
        PVOID pHead,
        PUCHAR pRxBuffer,       // Pointer to receive buffer
        ULONG *pBufflen         //  In = max bytes to read, out = bytes read
        );
    ULONG SL_PutBytesq(
        PVOID   pHead,
        PUCHAR  pSrc,	    // 	Pointer to bytes to be sent.
        ULONG   NumberOfBytes,  // 	Number of bytes to be sent.
        PULONG  pBytesSent	    // 	Pointer to actual number of bytes put.
        );
    VOID SL_TxIntrq(
        PVOID pHead 
        );
    VOID
SL_TxIntrExq(
           PVOID pHead,                // Hardware Head
           PUCHAR pTxBuffer,          // @parm Pointer to receive buffer
           ULONG *pBufflen            // @parm In = max bytes to transmit, out = bytes transmitted
           );
    VOID SL_LineIntrq(
        PVOID pHead
        );
    VOID SL_OtherIntrq(
        PVOID pHead 
        );
    VOID SL_ModemIntrq(
        PVOID pHead 
        );
    ULONG SL_GetStatusq(
        PVOID	pHead,
        LPCOMSTAT	lpStat	// Pointer to LPCOMMSTAT to hold status.
        );
    VOID SL_Resetq(
        PVOID   pHead
        );
    VOID SL_GetModemStatusq(
        PVOID   pHead,
        PULONG  pModemStatus    //  PULONG passed in by user.
        );
    VOID SL_PurgeCommq(
        PVOID   pHead,
        DWORD   fdwAction	    //  Action to take. 
        );
    BOOL SL_XmitComCharq(
        PVOID   pHead,
        UCHAR   ComChar   //  Character to transmit. 
        );
    VOID SL_PowerOnq(
        PVOID   pHead
        );
    VOID SL_PowerOffq(
        PVOID   pHead
        );
    BOOL SL_Ioctlq(
        PVOID pHead,
        DWORD dwCode,
        PBYTE pBufIn,
        DWORD dwLenIn,
        PBYTE pBufOut,
        DWORD dwLenOut,
        PDWORD pdwActualOut);

    VOID SL_TxIntrExq(
        PVOID pHead,
	    PUCHAR pTxBuffer,          // @parm Pointer to receive buffer
	    ULONG *pBufflen            // @parm In = max bytes to transmit, out = bytes transmitted
        );



	static
PVOID
Ser3Init(
       ULONG   Identifier, // @parm Device identifier.
       PVOID   pMddHead    // @parm First argument to mdd callbacks.
       );
/*	
BOOL
Ser3_GetRegistryData(PSER_INFO pHWHead, LPCTSTR regKeyPath);

static
void
SerSetOutputMode3(
                PSER_INFO   pHWHead,
                BOOL UseIR,     // @parm     BOOL Should we use IR interface
                BOOL Use9Pin    // @parm     BOOL Should we use Wire interface
                );

BOOL
Ser3_GetRegistryData(PSER_INFO pHWHead, LPCTSTR regKeyPath);
*/
static
BOOL
Ser3Open(
       PVOID   pHead /*@parm PVOID returned by Serinit. */
       );
static
BOOL
Ser3PowerOn(
          PVOID   pHead       // @parm	PVOID returned by SerInit.
          );
static
BOOL
Ser3EnableIR(
           PVOID   pHead, // @parm PVOID returned by Serinit.
           ULONG   BaudRate  // @parm PVOID returned by HWinit.
           );
static
BOOL
Ser3DisableIR(
            PVOID   pHead /*@parm PVOID returned by Serinit. */
            );
static
BOOL
Ser3PowerOff(
           PVOID   pHead       // @parm	PVOID returned by SerInit.
           );
static
BOOL
Ser3Deinit(
         PVOID   pHead   // @parm PVOID returned by SerInit.
         );
static
ULONG
Ser3Close(
        PVOID   pHead   // @parm PVOID returned by SerInit.
        );
static
VOID
Ser3GetCommProperties(
                    PVOID   pHead,      // @parm PVOID returned by SerInit. 
                    LPCOMMPROP  pCommProp   // @parm Pointer to receive COMMPROP structure. 
                    );




void usWait(unsigned usVal);
	
//liujianyong ser_add end 2003-5-9**************************************2003-6-24 10:09 wangyongqiang com34


BOOL IsModemCtsOn(PVOID pHWHead);

BOOL IsModemDsrOn(PVOID pHWHead);

DWORD GetModemCapabilities();


#endif __SER16552_H__

⌨️ 快捷键说明

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