using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.Core;
namespace Cosmos.Core.IOGroup
{
///
/// Communication port (COM) class. See also: .
///
public class COM : IOGroup
{
///
/// Data register port.
///
public readonly IOPort Data;
///
/// Interrupt enable register port.
///
public readonly IOPort InterruptEnable;
///
/// FIFO control register port.
///
public readonly IOPort FIFOControl;
///
/// Line control register port.
///
public readonly IOPort LineControl;
///
/// Modem control register port.
///
public readonly IOPort ModemControl;
///
/// Line status register port.
///
public readonly IOPort LineStatus;
///
/// Modem status register port.
///
public readonly IOPort ModemStatus;
///
/// Scratch register port.
///
public readonly IOPort Scratch;
///
/// Initializes a new set of IOPorts for the specified COM port number.
///
/// Can be either 1,2,3, or 4.
public COM(byte comPortNumber)
{
if (comPortNumber > 4 && comPortNumber != 0)
{
throw new Exception("Cosmos.Core->IOGroup->COM.cs-> ERROR: Unknown COM Port.");
}
ushort portBase = 0;
switch (comPortNumber)
{
case 1:
portBase = 0x3F8;
break;
case 2:
portBase = 0x2F8;
break;
case 3:
portBase = 0x3E8;
break;
case 4:
portBase = 0x2E8;
break;
}
Data = new IOPort(portBase);
InterruptEnable = new IOPort(unchecked((ushort)(portBase + 1)));
FIFOControl = new IOPort(unchecked((ushort)(portBase + 2)));
LineControl = new IOPort(unchecked((ushort)(portBase + 3)));
ModemControl = new IOPort(unchecked((ushort)(portBase + 4)));
LineStatus = new IOPort(unchecked((ushort)(portBase + 5)));
ModemStatus = new IOPort(unchecked((ushort)(portBase + 6)));
Scratch = new IOPort(unchecked((ushort)(portBase + 7)));
}
}
}