Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7ce47429c02a
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b6d0760ed3c9
Choose a head ref
  • 1 commit
  • 12 files changed
  • 1 contributor

Commits on May 13, 2020

  1. Copy the full SHA
    b6d0760 View commit details
8 changes: 5 additions & 3 deletions scopehal/ProtocolDecoder.h
Original file line number Diff line number Diff line change
@@ -85,16 +85,18 @@ class ProtocolDecoder : public OscilloscopeChannel
{
public:

//Add new categories to the end of this list to maintain ABI compatibility with existing plugins
enum Category
{
CAT_ANALYSIS, //Signal analysis (histograms, eye patterns, etc)
CAT_ANALYSIS, //Signal integrity analysis
CAT_BUS, //Buses
CAT_CLOCK, //Clock stuff
CAT_CONVERSION, //Type conversion
CAT_MATH, //Basic math functions
CAT_MEASUREMENT, //Measurement functions
CAT_MEMORY, //Memory buses
CAT_SERIAL, //Serial communications
CAT_MISC //anything not otherwise categorized
CAT_MISC, //anything not otherwise categorized
CAT_RF //Frequency domain analysis (FFT etc) and other RF stuff
};

ProtocolDecoder(OscilloscopeChannel::ChannelType type, std::string color, Category cat);
2 changes: 1 addition & 1 deletion scopeprotocols/ACCoupleDecoder.cpp
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ using namespace std;
// Construction / destruction

ACCoupleDecoder::ACCoupleDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_ANALOG, color, CAT_CONVERSION)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_ANALOG, color, CAT_MATH)
{
//Set up channels
m_signalNames.push_back("din");
2 changes: 1 addition & 1 deletion scopeprotocols/CANDecoder.cpp
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ using namespace std;
// Construction / destruction

CANDecoder::CANDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_SERIAL)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_BUS)
{
//Set up channels
m_signalNames.push_back("Diff");
2 changes: 1 addition & 1 deletion scopeprotocols/FFTDecoder.cpp
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ FFTCapture::~FFTCapture()
// Construction / destruction

FFTDecoder::FFTDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_ANALOG, color, CAT_MATH)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_ANALOG, color, CAT_RF)
{
m_xAxisUnit = Unit(Unit::UNIT_HZ);
m_yAxisUnit = Unit(Unit::UNIT_DB);
2 changes: 1 addition & 1 deletion scopeprotocols/I2CDecoder.cpp
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ using namespace std;
// Construction / destruction

I2CDecoder::I2CDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_SERIAL)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_BUS)
{
//Set up channels
m_signalNames.push_back("sda");
2 changes: 1 addition & 1 deletion scopeprotocols/JtagDecoder.cpp
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ const char* JtagSymbol::GetName(JtagSymbol::JtagState state)
// Construction / destruction

JtagDecoder::JtagDecoder(string color)
: PacketDecoder(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_SERIAL)
: PacketDecoder(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_BUS)
{
//Set up channels
m_signalNames.push_back("TDI");
2 changes: 1 addition & 1 deletion scopeprotocols/ParallelBusDecoder.cpp
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ using namespace std;
// Construction / destruction

ParallelBusDecoder::ParallelBusDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_DIGITAL, color, CAT_CONVERSION)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_DIGITAL, color, CAT_BUS)
{
//Set up channels
char tmp[32];
75 changes: 68 additions & 7 deletions scopeprotocols/SPIDecoder.cpp
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ using namespace std;
// Construction / destruction

SPIDecoder::SPIDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_SERIAL)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_BUS)
{
//Set up channels
m_signalNames.push_back("clk");
@@ -129,6 +129,7 @@ void SPIDecoder::Refresh()
uint8_t current_byte = 0;
uint8_t bitcount = 0;
int64_t bytestart = 0;
bool first = false;

for(size_t i=0; i<clk->m_samples.size(); i++)
{
@@ -148,6 +149,8 @@ void SPIDecoder::Refresh()
state = STATE_SELECTED_CLKLO;
current_byte = 0;
bitcount = 0;
bytestart = clk->m_samples[i].m_offset;
first = true;
}
break;

@@ -156,7 +159,18 @@ void SPIDecoder::Refresh()
if(cur_clk)
{
if(bitcount == 0)
{
//Add a "chip selected" event
if(first)
{
cap->m_samples.push_back(SPISample(
bytestart,
clk->m_samples[i].m_offset - bytestart,
SPISymbol(SPISymbol::TYPE_SELECT, 0)));
first = false;
}
bytestart = clk->m_samples[i].m_offset;
}

state = STATE_SELECTED_CLKHI;
bitcount ++;
@@ -170,17 +184,26 @@ void SPIDecoder::Refresh()
cap->m_samples.push_back(SPISample(
bytestart,
clk->m_samples[i].m_offset - bytestart,
current_byte));
SPISymbol(SPISymbol::TYPE_DATA, current_byte)));

