ReactOS 0.4.15-dev-8422-g6219a1a
portio.c File Reference
#include <ntddk.h>
#include "mpu401.h"
Include dependency graph for portio.c:

Go to the source code of this file.

Functions

BOOLEAN WaitToSend (ULONG BasePort)
 
BOOLEAN WaitToReceive (ULONG BasePort)
 
BOOLEAN InitUARTMode (ULONG BasePort)
 

Function Documentation

◆ InitUARTMode()

BOOLEAN InitUARTMode ( ULONG  BasePort)

Definition at line 64 of file portio.c.

65{
66 ULONG TimeOut;
67 UCHAR Status = 0;
68
69 DbgPrint("InitUARTMode() called\n");
70
71 // Check if it's OK to send
72 if (! WaitToSend(BasePort))
73 return FALSE;
74
75 DbgPrint("Resetting MPU401\n");
76
77 // Send an MPU reset:
78 MPU401_WRITE_COMMAND(BasePort, 0xff);
79
80 // Check if it's OK to receive (some cards will ignore the above reset
81 // command and so will not issue an ACK, so time out is NOT an error)
82 DbgPrint("Waiting for an ACK\n");
83 if (WaitToReceive(BasePort))
84 {
85 // Check to make sure the reset was acknowledged:
86 for (TimeOut = MPU401_TIMEOUT;
87 (Status = (MPU401_READ_DATA(BasePort) & 0xfe) && TimeOut > 0);
88 TimeOut --);
89 }
90
91 DbgPrint("Entering UART mode\n");
92 // Now we kick the MPU401 into UART ("dumb") mode
93 MPU401_WRITE_COMMAND(BasePort, 0x3f);
94
95 return TRUE;
96}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOLEAN WaitToReceive(ULONG BasePort)
Definition: portio.c:40
BOOLEAN WaitToSend(ULONG BasePort)
Definition: portio.c:16
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
#define MPU401_WRITE_COMMAND(bp, x)
Definition: mpu401.h:55
#define MPU401_TIMEOUT
Definition: mpu401.h:31
#define MPU401_READ_DATA(bp)
Definition: mpu401.h:54
uint32_t ULONG
Definition: typedefs.h:59
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by InitDevice().

◆ WaitToReceive()

BOOLEAN WaitToReceive ( ULONG  BasePort)

Definition at line 40 of file portio.c.

41{
42 int TimeOut;
43
44 DbgPrint("WaitToSend ");
45
46 // Check if it's OK to receive
47 for (TimeOut = MPU401_TIMEOUT;
48 ! MPU401_READY_TO_RECEIVE(BasePort) && TimeOut > 0;
49 TimeOut --);
50
51 // If a time-out occurs, we report failure
52 if (! TimeOut)
53 {
54 DbgPrint("FAILED\n");
55 return FALSE;
56 }
57
58 DbgPrint("SUCCEEDED\n");
59
60 return TRUE;
61}
#define MPU401_READY_TO_RECEIVE(bp)
Definition: mpu401.h:64

Referenced by InitSoundCard(), and InitUARTMode().

◆ WaitToSend()

BOOLEAN WaitToSend ( ULONG  BasePort)

Definition at line 16 of file portio.c.

17{
18 int TimeOut;
19
20 DbgPrint("WaitToSend ");
21
22 // Check if it's OK to send
23 for (TimeOut = MPU401_TIMEOUT;
24 ! MPU401_READY_TO_SEND(BasePort) && TimeOut > 0;
25 TimeOut --);
26
27 // If a time-out occurs, we report failure
28 if (! TimeOut)
29 {
30 DbgPrint("FAILED\n");
31 return FALSE;
32 }
33
34 DbgPrint("SUCCEEDED\n");
35
36 return TRUE;
37}
#define MPU401_READY_TO_SEND(bp)
Definition: mpu401.h:61

Referenced by InitSoundCard(), and InitUARTMode().