nl.kbna.dioscuri.module.pit
Class Counter

java.lang.Object
  extended by nl.kbna.dioscuri.module.pit.Counter

public class Counter
extends java.lang.Object

A single counter of the PIT based on the Intel 82C54 chipset. This counter works following the convention rules of the PIT: 1. For each counter, the control word must be written before the initial count is written. 2. The initial count must follow the count format specified in the Control Word (LSB, MSB, etc.)


Field Summary
protected  boolean bcd
           
private static boolean BCD
           
private static boolean BINARY
           
protected  byte[] ce
           
protected  int counterMode
           
private static int COUNTERMODE_0
           
private static int COUNTERMODE_1
           
private static int COUNTERMODE_2
           
private static int COUNTERMODE_3
           
private static int COUNTERMODE_4
           
private static int COUNTERMODE_5
           
private  int counterNumber
           
protected  byte[] cr
           
private static boolean EVEN
           
private  boolean isEnabled
           
private  boolean isGateRising
           
private  boolean isLatched
           
private  boolean isTriggered
           
private static java.util.logging.Logger logger
           
protected static int LSB
           
private  boolean lsbRead
           
private  boolean lsbWritten
           
protected static int MSB
           
private  boolean newCount
           
private static boolean ODD
           
protected  byte[] ol
           
private  boolean parity
           
private  PIT pit
           
protected  boolean readBackCmd
           
protected  int rwMode
           
private static int RWMODE_0
           
private static int RWMODE_1
           
private static int RWMODE_2
           
private static int RWMODE_3
           
private  boolean signalClock
           
private  boolean signalGate
           
private  boolean signalOut
           
 
Constructor Summary
Counter(PIT pit, int counterNumber)
          Constructor of the counter class
 
Method Summary
 void clockPulse()
          Performs counter action on one clockpulse.
protected  boolean getBCD()
          Return if this counter is in BCD mode
protected  int getCounterNumber()
          Return the counter number (ID)
protected  byte getCounterValue()
          Returns the counter value depending on the R/W mode
protected  boolean getGateSignal()
          Retrieves the GATE signal
protected  boolean getOutSignal()
          Retrieves the OUT signal
protected  boolean getParity()
          Return the parity of the count value
protected  boolean isEnabled()
          Return if this counter has been enabled
protected  void latchCounter()
          Latch this counter (read back current count value) Note: this function only works if the counter is in latchmode.
private  void loadCounter()
          Load counter with new value Note: new value is stored in register cr.
protected  void setCounterMode(int mode)
          Set counter mode
protected  void setCounterValue(byte data)
          Set counter value depending on the R/W mode Note: it is assumed that data is always loaded in LSB, MSB order.
protected  void setEnabled(boolean status)
          Enable/disable the counter
protected  void setGateSignal(boolean status)
          Sets the GATE signal to given status GATE signal is compared with its previous state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pit

private PIT pit

counterNumber

private int counterNumber

signalClock

private boolean signalClock

signalGate

private boolean signalGate

signalOut

private boolean signalOut

counterMode

protected int counterMode

rwMode

protected int rwMode

bcd

protected boolean bcd

ce

protected byte[] ce

cr

protected byte[] cr

ol

protected byte[] ol

isEnabled

private boolean isEnabled

parity

private boolean parity

lsbWritten

private boolean lsbWritten

lsbRead

private boolean lsbRead

isLatched

private boolean isLatched

newCount

private boolean newCount

isTriggered

private boolean isTriggered

isGateRising

private boolean isGateRising

readBackCmd

protected boolean readBackCmd

logger

private static java.util.logging.Logger logger

LSB

protected static final int LSB
See Also:
Constant Field Values

MSB

protected static final int MSB
See Also:
Constant Field Values

ODD

private static final boolean ODD
See Also:
Constant Field Values

EVEN

private static final boolean EVEN
See Also:
Constant Field Values

BINARY

private static final boolean BINARY
See Also:
Constant Field Values

BCD

private static final boolean BCD
See Also:
Constant Field Values

RWMODE_0

private static final int RWMODE_0
See Also:
Constant Field Values

RWMODE_1

private static final int RWMODE_1
See Also:
Constant Field Values

RWMODE_2

private static final int RWMODE_2
See Also:
Constant Field Values

RWMODE_3

private static final int RWMODE_3
See Also:
Constant Field Values

COUNTERMODE_0

private static final int COUNTERMODE_0
See Also:
Constant Field Values

COUNTERMODE_1

private static final int COUNTERMODE_1
See Also:
Constant Field Values

COUNTERMODE_2

private static final int COUNTERMODE_2
See Also:
Constant Field Values

COUNTERMODE_3

private static final int COUNTERMODE_3
See Also:
Constant Field Values

COUNTERMODE_4

private static final int COUNTERMODE_4
See Also:
Constant Field Values

COUNTERMODE_5

private static final int COUNTERMODE_5
See Also:
Constant Field Values
Constructor Detail

Counter

public Counter(PIT pit,
               int counterNumber)
Constructor of the counter class

Method Detail

clockPulse

public void clockPulse()
Performs counter action on one clockpulse. The action depends on the mode the counter is set to, the GATE signal, R/W mode and BCD setting.


getGateSignal

protected boolean getGateSignal()
Retrieves the GATE signal

Returns:
boolean true if GATE is high, false if GATE is low

setGateSignal

protected void setGateSignal(boolean status)
Sets the GATE signal to given status GATE signal is compared with its previous state. If GATE is rising (low -> high), variable isGateRising is set to true If GATE is falling (high -> low), signal OUT is turned high immediately for some counter modes

Parameters:
boolean - status, containing the new value for GATE

getOutSignal

protected boolean getOutSignal()
Retrieves the OUT signal

Returns:
boolean true if OUT is high, false if OUT is low

getCounterValue

protected byte getCounterValue()
Returns the counter value depending on the R/W mode

Returns:
byte data containing the LSB/MSB from Counting Element (ce) or Output latch (ol)

setCounterValue

protected void setCounterValue(byte data)
Set counter value depending on the R/W mode Note: it is assumed that data is always loaded in LSB, MSB order. So, first LSB then MSB.

Parameters:
byte - data containing the LSB/MSB for counter

setCounterMode

protected void setCounterMode(int mode)
Set counter mode

Parameters:
int - mode ranging from 0 to 5

latchCounter

protected void latchCounter()
Latch this counter (read back current count value) Note: this function only works if the counter is in latchmode. The latched value is stored in register ol.


loadCounter

private void loadCounter()
Load counter with new value Note: new value is stored in register cr.


getParity

protected boolean getParity()
Return the parity of the count value

Returns:
boolean true=EVEN, false=ODD

getBCD

protected boolean getBCD()
Return if this counter is in BCD mode

Returns:
boolean true=BCD, false=decimal

setEnabled

protected void setEnabled(boolean status)
Enable/disable the counter

Parameters:
boolean - status defining the status of this counter (true=enabled, false=disabled)

isEnabled

protected boolean isEnabled()
Return if this counter has been enabled

Returns:
true if enabled, false otherwise

getCounterNumber

protected int getCounterNumber()
Return the counter number (ID)

Returns:
int counternumber