ReactOS 0.4.16-dev-300-g2aadf2e
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 FALSE
Definition: types.h:117
#define WaitForMidiUartDTR(UartBasePort, Timeout)
Definition: midiuart.h:57
#define READ_MIDIUART_DATA(bp)
Definition: midiuart.h:26
static ULONG Timeout
Definition: ping.c:61

◆ 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 READ_MIDIUART_STATUS(bp)
Definition: midiuart.h:28
uint32_t ULONG
Definition: typedefs.h:59

◆ 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 WRITE_MIDIUART_DATA(bp, x)
Definition: midiuart.h:25

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}
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
_Must_inspect_result_ _In_ USHORT DataIndex
Definition: hidpi.h:346
BOOLEAN WriteMidiUartByte(IN PUCHAR UartBasePort, IN UCHAR Data, IN ULONG Timeout)
Definition: midiuart.c:38