portio.c
来自「ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机」· C语言 代码 · 共 97 行
C
97 行
/* * * 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 + =
减小字号Ctrl + -
显示快捷键?