ShiftRegister Module

Description

Provides the lower level functions for writing data to a shift-register.  Used by GameTimerLED.c and PrizeLED.c

InitShiftRegister()

Takes 2 OutputT (clock and data), initializes these outputs correspondingly.

LightNext()

Takes 2 OutputT (clock and data), shift 1 into the shiftregister

DontLightNext()

Takes 2 OutputT (clock and data) shift 0 into the shiftregister

Shift()

Take one OutputT as argument (clock), pulse the clock

Implementation

Define constant

SHIFT_REG_DELAY=2

This is the experimentally-determined number of counts we need to wait for the shift register circuits to read our outputs. Warning, if this number gets very large we have blocking code.

InitShiftRegister()

Write 0 to output clock

Write 0 to output data

Count to SHIFT_REG_DELAY (wait some microseconds)

LightNex()t

Write 1 to output data

Count to SHIFT_REG_DELAY

Shift

DontLightNext()

Write 0 to output data

Count to SHIFT_REG_DELAY

Shift

Shift()

Raise the clock high

Count to SHIFT_REG_DELAY

Pull the clock low