ReactOS  0.4.15-dev-5142-g967f5b9
midiuart.c File Reference
#include <ntddk.h>
#include "midiuart.h"
Include dependency graph for midiuart.c:

Go to the source code of this file.

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)
 

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
#define FALSE
Definition: types.h:117
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
#define FALSE
Definition: types.h:117
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
#define FALSE
Definition: types.h:117
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
#define FALSE
Definition: types.h:117
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
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