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

📄 portio.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
字号:
/* * * COPYRIGHT:            See COPYING in the top level directory * PROJECT:              ReactOS kernel * FILE:                 services/dd/mpu401/portio.c (see also mpu401.h) * PURPOSE:              MPU-401 MIDI port I/O helper * PROGRAMMER:           Andrew Greenwood * UPDATE HISTORY: *                       Sept 26, 2003: Created */#include <ntddk.h>#include "mpu401.h"BOOLEAN WaitToSend(ULONG BasePort){    int TimeOut;    DbgPrint("WaitToSend ");    // Check if it's OK to send    for (TimeOut = MPU401_TIMEOUT;         ! MPU401_READY_TO_SEND(BasePort) && TimeOut > 0;         TimeOut --);    // If a time-out occurs, we report failure    if (! TimeOut)    {        DbgPrint("FAILED\n");        return FALSE;    }    DbgPrint("SUCCEEDED\n");    return TRUE;}BOOLEAN WaitToReceive(ULONG BasePort){    int TimeOut;    DbgPrint("WaitToSend ");    // Check if it's OK to receive    for (TimeOut = MPU401_TIMEOUT;         ! MPU401_READY_TO_RECEIVE(BasePort) && TimeOut > 0;         TimeOut --);    // If a time-out occurs, we report failure    if (! TimeOut)    {        DbgPrint("FAILED\n");        return FALSE;    }    DbgPrint("SUCCEEDED\n");    return TRUE;}BOOLEAN InitUARTMode(ULONG BasePort){    ULONG TimeOut;    UCHAR Status = 0;    DbgPrint("InitUARTMode() called\n");    // Check if it's OK to send    if (! WaitToSend(BasePort))        return FALSE;    DbgPrint("Resetting MPU401\n");    // Send an MPU reset:    MPU401_WRITE_COMMAND(BasePort, 0xff);    // Check if it's OK to receive (some cards will ignore the above reset    // command and so will not issue an ACK, so time out is NOT an error)    DbgPrint("Waiting for an ACK\n");    if (WaitToReceive(BasePort))    {        // Check to make sure the reset was acknowledged:        for (TimeOut = MPU401_TIMEOUT;             (Status = (MPU401_READ_DATA(BasePort) & 0xfe) && TimeOut > 0);             TimeOut --);    }    DbgPrint("Entering UART mode\n");    // Now we kick the MPU401 into UART ("dumb") mode    MPU401_WRITE_COMMAND(BasePort, 0x3f);    return TRUE;}

⌨️ 快捷键说明

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