Skip to content

Commit

Permalink
Added support for OE pin
Browse files Browse the repository at this point in the history
  • Loading branch information
ctacke committed Sep 6, 2023
1 parent 297f83e commit dc3aaaf
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ private x74595()
/// <param name="spiBus">SpiBus object</param>
/// <param name="pinChipSelect">The chip select pin</param>
/// <param name="initialStates">An optional list of initial states for the pins. Omitting this will initialize all pins to low.</param>
public x74595(ISpiBus spiBus, IPin pinChipSelect, int pins = 8, bool[]? initialStates = null)
/// <param name="outputEnable">An optional pin connected to OE used for initializing startup state</param>
public x74595(ISpiBus spiBus, IPin pinChipSelect, int pins = 8, IPin? outputEnable = null, bool[]? initialStates = null)
{
if (initialStates != null && initialStates.Length != pins)
{
Expand All @@ -92,8 +93,15 @@ public x74595(ISpiBus spiBus, IPin pinChipSelect, int pins = 8, bool[]? initialS

latchData = new byte[numberOfChips];

IDigitalOutputPort? oe = null;

if (outputEnable != null)
{
oe = outputEnable.CreateDigitalOutputPort(true);
}

// start with the CS/OE/lath *high* which put the outputs in high-Z while we clear things to a known state
spiComms = new SpiCommunications(spiBus, pinChipSelect?.CreateDigitalOutputPort(true), DefaultSpiBusSpeed, DefaultSpiBusMode);
spiComms = new SpiCommunications(spiBus, pinChipSelect?.CreateDigitalOutputPort(), DefaultSpiBusSpeed, DefaultSpiBusMode);

// the chip register is in an unknown state right now - we need to set the data before the initial latch
if (initialStates != null)
Expand Down Expand Up @@ -121,6 +129,11 @@ public x74595(ISpiBus spiBus, IPin pinChipSelect, int pins = 8, bool[]? initialS
{
Clear();
}

if (oe != null)
{
oe.State = false;
}
}
else
{
Expand Down

0 comments on commit dc3aaaf

Please sign in to comment.