None
None
combo data
combo clock
combo latch
combo oe
spinner bits
unsigned int data;
int count;
palSetPadMode(attr_data, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(attr_clock, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(attr_latch, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(attr_oe, PAL_MODE_OUTPUT_PUSHPULL);
palWritePad(attr_oe, 0); // 0 = enable outputs
palWritePad(attr_latch, 0); // latch on rising edge
palWritePad(attr_clock, 0); // clock on rising edge
data = 0;
count = (attr_bits << 1) - 1;
// Sequence: count runs from attr_bits<<1 - 1 down to -2
// When count is >= 0, send corresponding bit to data pin, and pulse clock
// data is clocked on the rising edge of the clock (so in the current
// implementation, data is clocked on the same phase as it is written)
// When count is -1 and -2, pulse latch to transfer data to output register
// oe is low (enabled) at all times
if (count < 0) {
palWritePad(attr_latch, count & 1);
if (count == -2)
count = (attr_bits << 1) - 1;
else
count--;
} else {
palWritePad(attr_data, (data >> (count >> 1)) & 1);
palWritePad(attr_clock, !(count & 1));
count--;
}