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

📄 io.c

📁 SBC2410 WinCE 5.0 BSP.绝大多数驱动已经调通。
💻 C
字号:
//
// 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.
//
//------------------------------------------------------------------------------
//
//  File: io.c
//
//  This file implements Mainstone II input-output routines.
//
#include <windows.h>


UINT16 READ_PORT_USHORT(UINT16 *pAddr)
{
    UINT32 nAlignedAddr = ((UINT32)pAddr & ~0x3);

    if ((UINT32)pAddr & 0x2)    // Is the address an "odd" word within a longword?
    {
        // Yes - read a longword and data is in the upper word.
        return((UINT16) ((*(volatile unsigned long *)nAlignedAddr) >> 16));
    }
    else
    {
        // No - read single word.
        return(*(volatile unsigned short *)nAlignedAddr);
    }
}


void WRITE_PORT_USHORT(UINT16 *pAddr, UINT16 Data)
{
    UINT32 nAlignedAddr = ((UINT32)pAddr & ~0x3);

    if ((UINT32)pAddr & 0x2)    // Is the address an "odd" word within a longword?
    {
        // Yes - write a longword with data in the upper word.
        *(volatile UINT32 *)nAlignedAddr = (READ_PORT_USHORT(pAddr) | (Data << 16));
    }
    else
    {
        // No - write single word.
        *(volatile UINT16 *)pAddr = Data;
    }
}



UCHAR
READ_PORT_UCHAR(
    PUCHAR  Port
    )
{
    return *(volatile UCHAR * const)Port;
}

VOID
WRITE_PORT_UCHAR(
    PUCHAR  Port,
    UCHAR   Value
    )
{
    *(volatile UCHAR * const)Port = Value;
}

VOID
WRITE_REGISTER_USHORT(
    PUSHORT Register,
    USHORT  Value
    )
{
    *(volatile USHORT * const)Register = Value;
}


VOID
WRITE_REGISTER_ULONG(
    PULONG  Register,
    ULONG   Value
    )
{
    *(volatile ULONG * const)Register = Value;
}

USHORT
READ_REGISTER_USHORT(
    PUSHORT Register
    )
{
    return (*(volatile USHORT * const)Register);
}


ULONG
READ_REGISTER_ULONG(
    PULONG  Register
    )
{
    return (*(volatile ULONG * const)Register);
}

⌨️ 快捷键说明

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