Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenportio.c
Go to the documentation of this file.
00001 /* 00002 * 00003 * COPYRIGHT: See COPYING in the top level directory 00004 * PROJECT: ReactOS kernel 00005 * FILE: services/dd/mpu401/portio.c (see also mpu401.h) 00006 * PURPOSE: MPU-401 MIDI port I/O helper 00007 * PROGRAMMER: Andrew Greenwood 00008 * UPDATE HISTORY: 00009 * Sept 26, 2003: Created 00010 */ 00011 00012 #include <ntddk.h> 00013 #include "mpu401.h" 00014 00015 00016 BOOLEAN WaitToSend(ULONG BasePort) 00017 { 00018 int TimeOut; 00019 00020 DbgPrint("WaitToSend "); 00021 00022 // Check if it's OK to send 00023 for (TimeOut = MPU401_TIMEOUT; 00024 ! MPU401_READY_TO_SEND(BasePort) && TimeOut > 0; 00025 TimeOut --); 00026 00027 // If a time-out occurs, we report failure 00028 if (! TimeOut) 00029 { 00030 DbgPrint("FAILED\n"); 00031 return FALSE; 00032 } 00033 00034 DbgPrint("SUCCEEDED\n"); 00035 00036 return TRUE; 00037 } 00038 00039 00040 BOOLEAN WaitToReceive(ULONG BasePort) 00041 { 00042 int TimeOut; 00043 00044 DbgPrint("WaitToSend "); 00045 00046 // Check if it's OK to receive 00047 for (TimeOut = MPU401_TIMEOUT; 00048 ! MPU401_READY_TO_RECEIVE(BasePort) && TimeOut > 0; 00049 TimeOut --); 00050 00051 // If a time-out occurs, we report failure 00052 if (! TimeOut) 00053 { 00054 DbgPrint("FAILED\n"); 00055 return FALSE; 00056 } 00057 00058 DbgPrint("SUCCEEDED\n"); 00059 00060 return TRUE; 00061 } 00062 00063 00064 BOOLEAN InitUARTMode(ULONG BasePort) 00065 { 00066 ULONG TimeOut; 00067 UCHAR Status = 0; 00068 00069 DbgPrint("InitUARTMode() called\n"); 00070 00071 // Check if it's OK to send 00072 if (! WaitToSend(BasePort)) 00073 return FALSE; 00074 00075 DbgPrint("Resetting MPU401\n"); 00076 00077 // Send an MPU reset: 00078 MPU401_WRITE_COMMAND(BasePort, 0xff); 00079 00080 // Check if it's OK to receive (some cards will ignore the above reset 00081 // command and so will not issue an ACK, so time out is NOT an error) 00082 DbgPrint("Waiting for an ACK\n"); 00083 if (WaitToReceive(BasePort)) 00084 { 00085 // Check to make sure the reset was acknowledged: 00086 for (TimeOut = MPU401_TIMEOUT; 00087 (Status = (MPU401_READ_DATA(BasePort) & 0xfe) && TimeOut > 0); 00088 TimeOut --); 00089 } 00090 00091 DbgPrint("Entering UART mode\n"); 00092 // Now we kick the MPU401 into UART ("dumb") mode 00093 MPU401_WRITE_COMMAND(BasePort, 0x3f); 00094 00095 return TRUE; 00096 } Generated on Sun May 27 2012 04:27:58 for ReactOS by
1.7.6.1
|