Skip to content

Commit

Permalink
clang-format update of ARM Serial Wire Debug (SWD) Analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus10110 committed Oct 29, 2020
1 parent 40dd6b3 commit 921af23
Show file tree
Hide file tree
Showing 12 changed files with 2,058 additions and 1,952 deletions.
142 changes: 71 additions & 71 deletions src/SWDAnalyzer.cpp
Expand Up @@ -7,116 +7,116 @@
#include "SWDAnalyzerSettings.h"
#include "SWDUtils.h"

SWDAnalyzer::SWDAnalyzer()
: mSimulationInitilized(false)
SWDAnalyzer::SWDAnalyzer() : mSimulationInitilized( false )
{
SetAnalyzerSettings(&mSettings);
SetAnalyzerSettings( &mSettings );
}

SWDAnalyzer::~SWDAnalyzer()
{
KillThread();
KillThread();
}

void SWDAnalyzer::SetupResults()
{
// reset the results
mResults.reset( new SWDAnalyzerResults( this, &mSettings ) );
SetAnalyzerResults( mResults.get() );
// reset the results
mResults.reset( new SWDAnalyzerResults( this, &mSettings ) );
SetAnalyzerResults( mResults.get() );

// set which channels will carry bubbles
mResults->AddChannelBubblesWillAppearOn( mSettings.mSWDIO );
mResults->AddChannelBubblesWillAppearOn( mSettings.mSWCLK );
// set which channels will carry bubbles
mResults->AddChannelBubblesWillAppearOn( mSettings.mSWDIO );
mResults->AddChannelBubblesWillAppearOn( mSettings.mSWCLK );
}

void SWDAnalyzer::WorkerThread()
{
//SetupResults();
// get the channel pointers
mSWDIO = GetAnalyzerChannelData( mSettings.mSWDIO );
mSWCLK = GetAnalyzerChannelData( mSettings.mSWCLK );

mSWDParser.Setup( mSWDIO, mSWCLK, this );

// these are our three objects that SWDParser will fill with data
// on calls to IsOperation or IsLineReset
SWDOperation tran;
SWDLineReset reset;
SWDBit error_bit;

mSWDParser.Clear();

// For every new bit the parser extracts from the stream,
// ask if this can be a valid operation or line reset.
// A valid operation will have the constant part of the request correctly set,
// and also the parity bits will be correct.
// A valid line reset has at least 50 high bits in succession.
for (;;)
{
if (mSWDParser.IsOperation(tran))
{
tran.AddFrames(mResults.get());
tran.AddMarkers(mResults.get());

mResults->CommitResults();

} else if (mSWDParser.IsLineReset(reset)) {

reset.AddFrames(mResults.get());

mResults->CommitResults();

} else {
// This is neither a valid transaction nor a valid reset,
// so remove the first bit and try again.
// We're dropping the error bit into oblivion.
error_bit = mSWDParser.PopFrontBit();
}

ReportProgress(mSWDIO->GetSampleNumber());
}
// SetupResults();
// get the channel pointers
mSWDIO = GetAnalyzerChannelData( mSettings.mSWDIO );
mSWCLK = GetAnalyzerChannelData( mSettings.mSWCLK );

mSWDParser.Setup( mSWDIO, mSWCLK, this );

// these are our three objects that SWDParser will fill with data
// on calls to IsOperation or IsLineReset
SWDOperation tran;
SWDLineReset reset;
SWDBit error_bit;

mSWDParser.Clear();

// For every new bit the parser extracts from the stream,
// ask if this can be a valid operation or line reset.
// A valid operation will have the constant part of the request correctly set,
// and also the parity bits will be correct.
// A valid line reset has at least 50 high bits in succession.
for( ;; )
{
if( mSWDParser.IsOperation( tran ) )
{
tran.AddFrames( mResults.get() );
tran.AddMarkers( mResults.get() );

mResults->CommitResults();
}
else if( mSWDParser.IsLineReset( reset ) )
{
reset.AddFrames( mResults.get() );

mResults->CommitResults();
}
else
{
// This is neither a valid transaction nor a valid reset,
// so remove the first bit and try again.
// We're dropping the error bit into oblivion.
error_bit = mSWDParser.PopFrontBit();
}

ReportProgress( mSWDIO->GetSampleNumber() );
}
}

