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

📄 ccser_pdd.c

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 C
📖 第 1 页 / 共 2 页
字号:
 *
 */
static
BOOL
CCSerDeinit(
    PVOID   pHead	// @parm PVOID returned by CCSerInit.
    )
{
    PSER_INFO	pHWHead = (PSER_INFO)pHead;
    
    if ( !pHWHead )
        return FALSE;

     // Make sure device is closed before doing DeInit
    if( pHWHead->cOpenCount )
        CCSerClose( pHead );

    if ( pHWHead->pBaseAddress )
        VirtualFree(pHWHead->pBaseAddress, 0, MEM_RELEASE);
    
    LocalFree(pHWHead);

    return TRUE;
}

/*
 @doc OEM
 @func	VOID | CCSerGetCommProperties | Retrieves Comm Properties.
 *
 @rdesc	None.
 */
static
VOID
CCSerGetCommProperties(
    PVOID	pHead,	    // @parm PVOID returned by CCSerInit. 
    LPCOMMPROP	pCommProp   // @parm Pointer to receive COMMPROP structure. 
    )
{
    PSER_INFO	pHWHead = (PSER_INFO)pHead;

    *pCommProp = pHWHead->CommProp;
    return;
}


/*
 @doc OEM
 @func VOID | CCSerSetBaudRate |
 * This routine sets the baud rate of the device.
 *  Not exported to users, only to driver.
 *
 @rdesc None.
 */
static
BOOL
CCSerSetBaudRate(
    PVOID   pHead,	// @parm     PVOID returned by CCSerInit
    ULONG   BaudRate	// @parm     ULONG representing decimal baud rate.
    )
{
    PSER_INFO	pHWHead = (PSER_INFO)pHead;

     // If we are running in IR mode, try to set the IR baud
     // first, since it supports a subset of the rates supported
     // by the UART.  If we fail setting the IR rate, then
     // return an error and leave the UART alone.
    if( pHWHead->fIRMode )
    {
        if( ! CCSerSetIRBaudRate( pHWHead, BaudRate ) )
        {
            DEBUGMSG (ZONE_ERROR, 
                      (TEXT("Unsupported IR BaudRate\r\n")));
             // We should return an error, but vtbl doesn't expect one
            return FALSE; 
        }
    }

     // Now set buadrate on the UART
    return( SL_SetBaudRate( pHead, BaudRate ) );    
}

/*
 @doc OEM
 @func BOOL | CCSerPowerOff |
 *  Called by driver to turn off power to serial port.
 *  Not exported to users, only to driver.
 *
 @rdesc This routine returns a status.
 */
static
BOOL
CCSerPowerOff(
    PVOID   pHead	    // @parm	PVOID returned by CCSerInit.
    )
{
    PSER_INFO	pHWHead = (PSER_INFO)pHead;

     // First, power down the UART
    SL_PowerOff( pHWHead );
    
     // And then disable our IR and 9 Pin interface
    CCSerSetOutputMode( pHWHead, FALSE, FALSE );
    
    return TRUE;
}
 
/*
 @doc OEM
 @func BOOL | CCSerPowerOn |
 *  Called by driver to turn on power to serial port.
 *  Not exported to users, only to driver.
 *
 @rdesc This routine returns a status.
 */
static
BOOL
CCSerPowerOn(
    PVOID   pHead	    // @parm	PVOID returned by CCSerInit.
    )
{
    PSER_INFO	pHWHead = (PSER_INFO)pHead;

     // First, power up the UART
    SL_PowerOn( pHWHead );
    
     // And then enable our IR interface (if needed)
    CCSerSetOutputMode( pHWHead, pHWHead->fIRMode, !pHWHead->fIRMode );
    return TRUE;
}

/*
 @doc OEM
 @func BOOL | CCSerEnableIR | This routine enables ir.
 *  Not exported to users, only to driver.
 *
 @rdesc Returns TRUE if successful, FALSEotherwise.
 */
static
BOOL
CCSerEnableIR(
    PVOID   pHead, // @parm PVOID returned by CCSerinit.
    ULONG   BaudRate  // @parm PVOID returned by HWinit.
    )
{
    PSER_INFO	pHWHead = (PSER_INFO)pHead;

     // Not sure why he passes baudRate when its already in our
     // pHWHead.  So I'll ignore it and use the one in our struct.
    pHWHead->fIRMode  = TRUE;
    CCSerSetOutputMode( pHWHead, pHWHead->fIRMode, !pHWHead->fIRMode );
    return TRUE;
}

