Skip to content

Commit

Permalink
AntikernelLabsTriggerCrossbar: support for setting output swing. See #…
Browse files Browse the repository at this point in the history
  • Loading branch information
azonenberg committed Apr 27, 2024
1 parent bde5d98 commit 6d8a99c
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 10 deletions.
71 changes: 62 additions & 9 deletions scopehal/AntikernelLabsTriggerCrossbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ AntikernelLabsTriggerCrossbar::AntikernelLabsTriggerCrossbar(SCPITransport* tran
, m_activeScanChannel(0)
, m_activeScanProgress(0)
{

}

AntikernelLabsTriggerCrossbar::~AntikernelLabsTriggerCrossbar()
Expand All @@ -64,38 +63,61 @@ void AntikernelLabsTriggerCrossbar::PostCtorInit()
m_triggerInChannelBase = m_channels.size();
for(size_t i=0; i<8; i++)
{
//high voltage channels are bright, low voltage dim
string color = "#ffff00"; //yellow
if(i < 7)
color = "#808000"; //dark yellow

m_channels.push_back(new DigitalInputChannel(
string("IN") + to_string(i + m_triggerInChannelBase),
this,
"#ffff00", //yellow
color,
m_channels.size()));
}

//Bidir channels
m_triggerBidirChannelBase = m_channels.size();
for(size_t i=0; i<4; i++)
{
auto hwname = string("IO") + to_string(i + m_triggerBidirChannelBase);

//high voltage channels are bright, low voltage dim
string color = "#ff6abc"; //pink
if(i < 2)
color = "#80355e"; //dark pink

m_channels.push_back(new BufferedSwitchMatrixIOChannel(
string("IO") + to_string(i + m_triggerBidirChannelBase),
hwname,
this,
"#ff6abc", //pink
color,
m_channels.size()));

//Get the output drive level
auto reply = Trim(m_transport->SendCommandQueuedWithReply(hwname + ":LEV?"));
m_trigDrive[i + m_triggerBidirChannelBase] = 0.001f * atoi(reply.c_str());
}

//Output-only channels
//TODO: 0-3 are unbuffered, 4-7 are buffered, we need to note this somewhere
//For now we just want to reserve spaces in the channel list
m_triggerOutChannelBase = m_channels.size();
for(size_t i=0; i<8; i++)
{
auto hwname = string("OUT") + to_string(i);

//high voltage channels are bright, low voltage dim
string color = "#00ffff"; //cyan
if(i < 4)
color = "#008080"; //dark cyan

m_channels.push_back(new BufferedSwitchMatrixOutputChannel(
string("OUT") + to_string(i),
hwname,
this,
"#00ffff", //cyan
color,
m_channels.size()));
}

//TODO: figure out mux config stuff
auto reply = Trim(m_transport->SendCommandQueuedWithReply(hwname + ":LEV?"));
m_trigDrive[i] = 0.001f * atoi(reply.c_str());
}

//Set up pattern generator channels
m_txChannelBase = m_channels.size();
Expand Down Expand Up @@ -269,6 +291,37 @@ void AntikernelLabsTriggerCrossbar::SetMuxPathOpen(size_t dstchan)
m_transport->SendCommandQueued(m_channels[dstchan]->GetHwname() + ":DIR IN");
}

bool AntikernelLabsTriggerCrossbar::MuxHasConfigurableDrive(size_t dstchan)
{
//Output channels 0-3 are unbuffered, 4-11 are buffered
size_t relchan = dstchan - m_triggerOutChannelBase;
if( (relchan < 4) || (relchan > 11) )
return false;

return true;
}

float AntikernelLabsTriggerCrossbar::GetMuxOutputDrive(size_t dstchan)
{
size_t relchan = dstchan - m_triggerOutChannelBase;
if( (relchan < 4) || (relchan > 11) )
return 0;

return m_trigDrive[relchan];
}

void AntikernelLabsTriggerCrossbar::SetMuxOutputDrive(size_t dstchan, float v)
{
size_t relchan = dstchan - m_triggerOutChannelBase;
if( (relchan < 4) || (relchan > 11) )
return;

m_trigDrive[relchan] = v;

int mv = round(v * 1000);
m_transport->SendCommandQueued(m_channels[dstchan]->GetHwname() + ":LEV " + to_string(mv));
}

string AntikernelLabsTriggerCrossbar::GetDriverNameInternal()
{
return "akl.crossbar";
Expand Down
8 changes: 7 additions & 1 deletion scopehal/AntikernelLabsTriggerCrossbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ class AntikernelLabsTriggerCrossbar
//Switch matrix
virtual void SetMuxPath(size_t dstchan, size_t srcchan) override;
virtual void SetMuxPathOpen(size_t dstchan) override;
virtual bool MuxHasConfigurableDrive(size_t dstchan) override;
virtual float GetMuxOutputDrive(size_t dstchan) override;
virtual void SetMuxOutputDrive(size_t dstchan, float v) override;

protected:

Expand All @@ -140,7 +143,10 @@ class AntikernelLabsTriggerCrossbar
ssize_t GetScanHalfWidth(size_t i)
{ return 16 << m_rxClkDiv[i - m_rxChannelBase]; }

//Cached settings
//Cached settings for trigger channels
float m_trigDrive[12];

//Cached settings for bert channels
Pattern m_txPattern[2];
//Pattern m_rxPattern[2];
bool m_txInvert[2];
Expand Down
9 changes: 9 additions & 0 deletions scopehal/BufferedSwitchMatrixOutputChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ class BufferedSwitchMatrixOutputChannel : public DigitalOutputChannel
virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
virtual void OnInputChanged(size_t i) override;

bool MuxHasConfigurableDrive()
{ return dynamic_cast<SwitchMatrix*>(m_parent)->MuxHasConfigurableDrive(GetIndex()); }

float GetMuxOutputDrive()
{ return dynamic_cast<SwitchMatrix*>(m_parent)->GetMuxOutputDrive(GetIndex()); }

void SetMuxOutputDrive(float v)
{ dynamic_cast<SwitchMatrix*>(m_parent)->SetMuxOutputDrive(GetIndex(), v); }

protected:
};

Expand Down
3 changes: 3 additions & 0 deletions scopehal/DigitalOutputChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class DigitalOutputChannel : public InstrumentChannel

virtual PhysicalConnector GetPhysicalConnector() override;

Instrument* GetParent()
{ return m_parent; }

protected:
Instrument* m_parent;
};
Expand Down
15 changes: 15 additions & 0 deletions scopehal/SwitchMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ class SwitchMatrix : public virtual Instrument
*/
virtual void SetMuxPathOpen(size_t dstchan) =0;

/**
@brief Checks if an output channel has configurable voltage level
*/
virtual bool MuxHasConfigurableDrive(size_t dstchan) =0;

/**
@brief Gets the drive level of an output channel
*/
virtual float GetMuxOutputDrive(size_t dstchan) =0;

/**
@brief Sets the drive level of an output channel
*/
virtual void SetMuxOutputDrive(size_t dstchan, float v) =0;

protected:
/**
@brief Serializes this oscilloscope's configuration to a YAML node.
Expand Down

0 comments on commit 6d8a99c

Please sign in to comment.