/// <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();
 }
Beispiel #3
0
 /// <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.
 }