ReactOS  0.4.15-dev-499-g1f31905
midiuart.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WRITE_MIDIUART_DATA(bp, x)   WRITE_PORT_UCHAR((PUCHAR) bp, x)
 
#define READ_MIDIUART_DATA(bp)   READ_PORT_UCHAR((PUCHAR) bp)
 
#define WRITE_MIDIUART_COMMAND(bp, x)   WRITE_PORT_UCHAR((PUCHAR) bp+1, x)
 
#define READ_MIDIUART_STATUS(bp)   READ_PORT_UCHAR((PUCHAR) bp+1)
 
#define MIDIUART_STATUS_DTR   0x40
 
#define MIDIUART_STATUS_CTS   0x80
 
#define WaitForMidiUartCTS(UartBasePort, Timeout)   WaitForMidiUartStatus(UartBasePort, MIDIUART_STATUS_CTS, Timeout)
 
#define WaitForMidiUartDTR(UartBasePort, Timeout)   WaitForMidiUartStatus(UartBasePort, MIDIUART_STATUS_DTR, Timeout)
 

Functions

BOOLEAN WaitForMidiUartStatus (IN PUCHAR UartBasePort, IN UCHAR StatusFlags, IN ULONG Timeout)
 
BOOLEAN WriteMidiUartByte (IN PUCHAR UartBasePort, IN UCHAR Data, IN ULONG Timeout)
 
BOOLEAN WriteMidiUartMulti (IN PUCHAR UartBasePort, IN PUCHAR Data, IN ULONG DataLength, IN ULONG Timeout)
 
BOOLEAN ReadMidiUartByte (IN PUCHAR UartBasePort, OUT UCHAR *Data, IN ULONG Timeout)
 

Macro Definition Documentation

◆ MIDIUART_STATUS_CTS

#define MIDIUART_STATUS_CTS   0x80

Definition at line 32 of file midiuart.h.

◆ MIDIUART_STATUS_DTR

#define MIDIUART_STATUS_DTR   0x40

Definition at line 31 of file midiuart.h.

◆ READ_MIDIUART_DATA

#define READ_MIDIUART_DATA (   bp)    READ_PORT_UCHAR((PUCHAR) bp)

Definition at line 26 of file midiuart.h.

◆ READ_MIDIUART_STATUS

#define READ_MIDIUART_STATUS (   bp)    READ_PORT_UCHAR((PUCHAR) bp+1)

Definition at line 28 of file midiuart.h.

◆ WaitForMidiUartCTS

#define WaitForMidiUartCTS (   UartBasePort,
  Timeout 
)    WaitForMidiUartStatus(UartBasePort, MIDIUART_STATUS_CTS, Timeout)

Definition at line 53 of file midiuart.h.

◆ WaitForMidiUartDTR

#define WaitForMidiUartDTR (   UartBasePort,
  Timeout 
)    WaitForMidiUartStatus(UartBasePort, MIDIUART_STATUS_DTR, Timeout)

Definition at line 57 of file midiuart.h.

◆ WRITE_MIDIUART_COMMAND

#define WRITE_MIDIUART_COMMAND (   bp,
  x 
)    WRITE_PORT_UCHAR((PUCHAR) bp+1, x)

Definition at line 27 of file midiuart.h.

◆ WRITE_MIDIUART_DATA

#define WRITE_MIDIUART_DATA (   bp,
  x 
)    WRITE_PORT_UCHAR((PUCHAR) bp, x)

Definition at line 25 of file midiuart.h.

Function Documentation

◆ ReadMidiUartByte()

BOOLEAN ReadMidiUartByte ( IN PUCHAR  UartBasePort,
OUT UCHAR Data,
IN ULONG  Timeout 
)

Definition at line 75 of file midiuart.c.

79 {
80  if ( ! Data )
81  {
82  return FALSE;
83  }
84 
85  if ( ! WaitForMidiUartDTR(UartBasePort, Timeout) )
86  {
87  return FALSE;
88  }
89 
90  *Data = READ_MIDIUART_DATA(UartBasePort);
91 
92  return TRUE;
93 }
#define TRUE
Definition: types.h:120
#define WaitForMidiUartDTR(UartBasePort, Timeout)
Definition: midiuart.h:57
static ULONG Timeout
Definition: ping.c:61
#define READ_MIDIUART_DATA(bp)
Definition: midiuart.h:26

◆ WaitForMidiUartStatus()

BOOLEAN WaitForMidiUartStatus ( IN PUCHAR  UartBasePort,
IN UCHAR  StatusFlags,
IN ULONG  Timeout 
)

Definition at line 19 of file midiuart.c.

23 {
24  ULONG RemainingTime = Timeout;
25 
26  while ( RemainingTime -- )
27  {
28  if ( READ_MIDIUART_STATUS(UartBasePort) & StatusFlags )
29  {
30  return TRUE;
31  }
32  }
33 
34  return FALSE;
35 }
#define TRUE
Definition: types.h:120
#define READ_MIDIUART_STATUS(bp)
Definition: midiuart.h:28
static ULONG Timeout
Definition: ping.c:61
unsigned int ULONG
Definition: retypes.h:1

◆ WriteMidiUartByte()

BOOLEAN WriteMidiUartByte ( IN PUCHAR  UartBasePort,
IN UCHAR  Data,
IN ULONG  Timeout 
)

Definition at line 38 of file midiuart.c.

42 {
43  if ( ! WaitForMidiUartCTS(UartBasePort, Timeout) )
44  {
45  return FALSE;
46  }
47 
48  WRITE_MIDIUART_DATA(UartBasePort, Data);
49 
50  return TRUE;
51 }
#define WaitForMidiUartCTS(UartBasePort, Timeout)
Definition: midiuart.h:53
#define TRUE
Definition: types.h:120
#define WRITE_MIDIUART_DATA(bp, x)
Definition: midiuart.h:25
static ULONG Timeout
Definition: ping.c:61

Referenced by WriteMidiUartMulti().

◆ WriteMidiUartMulti()

BOOLEAN WriteMidiUartMulti ( IN PUCHAR  UartBasePort,
IN PUCHAR  Data,
IN ULONG  DataLength,
IN ULONG  Timeout 
)

Definition at line 54 of file midiuart.c.

59 {
61 
62  for ( DataIndex = 0; DataIndex < DataLength; ++ DataIndex )
63  {
64  if ( ! WriteMidiUartByte(UartBasePort, Data[DataIndex], Timeout) )
65  {
66  /* We failed - don't try writing any more */
67  return FALSE;
68  }
69  }
70 
71  return TRUE;
72 }
#define TRUE
Definition: types.h:120
static ULONG Timeout
Definition: ping.c:61
_Must_inspect_result_ _In_ USHORT DataIndex
Definition: hidpi.h:346
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN WriteMidiUartByte(IN PUCHAR UartBasePort, IN UCHAR Data, IN ULONG Timeout)
Definition: midiuart.c:38
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333