/*
 @doc OEM
 @func BOOL | CCSerDisableIR | This routine disable the ir.
 *  Not exported to users, only to driver.
 *
 @rdesc Returns TRUE if successful, FALSEotherwise.
 */
static
BOOL
CCSerDisableIR(
    PVOID   pHead /*@parm PVOID returned by CCSerinit. */
    )
{
    PSER_INFO	pHWHead = (PSER_INFO)pHead;

    pHWHead->fIRMode  = FALSE;
    CCSerSetOutputMode( pHWHead, pHWHead->fIRMode, !pHWHead->fIRMode );
    return TRUE;
}

/*
 @doc OEM
 @func BOOL | CCSerOpen | This routine is called when the port is opened.
 *  Not exported to users, only to driver.
 *
 @rdesc Returns TRUE if successful, FALSEotherwise.
 */
static
BOOL
CCSerOpen(
    PVOID   pHead /*@parm PVOID returned by CCSerinit. */
    )
{

    PSER_INFO	pHWHead = (PSER_INFO)pHead;

     // Disallow multiple simultaneous opens
    if( pHWHead->cOpenCount )
        return FALSE;

    pHWHead->cOpenCount++;

    DEBUGMSG (ZONE_OPEN,
              (TEXT("CCSerOpen - Selecting Non IR Mode\r\n")));

    pHWHead->fIRMode  = FALSE;   // Select wired by default
    CCSerSetOutputMode(pHWHead, pHWHead->fIRMode, !pHWHead->fIRMode );  

    // BUGBUG - If we want to support 16450s, we'll need to dynamically
    // identify them here.
    pHWHead->ser16550.ChipID = CHIP_ID_16550;

     // Init 16550 info
    DEBUGMSG (ZONE_OPEN, (TEXT("CCSerOpen - Calling SL_Open\r\n")));
    SL_Open( pHWHead );
//    SL_Open( &(pHWHead->ser16550) );
    
    return TRUE;
}

#if 0
//
//  @doc OEM
//  @func	BOOL | HWIoctl | Device IO control routine.
//  @parm DWORD | dwOpenData | value returned from COM_Open call
//	@parm DWORD | dwCode | io control code to be performed
//	@parm PBYTE | pBufIn | input data to the device
//	@parm DWORD | dwLenIn | number of bytes being passed in
//	@parm PBYTE | pBufOut | output data from the device
//	@parm DWORD | dwLenOut |maximum number of bytes to receive from device
//	@parm PDWORD | pdwActualOut | actual number of bytes received from device
//
//	@rdesc		Returns TRUE for success, FALSE for failure
//
//  @remark  The MDD will pass any unrecognized IOCTLs through to this function.
//
BOOL
CCSerIoctl(PVOID pHead,DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn,
        PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
    BOOL RetVal = TRUE;
//    DEBUGMSG(ZONE_INIT,(TEXT("CCSerIoctl, Enter.\r\n")));
RETAILMSG(1,(TEXT("CCSerIoctl, Enter.\r\n")));

    switch ( dwCode ) {

    // Currently, no defined IOCTLs
    default:
        RetVal = FALSE;
//        DEBUGMSG (ZONE_INIT, (TEXT(" Unsupported ioctl 0x%X\r\n"), dwCode));
RETAILMSG (1, (TEXT(" Unsupported ioctl 0x%X\r\n"), dwCode));
        break;
    }
//    DEBUGMSG(ZONE_INIT, (TEXT("CCSerIoctl returning %s\r\n"),
RETAILMSG(1, (TEXT("CCSerIoctl returning %s\r\n"),
                         (RetVal == TRUE) ? TEXT("Success") : TEXT("Error")));
    return (RetVal);
}
#endif

const
HW_VTBL CCUARTIoVTbl = {
    CCSerInit,
    CCSerDeinit,
    CCSerOpen,
    CCSerClose,
    SL_RxIntr,
    SL_GetRxStart,
    SL_GetInterruptType,
    SL_OtherIntr,
    SL_LineIntr,
    SL_GetRxBufferSize,
    SL_TxIntr,
    SL_PutBytes,
    CCSerPowerOff,
    CCSerPowerOn,
    SL_ClearDTR,
    SL_SetDTR,
    SL_ClearRTS,
    SL_SetRTS,
    CCSerEnableIR,
    CCSerDisableIR,
    SL_ClearBreak,
    SL_SetBreak,
    SL_XmitComChar,
    SL_GetStatus,
    SL_Reset,
    SL_GetModemStatus,
    CCSerGetCommProperties,
    SL_PurgeComm,
    SL_SetDCB,
    SL_SetCommTimeouts,
    SL_Ioctl
	};

⌨️ 快捷键说明

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