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

📄 esi.c

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 C
字号:
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1998  Microsoft Corporation

Module Name:

    esi.c

Abstract:

    This file implemements the device specific initialiation,
    deinitialization and setting baud rates routines for the Extended 
    Systems JetEye ESI-9680 IR dongle.

Functions:

    EsiInit
    EsiDeinit
    EsiSetSpeed
    EsiGetCaps

Notes:


--*/

#include "irsirp.h"

/*++

 Function:       EsiInit

 Description:    Initializes the Extended Systems ESI-9680 IR dongle.

 Arguments:

    hSerialDevObj   - Handle to the serial device object which the dongle
                      is connected to.
                      
 Returns:

    NDIS_STATUS 
    
        NDIS_STATUS_SUCCESS - Initialization completed successfully.

 Comments:

    The Extended Systems dongle does not require any special setup.
    
--*/

NDIS_STATUS 
EsiInit(
    IN HANDLE hSerialDevObj
    )
{
    ASSERT(hSerialDevObj != INVALID_HANDLE_VALUE);
    return (NDIS_STATUS_SUCCESS);
}

/*++

 Function:       EsiDeinit

 Description:    Deinitializes the Extended Systems ESI-9680 IR dongle.

 Arguments:

    hSerialDevObj   - Handle to the serial device object which the dongle
                      is connected to.
                      
 Returns:

    NDIS_STATUS
    
        NDIS_STATUS_SUCCESS - Deinit completed successfully.

 Comments:

--*/


NDIS_STATUS 
EsiDeinit(
    IN HANDLE hSerialDevObj
    )
{
    ASSERT(hSerialDevObj != INVALID_HANDLE_VALUE);
    return (NDIS_STATUS_SUCCESS);
}

/*++

 Function:       EsiSetSpeed

 Description:    Set the speed (baud rate) of the Extended Systems ESI-9680
                 IR dongle

 Arguments:

    hSerialDevObj   - Handle to the serial device object which the dongle
                      is connected to.
                      
    pDcb            - Pointer to the serial drivers device control block used
                      to set the comm state of the serial device.
                      
    dwNewSpeed      - Value in BPS representing the new speed to set the dongle.                      

 Returns:

    NDIS_STATUS
    
        NDIS_STATUS_SUCCESS - The new baud rate was successfully set.
                               
        NDIS_STATUS_FAILURE - Some serial device failure.                              

 Comments:

    This function is required to perform any operations to allow the dongle
    to operate at the requested speed as well as set the UART to the correct
    baud rate.

--*/

NDIS_STATUS 
EsiSetSpeed(
    IN     HANDLE  hSerialDevObj,
    IN OUT DCB    *pDcb,
    IN     DWORD   dwNewSpeed
    )
{
    NDIS_STATUS status = NDIS_STATUS_SUCCESS;

    ASSERT(hSerialDevObj != INVALID_HANDLE_VALUE);
    ASSERT(pDcb          != NULL);

    DEBUGMSG(ZONE_DONGLE,
             (TEXT("+EsiSetSpeed(0x%.8X, 0x%.8X, %d)\r\n"),
              hSerialDevObj, pDcb, dwNewSpeed)
             );
    
    // OK, This doesn't work since the very first time that I call
    // this function the NewSpeed is the same as the current speed,
    // but we have NOT done any of the dongle specific stuff. Maybe
    // EsiInit should do things to make sure that the dongle is
    // set up.

    /*
    // Shortcut if current speed is same as new requested speed.
    if (dwNewSpeed == pDcb->BaudRate)
    {
        goto done;
    }
    */

    pDcb->BaudRate = dwNewSpeed;
    if (SetCommState(hSerialDevObj, pDcb) == FALSE)
    {
        status = NDIS_STATUS_FAILURE;
        goto done;
    }

    // Communicate with dongle.
    switch (dwNewSpeed)
    {
        case 115200:
            EscapeCommFunction(hSerialDevObj, SETDTR);
            EscapeCommFunction(hSerialDevObj, SETRTS);
            break;

        case 19200:
            EscapeCommFunction(hSerialDevObj, SETDTR);
            EscapeCommFunction(hSerialDevObj, CLRRTS);
            break;

        case 9600:
        default: // By default, set 9600.
            EscapeCommFunction(hSerialDevObj, CLRDTR);
            EscapeCommFunction(hSerialDevObj, SETRTS);
            break;
    }

done:

    DEBUGMSG(ZONE_DONGLE, (TEXT("-EsiSetSpeed [0x%.8X]\r\n"), status));

    return (status);
}

/*++

 Function:       EsiGetCaps

 Description:    Get the ESI dongle capabilities.
                 1) support speed.
                 2) required min TAT.
                 3) required extra BOFs.

 Arguments:

    pDongleCaps     - Pointer to a buffer to return the dongle capabilities.                      

 Returns:

    NDIS_STATUS 
    
        NDIS_STATUS_SUCCESS - Retrieved dongle caps successfully.

 Comments:

--*/

NDIS_STATUS
EsiGetCaps(
    OUT PDONGLE_CAPS pDongleCaps
    )
{
    ASSERT(pDongleCaps   != NULL);

    pDongleCaps->dwSpeedMask = ESI_9680_IRDA_SPEEDS;
    pDongleCaps->dwTAT_usec  = 100;
    pDongleCaps->dwExtraBOFs = 0;      

    return (NDIS_STATUS_SUCCESS);
}

⌨️ 快捷键说明

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