RDFU  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
ComPort.c File Reference

Serial (COM) port communication. More...

Include dependency graph for ComPort.c:

Go to the source code of this file.

Macros

#define LSR_OFFSET   0x05
 
#define LSR_RXDA   0x01
 
#define LSR_TXRDY   0x20
 
#define COM_PORT_ADDRESS1   0x3f8
 
#define COM_PORT_ADDRESS2   0x2f8
 
#define COM_PORT_ADDRESS3   0x3e8
 
#define COM_PORT_ADDRESS4   0x2e8
 

Functions

VOID ComInitialize (ULONG ComPortAddr)
 
VOID ComPutChar (UCHAR c)
 
VOID ComPutString (CHAR8 *String)
 
UCHAR ComGetChar (VOID)
 

Variables

ULONG ComPort = COM_PORT_ADDRESS2
 

Detailed Description

Serial (COM) port communication.

Author
Piotr Bania
Date
Feb 2013 Serial (COM) port communication

Definition in file ComPort.c.

Macro Definition Documentation

#define COM_PORT_ADDRESS1   0x3f8

Definition at line 24 of file ComPort.c.

#define COM_PORT_ADDRESS2   0x2f8

Definition at line 25 of file ComPort.c.

#define COM_PORT_ADDRESS3   0x3e8

Definition at line 26 of file ComPort.c.

#define COM_PORT_ADDRESS4   0x2e8

Definition at line 27 of file ComPort.c.

#define LSR_OFFSET   0x05

Definition at line 20 of file ComPort.c.

Referenced by ComGetChar(), and ComPutChar().

#define LSR_RXDA   0x01

Definition at line 21 of file ComPort.c.

Referenced by ComGetChar().

#define LSR_TXRDY   0x20

Definition at line 22 of file ComPort.c.

Referenced by ComPutChar().

Function Documentation

UCHAR ComGetChar ( VOID  )

Definition at line 89 of file ComPort.c.

References ASMReadPortByte(), ComPort, LSR_OFFSET, and LSR_RXDA.

Referenced by ComConsoleStart().

90 {
91 
92  UINT8 Data;
93  CHAR8 Char;
94  do
95  {
97  } while ((Data & LSR_RXDA) == 0);
98 
99  Char = ASMReadPortByte(ComPort);
100  return Char;
101 }

Here is the call graph for this function:

Here is the caller graph for this function:

VOID ComInitialize ( ULONG  ComPortAddr)

Function initializes serial port (com port) that will be used for the communication.

Parameters
ComPortAddrAddress of the com port.
Return values
NONE

Definition at line 44 of file ComPort.c.

References ComPort.

45 {
46  if (ComPortAddr)
47  ComPort = ComPortAddr;
48 }
VOID ComPutChar ( UCHAR  c)

Function writes single character to the selected com port.

Parameters
cCharacter
Return values
NONE

Definition at line 61 of file ComPort.c.

References ASMReadPortByte(), ASMWritePortByte(), ComPort, LSR_OFFSET, and LSR_TXRDY.

Referenced by ComConsoleStart(), and ComPutString().

62 {
63  // wait for tx ready
64  while ((ASMReadPortByte(ComPort + LSR_OFFSET) & LSR_TXRDY) == 0);
66 }

Here is the call graph for this function:

Here is the caller graph for this function:

VOID ComPutString ( CHAR8 *  String)

Function writes selected string to the selected com port.

Parameters
StringPointer to null-terminated string to send.
Return values
NONE

Definition at line 78 of file ComPort.c.

References ComPutChar().

Referenced by LogFileAscii(), and LogFullAscii().

79 {
80  while (String[0] != 0)
81  {
82  ComPutChar((UCHAR)String[0]);
83  String++;
84  }
85 }

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

Definition at line 30 of file ComPort.c.

Referenced by ComGetChar(), ComInitialize(), and ComPutChar().