bool SWDAnalyzer::NeedsRerun()
{
return false;
return false;
}

U32 SWDAnalyzer::GenerateSimulationData(U64 minimum_sample_index, U32 device_sample_rate, SimulationChannelDescriptor** simulation_channels)
U32 SWDAnalyzer::GenerateSimulationData( U64 minimum_sample_index, U32 device_sample_rate,
SimulationChannelDescriptor** simulation_channels )
{
if (!mSimulationInitilized)
{
mSimulationDataGenerator.Initialize(GetSimulationSampleRate(), &mSettings);
mSimulationInitilized = true;
}
if( !mSimulationInitilized )
{
mSimulationDataGenerator.Initialize( GetSimulationSampleRate(), &mSettings );
mSimulationInitilized = true;
}

return mSimulationDataGenerator.GenerateSimulationData(minimum_sample_index, device_sample_rate, simulation_channels);
return mSimulationDataGenerator.GenerateSimulationData( minimum_sample_index, device_sample_rate, simulation_channels );
}

U32 SWDAnalyzer::GetMinimumSampleRateHz()
{
// this 1MHz limit is a little arbitrary, since the specs don't say much about the
// valid frequency range a SWD stream should be in.
return 1000000;
// this 1MHz limit is a little arbitrary, since the specs don't say much about the
// valid frequency range a SWD stream should be in.
return 1000000;
}

const char* SWDAnalyzer::GetAnalyzerName() const
{
return ::GetAnalyzerName();
return ::GetAnalyzerName();
}

const char* GetAnalyzerName()
{
return "SWD";
return "SWD";
}

Analyzer* CreateAnalyzer()
{
return new SWDAnalyzer();
return new SWDAnalyzer();
}

void DestroyAnalyzer(Analyzer* analyzer)
void DestroyAnalyzer( Analyzer* analyzer )
{
delete analyzer;
delete analyzer;
}
39 changes: 19 additions & 20 deletions src/SWDAnalyzer.h
Expand Up @@ -11,35 +11,34 @@

class SWDAnalyzer : public Analyzer2
{
public:
SWDAnalyzer();
virtual ~SWDAnalyzer();
virtual void SetupResults();
virtual void WorkerThread();
public:
SWDAnalyzer();
virtual ~SWDAnalyzer();
virtual void SetupResults();
virtual void WorkerThread();

virtual U32 GenerateSimulationData(U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels);
virtual U32 GetMinimumSampleRateHz();
virtual U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels );
virtual U32 GetMinimumSampleRateHz();

virtual const char* GetAnalyzerName() const;
virtual bool NeedsRerun();
virtual const char* GetAnalyzerName() const;
virtual bool NeedsRerun();

protected: // vars
protected: // vars
SWDAnalyzerSettings mSettings;
std::auto_ptr<SWDAnalyzerResults> mResults;

SWDAnalyzerSettings mSettings;
std::auto_ptr<SWDAnalyzerResults> mResults;
AnalyzerChannelData* mSWDIO;
AnalyzerChannelData* mSWCLK;

AnalyzerChannelData* mSWDIO;
AnalyzerChannelData* mSWCLK;
SWDSimulationDataGenerator mSimulationDataGenerator;

SWDSimulationDataGenerator mSimulationDataGenerator;
SWDParser mSWDParser;

SWDParser mSWDParser;

bool mSimulationInitilized;
bool mSimulationInitilized;
};

extern "C" ANALYZER_EXPORT const char* __cdecl GetAnalyzerName();
extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer();
extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer(Analyzer* analyzer);
extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer( Analyzer* analyzer );

#endif // SWD_ANALYZER_H
#endif // SWD_ANALYZER_H

0 comments on commit 921af23

Please sign in to comment.