void WriteOctet(Octet data) { // The 74HCT595 shift register accepts the most significant bit first. // SO whatever is shifted in forst ends up on output Q7/QH/Pin 7. for (int i = 7; i >= 0; i--) { WriteOneBit(data[i]); } serialClockPositiveEdge.Low(); // Leave the clock low }
/// <summary> /// Writes the specified data pattern and latches it onto the output pins. /// The operation is thread-safe. /// </summary> /// <param name="data"> /// The bit pattern to be written. /// Octet[0] corresponds to output Q0 and Octet[7] corresponds to output Q7. /// </param> public void Write(Octet data) { lock (syncObject) // prevent race condition { latchPositiveEdge.Low(); WriteOctet(data); latchPositiveEdge.High(); outputs = data; outputEnableActiveLow.Low(); } }
public SerialShiftRegister(OutputPort outputEnable, OutputPort serialClock, OutputPort serialData, OutputPort latch) { outputEnableActiveLow = outputEnable; serialClockPositiveEdge = serialClock; this.serialData = serialData; latchPositiveEdge = latch; outputEnable.High(); latchPositiveEdge.Low(); serialClockPositiveEdge.Low(); }
/// <summary> /// Resets the latch so that all motors and outputs are disabled. This method should be called /// before using any of the shield's resources to ensure that the hardware is in a consistent /// state. /// </summary> /// <exception cref="System.NotImplementedException"></exception> public void InitializeShield() { enable.High(); // disables the latch outputs. serialShiftRegister.Write(Octet.Zero); enable.Low(); // Enables the parallel output register drivers. }