dioscuri.module.pit
Class Counter

java.lang.Object
  extended by 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
           
protected  byte[] ce
           
protected  int counterMode
           
protected  byte[] cr
           
protected static int LSB
           
protected static int MSB
           
protected  byte[] ol
           
protected  boolean readBackCmd
           
protected  int rwMode
           
 
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.
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

counterMode

protected int counterMode

rwMode

protected int rwMode

bcd

protected boolean bcd

ce

protected byte[] ce

cr

protected byte[] cr

ol

protected byte[] ol

readBackCmd

protected boolean readBackCmd

LSB

protected static final int LSB
See Also:
Constant Field Values

MSB

protected static final int MSB
See Also:
Constant Field Values
Constructor Detail

Counter

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

Parameters:
pit -
counterNumber -
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:
status -

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:
data -

setCounterMode

protected void setCounterMode(int mode)
Set counter mode

Parameters:
mode -

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.


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:
status -

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