bitcount = 0;
current_byte = 0;
bytestart = clk->m_samples[i].m_offset;
}
}

//end of packet
//TODO: error if a byte is truncated
else if(cur_cs)
{
cap->m_samples.push_back(SPISample(
bytestart,
clk->m_samples[i].m_offset - bytestart,
SPISymbol(SPISymbol::TYPE_DESELECT, 0)));

bytestart = clk->m_samples[i].m_offset;
state = STATE_DESELECTED;
}
break;

//wait for falling edge of clk
@@ -191,7 +214,15 @@ void SPIDecoder::Refresh()
//end of packet
//TODO: error if a byte is truncated
else if(cur_cs)
{
cap->m_samples.push_back(SPISample(
bytestart,
clk->m_samples[i].m_offset - bytestart,
SPISymbol(SPISymbol::TYPE_DESELECT, 0)));

bytestart = clk->m_samples[i].m_offset;
state = STATE_DESELECTED;
}

break;
}
@@ -200,19 +231,49 @@ void SPIDecoder::Refresh()
SetData(cap);
}

Gdk::Color SPIDecoder::GetColor(int /*i*/)
Gdk::Color SPIDecoder::GetColor(int i)
{
return m_standardColors[COLOR_DATA];
SPICapture* capture = dynamic_cast<SPICapture*>(GetData());
if(capture != NULL)
{
const SPISymbol& s = capture->m_samples[i].m_sample;
switch(s.m_stype)
{
case SPISymbol::TYPE_SELECT:
case SPISymbol::TYPE_DESELECT:
return m_standardColors[COLOR_CONTROL];

case SPISymbol::TYPE_DATA:
return m_standardColors[COLOR_DATA];

case SPISymbol::TYPE_ERROR:
default:
return m_standardColors[COLOR_ERROR];
}
}
return m_standardColors[COLOR_ERROR];
}

string SPIDecoder::GetText(int i)
{
SPICapture* capture = dynamic_cast<SPICapture*>(GetData());
if(capture != NULL)
{
char tmp[16];
snprintf(tmp, sizeof(tmp), "%02x", capture->m_samples[i].m_sample);
return string(tmp);
const SPISymbol& s = capture->m_samples[i].m_sample;
char tmp[32];
switch(s.m_stype)
{
case SPISymbol::TYPE_SELECT:
return "SELECT";
case SPISymbol::TYPE_DESELECT:
return "DESELECT";
case SPISymbol::TYPE_DATA:
snprintf(tmp, sizeof(tmp), "%02x", capture->m_samples[i].m_sample.m_data);
return string(tmp);
case SPISymbol::TYPE_ERROR:
default:
return "ERROR";
}
}
return "";
}
29 changes: 27 additions & 2 deletions scopeprotocols/SPIDecoder.h
Original file line number Diff line number Diff line change
@@ -38,8 +38,33 @@

#include "../scopehal/ProtocolDecoder.h"

typedef OscilloscopeSample<uint8_t> SPISample;
typedef CaptureChannel<uint8_t> SPICapture;
class SPISymbol
{
public:
enum stype
{
TYPE_SELECT,
TYPE_DATA,
TYPE_DESELECT,
TYPE_ERROR
};

SPISymbol(stype t,uint8_t d)
: m_stype(t)
, m_data(d)
{}

stype m_stype;
uint8_t m_data;

bool operator== (const SPISymbol& s) const
{
return (m_stype == s.m_stype) && (m_data == s.m_data);
}
};

typedef OscilloscopeSample<SPISymbol> SPISample;
typedef CaptureChannel<SPISymbol> SPICapture;

class SPIDecoder : public ProtocolDecoder
{
2 changes: 1 addition & 1 deletion scopeprotocols/ThresholdDecoder.cpp
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ using namespace std;
// Construction / destruction

ThresholdDecoder::ThresholdDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_DIGITAL, color, CAT_CONVERSION)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_DIGITAL, color, CAT_MATH)
{
//Set up channels
m_signalNames.push_back("din");
2 changes: 1 addition & 1 deletion scopeprotocols/UARTDecoder.cpp
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ using namespace std;
// Construction / destruction

UARTDecoder::UARTDecoder(string color)
: PacketDecoder(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_SERIAL)
: PacketDecoder(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_BUS)
{
//Set up channels
m_signalNames.push_back("din");
2 changes: 1 addition & 1 deletion scopeprotocols/WaterfallDecoder.cpp
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ bool WaterfallCapture::SamplesAdjacent(size_t /*i*/, size_t /*j*/) const
// Construction / destruction

WaterfallDecoder::WaterfallDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_ANALOG, color, CAT_MATH)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_ANALOG, color, CAT_RF)
, m_pixelsPerHz(0.001)
, m_offsetHz(0)
, m_width(1)