mirror of
https://github.com/stacksmashing/LPCClocklessAnalyzer.git
synced 2026-01-30 19:08:38 +03:00
New analyzer
This commit is contained in:
@@ -1,70 +1,77 @@
|
||||
#include "SimpleSerialAnalyzer.h"
|
||||
#include "SimpleSerialAnalyzerSettings.h"
|
||||
#include "LPCClocklessAnalyzer.h"
|
||||
#include "LPCClocklessAnalyzerSettings.h"
|
||||
#include <AnalyzerChannelData.h>
|
||||
|
||||
SimpleSerialAnalyzer::SimpleSerialAnalyzer()
|
||||
#include <iostream>
|
||||
LPCClocklessAnalyzer::LPCClocklessAnalyzer()
|
||||
: Analyzer2(),
|
||||
mSettings( new SimpleSerialAnalyzerSettings() ),
|
||||
mSimulationInitilized( false )
|
||||
mSettings( new LPCClocklessAnalyzerSettings() )
|
||||
// mSimulationInitilized( false )
|
||||
{
|
||||
SetAnalyzerSettings( mSettings.get() );
|
||||
}
|
||||
|
||||
SimpleSerialAnalyzer::~SimpleSerialAnalyzer()
|
||||
LPCClocklessAnalyzer::~LPCClocklessAnalyzer()
|
||||
{
|
||||
KillThread();
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzer::SetupResults()
|
||||
void LPCClocklessAnalyzer::SetupResults()
|
||||
{
|
||||
mResults.reset( new SimpleSerialAnalyzerResults( this, mSettings.get() ) );
|
||||
mResults.reset( new LPCClocklessAnalyzerResults( this, mSettings.get() ) );
|
||||
SetAnalyzerResults( mResults.get() );
|
||||
mResults->AddChannelBubblesWillAppearOn( mSettings->mInputChannel );
|
||||
mResults->AddChannelBubblesWillAppearOn( mSettings->mFrameChannel );
|
||||
// mResults->AddChannelBubblesWillAppearOn( mSettings->mInputChannel );
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzer::WorkerThread()
|
||||
void LPCClocklessAnalyzer::WorkerThread()
|
||||
{
|
||||
mSampleRateHz = GetSampleRate();
|
||||
mFrame = GetAnalyzerChannelData( mSettings->mFrameChannel );
|
||||
// mSerial = GetAnalyzerChannelData( mSettings->mInputChannel );
|
||||
|
||||
mSerial = GetAnalyzerChannelData( mSettings->mInputChannel );
|
||||
if( mFrame->GetBitState() == BIT_HIGH )
|
||||
mFrame->AdvanceToNextEdge();
|
||||
|
||||
if( mSerial->GetBitState() == BIT_LOW )
|
||||
mSerial->AdvanceToNextEdge();
|
||||
|
||||
U32 samples_per_bit = mSampleRateHz / mSettings->mBitRate;
|
||||
U32 samples_to_first_center_of_first_data_bit = U32( 1.5 * double( mSampleRateHz ) / double( mSettings->mBitRate ) );
|
||||
|
||||
|
||||
U32 samples_per_bit = mSampleRateHz / 33000000;
|
||||
std::cout << "Samples per bit: " << samples_per_bit << std::endl;
|
||||
// U32 samples_to_first_center_of_first_data_bit = U32( 1.5 * double( mSampleRateHz ) / double( mSettings->mBitRate ) );
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
U8 data = 0;
|
||||
U8 mask = 1 << 7;
|
||||
// std::cout << "Advancing..." << mFrame->GetSampleNumber() << std::endl;
|
||||
mFrame->Advance(samples_per_bit/2);
|
||||
|
||||
mSerial->AdvanceToNextEdge(); //falling edge -- beginning of the start bit
|
||||
// mSerial->AdvanceToNextEdge(); //falling edge -- beginning of the start bit
|
||||
|
||||
U64 starting_sample = mSerial->GetSampleNumber();
|
||||
U64 starting_sample = mFrame->GetSampleNumber();
|
||||
|
||||
mSerial->Advance( samples_to_first_center_of_first_data_bit );
|
||||
// mSerial->Advance( samples_to_first_center_of_first_data_bit );
|
||||
|
||||
for( U32 i=0; i<8; i++ )
|
||||
{
|
||||
//let's put a dot exactly where we sample this bit:
|
||||
mResults->AddMarker( mSerial->GetSampleNumber(), AnalyzerResults::Dot, mSettings->mInputChannel );
|
||||
mResults->AddMarker( mFrame->GetSampleNumber(), AnalyzerResults::Dot, mSettings->mFrameChannel );
|
||||
|
||||
if( mSerial->GetBitState() == BIT_HIGH )
|
||||
data |= mask;
|
||||
// if( mSerial->GetBitState() == BIT_HIGH )
|
||||
// data |= mask;
|
||||
|
||||
mSerial->Advance( samples_per_bit );
|
||||
mFrame->Advance( samples_per_bit );
|
||||
|
||||
mask = mask >> 1;
|
||||
// mask = mask >> 1;
|
||||
}
|
||||
|
||||
|
||||
//we have a byte to save.
|
||||
Frame frame;
|
||||
frame.mData1 = data;
|
||||
// frame.mData1 = data;
|
||||
frame.mFlags = 0;
|
||||
frame.mStartingSampleInclusive = starting_sample;
|
||||
frame.mEndingSampleInclusive = mSerial->GetSampleNumber();
|
||||
frame.mEndingSampleInclusive = mFrame->GetSampleNumber();
|
||||
|
||||
mResults->AddFrame( frame );
|
||||
mResults->CommitResults();
|
||||
@@ -72,40 +79,42 @@ void SimpleSerialAnalyzer::WorkerThread()
|
||||
}
|
||||
}
|
||||
|
||||
bool SimpleSerialAnalyzer::NeedsRerun()
|
||||
bool LPCClocklessAnalyzer::NeedsRerun()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
U32 SimpleSerialAnalyzer::GenerateSimulationData( U64 minimum_sample_index, U32 device_sample_rate, SimulationChannelDescriptor** simulation_channels )
|
||||
U32 LPCClocklessAnalyzer::GenerateSimulationData( U64 minimum_sample_index, U32 device_sample_rate, SimulationChannelDescriptor** simulation_channels )
|
||||
{
|
||||
if( mSimulationInitilized == false )
|
||||
{
|
||||
mSimulationDataGenerator.Initialize( GetSimulationSampleRate(), mSettings.get() );
|
||||
mSimulationInitilized = true;
|
||||
}
|
||||
|
||||
return mSimulationDataGenerator.GenerateSimulationData( minimum_sample_index, device_sample_rate, simulation_channels );
|
||||
return 0;
|
||||
}
|
||||
// if( mSimulationInitilized == false )
|
||||
// {
|
||||
// mSimulationDataGenerator.Initialize( GetSimulationSampleRate(), mSettings.get() );
|
||||
// mSimulationInitilized = true;
|
||||
// }
|
||||
|
||||
U32 SimpleSerialAnalyzer::GetMinimumSampleRateHz()
|
||||
// return mSimulationDataGenerator.GenerateSimulationData( minimum_sample_index, device_sample_rate, simulation_channels );
|
||||
// }
|
||||
|
||||
U32 LPCClocklessAnalyzer::GetMinimumSampleRateHz()
|
||||
{
|
||||
return mSettings->mBitRate * 4;
|
||||
}
|
||||
|
||||
const char* SimpleSerialAnalyzer::GetAnalyzerName() const
|
||||
const char* LPCClocklessAnalyzer::GetAnalyzerName() const
|
||||
{
|
||||
return "Simple Serial";
|
||||
return "LPC Clockless";
|
||||
}
|
||||
|
||||
const char* GetAnalyzerName()
|
||||
{
|
||||
return "Simple Serial";
|
||||
return "LPC Clockless";
|
||||
}
|
||||
|
||||
Analyzer* CreateAnalyzer()
|
||||
{
|
||||
return new SimpleSerialAnalyzer();
|
||||
return new LPCClocklessAnalyzer();
|
||||
}
|
||||
|
||||
void DestroyAnalyzer( Analyzer* analyzer )
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#ifndef SIMPLESERIAL_ANALYZER_H
|
||||
#define SIMPLESERIAL_ANALYZER_H
|
||||
#ifndef LPCCLOCKLESS_ANALYZER_H
|
||||
#define LPCCLOCKLESS_ANALYZER_H
|
||||
|
||||
#include <Analyzer.h>
|
||||
#include "SimpleSerialAnalyzerResults.h"
|
||||
#include "SimpleSerialSimulationDataGenerator.h"
|
||||
#include "LPCClocklessAnalyzerResults.h"
|
||||
#include "LPCClocklessSimulationDataGenerator.h"
|
||||
|
||||
class SimpleSerialAnalyzerSettings;
|
||||
class ANALYZER_EXPORT SimpleSerialAnalyzer : public Analyzer2
|
||||
class LPCClocklessAnalyzerSettings;
|
||||
class ANALYZER_EXPORT LPCClocklessAnalyzer : public Analyzer2
|
||||
{
|
||||
public:
|
||||
SimpleSerialAnalyzer();
|
||||
virtual ~SimpleSerialAnalyzer();
|
||||
LPCClocklessAnalyzer();
|
||||
virtual ~LPCClocklessAnalyzer();
|
||||
|
||||
virtual void SetupResults();
|
||||
virtual void WorkerThread();
|
||||
@@ -22,12 +22,14 @@ public:
|
||||
virtual bool NeedsRerun();
|
||||
|
||||
protected: //vars
|
||||
std::auto_ptr< SimpleSerialAnalyzerSettings > mSettings;
|
||||
std::auto_ptr< SimpleSerialAnalyzerResults > mResults;
|
||||
AnalyzerChannelData* mSerial;
|
||||
std::unique_ptr< LPCClocklessAnalyzerSettings > mSettings;
|
||||
std::unique_ptr< LPCClocklessAnalyzerResults > mResults;
|
||||
// AnalyzerChannelData* mSerial;
|
||||
AnalyzerChannelData *mFrame;
|
||||
AnalyzerChannelData *mLadd[4];
|
||||
|
||||
SimpleSerialSimulationDataGenerator mSimulationDataGenerator;
|
||||
bool mSimulationInitilized;
|
||||
// LPCClocklessSimulationDataGenerator mSimulationDataGenerator;
|
||||
// bool mSimulationInitilized;
|
||||
|
||||
//Serial analysis vars:
|
||||
U32 mSampleRateHz;
|
||||
@@ -39,4 +41,4 @@ extern "C" ANALYZER_EXPORT const char* __cdecl GetAnalyzerName();
|
||||
extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer( );
|
||||
extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer( Analyzer* analyzer );
|
||||
|
||||
#endif //SIMPLESERIAL_ANALYZER_H
|
||||
#endif //LPCCLOCKLESS_ANALYZER_H
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#include "SimpleSerialAnalyzerResults.h"
|
||||
#include "LPCClocklessAnalyzerResults.h"
|
||||
#include <AnalyzerHelpers.h>
|
||||
#include "SimpleSerialAnalyzer.h"
|
||||
#include "SimpleSerialAnalyzerSettings.h"
|
||||
#include "LPCClocklessAnalyzer.h"
|
||||
#include "LPCClocklessAnalyzerSettings.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
SimpleSerialAnalyzerResults::SimpleSerialAnalyzerResults( SimpleSerialAnalyzer* analyzer, SimpleSerialAnalyzerSettings* settings )
|
||||
LPCClocklessAnalyzerResults::LPCClocklessAnalyzerResults( LPCClocklessAnalyzer* analyzer, LPCClocklessAnalyzerSettings* settings )
|
||||
: AnalyzerResults(),
|
||||
mSettings( settings ),
|
||||
mAnalyzer( analyzer )
|
||||
{
|
||||
}
|
||||
|
||||
SimpleSerialAnalyzerResults::~SimpleSerialAnalyzerResults()
|
||||
LPCClocklessAnalyzerResults::~LPCClocklessAnalyzerResults()
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerResults::GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base )
|
||||
void LPCClocklessAnalyzerResults::GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base )
|
||||
{
|
||||
ClearResultStrings();
|
||||
Frame frame = GetFrame( frame_index );
|
||||
@@ -26,7 +26,7 @@ void SimpleSerialAnalyzerResults::GenerateBubbleText( U64 frame_index, Channel&
|
||||
AddResultString( number_str );
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id )
|
||||
void LPCClocklessAnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id )
|
||||
{
|
||||
std::ofstream file_stream( file, std::ios::out );
|
||||
|
||||
@@ -58,7 +58,7 @@ void SimpleSerialAnalyzerResults::GenerateExportFile( const char* file, DisplayB
|
||||
file_stream.close();
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerResults::GenerateFrameTabularText( U64 frame_index, DisplayBase display_base )
|
||||
void LPCClocklessAnalyzerResults::GenerateFrameTabularText( U64 frame_index, DisplayBase display_base )
|
||||
{
|
||||
#ifdef SUPPORTS_PROTOCOL_SEARCH
|
||||
Frame frame = GetFrame( frame_index );
|
||||
@@ -70,13 +70,13 @@ void SimpleSerialAnalyzerResults::GenerateFrameTabularText( U64 frame_index, Dis
|
||||
#endif
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerResults::GeneratePacketTabularText( U64 packet_id, DisplayBase display_base )
|
||||
void LPCClocklessAnalyzerResults::GeneratePacketTabularText( U64 packet_id, DisplayBase display_base )
|
||||
{
|
||||
//not supported
|
||||
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerResults::GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base )
|
||||
void LPCClocklessAnalyzerResults::GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base )
|
||||
{
|
||||
//not supported
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
#ifndef SIMPLESERIAL_ANALYZER_RESULTS
|
||||
#define SIMPLESERIAL_ANALYZER_RESULTS
|
||||
#ifndef LPCCLOCKLESS_ANALYZER_RESULTS
|
||||
#define LPCCLOCKLESS_ANALYZER_RESULTS
|
||||
|
||||
#include <AnalyzerResults.h>
|
||||
|
||||
class SimpleSerialAnalyzer;
|
||||
class SimpleSerialAnalyzerSettings;
|
||||
class LPCClocklessAnalyzer;
|
||||
class LPCClocklessAnalyzerSettings;
|
||||
|
||||
class SimpleSerialAnalyzerResults : public AnalyzerResults
|
||||
class LPCClocklessAnalyzerResults : public AnalyzerResults
|
||||
{
|
||||
public:
|
||||
SimpleSerialAnalyzerResults( SimpleSerialAnalyzer* analyzer, SimpleSerialAnalyzerSettings* settings );
|
||||
virtual ~SimpleSerialAnalyzerResults();
|
||||
LPCClocklessAnalyzerResults( LPCClocklessAnalyzer* analyzer, LPCClocklessAnalyzerSettings* settings );
|
||||
virtual ~LPCClocklessAnalyzerResults();
|
||||
|
||||
virtual void GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base );
|
||||
virtual void GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id );
|
||||
@@ -22,8 +22,8 @@ public:
|
||||
protected: //functions
|
||||
|
||||
protected: //vars
|
||||
SimpleSerialAnalyzerSettings* mSettings;
|
||||
SimpleSerialAnalyzer* mAnalyzer;
|
||||
LPCClocklessAnalyzerSettings* mSettings;
|
||||
LPCClocklessAnalyzer* mAnalyzer;
|
||||
};
|
||||
|
||||
#endif //SIMPLESERIAL_ANALYZER_RESULTS
|
||||
#endif //LPCCLOCKLESS_ANALYZER_RESULTS
|
||||
|
||||
@@ -1,14 +1,31 @@
|
||||
#include "SimpleSerialAnalyzerSettings.h"
|
||||
#include "LPCClocklessAnalyzerSettings.h"
|
||||
#include <AnalyzerHelpers.h>
|
||||
|
||||
|
||||
SimpleSerialAnalyzerSettings::SimpleSerialAnalyzerSettings()
|
||||
: mInputChannel( UNDEFINED_CHANNEL ),
|
||||
LPCClocklessAnalyzerSettings::LPCClocklessAnalyzerSettings() :
|
||||
// : mInputChannel( UNDEFINED_CHANNEL ),
|
||||
mFrameChannel( UNDEFINED_CHANNEL ),
|
||||
mBitRate( 9600 )
|
||||
{
|
||||
mInputChannelInterface.reset( new AnalyzerSettingInterfaceChannel() );
|
||||
mInputChannelInterface->SetTitleAndTooltip( "Serial", "Standard Simple Serial" );
|
||||
mInputChannelInterface->SetChannel( mInputChannel );
|
||||
ClearChannels();
|
||||
for(int i=0; i < 4; i++) {
|
||||
mLaddChannel[i] = Channel(UNDEFINED_CHANNEL);
|
||||
// }
|
||||
mLaddChannelInterface[i].reset( new AnalyzerSettingInterfaceChannel() );
|
||||
// const char *name = std::string("Ladd" + std::to_string(i)).c_str();
|
||||
mLaddChannelInterface[i]->SetTitleAndTooltip(std::string("Ladd" + std::to_string(i)).c_str(), "Signal.");
|
||||
mLaddChannelInterface[i]->SetChannel( mLaddChannel[i] );
|
||||
AddInterface( mLaddChannelInterface[i].get() );
|
||||
AddChannel( mLaddChannel[i], std::string("Ladd" + std::to_string(i)).c_str(), false );
|
||||
}
|
||||
|
||||
mFrameChannelInterface.reset( new AnalyzerSettingInterfaceChannel() );
|
||||
mFrameChannelInterface->SetTitleAndTooltip( "Frame", "Frame signal" );
|
||||
mFrameChannelInterface->SetChannel( mFrameChannel );
|
||||
AddInterface(mFrameChannelInterface.get());
|
||||
// mInputChannelInterface.reset( new AnalyzerSettingInterfaceChannel() );
|
||||
// mInputChannelInterface->SetTitleAndTooltip( "Serial", "Standard LPC Clockless" );
|
||||
// mInputChannelInterface->SetChannel( mInputChannel );
|
||||
|
||||
mBitRateInterface.reset( new AnalyzerSettingInterfaceInteger() );
|
||||
mBitRateInterface->SetTitleAndTooltip( "Bit Rate (Bits/S)", "Specify the bit rate in bits per second." );
|
||||
@@ -16,57 +33,80 @@ SimpleSerialAnalyzerSettings::SimpleSerialAnalyzerSettings()
|
||||
mBitRateInterface->SetMin( 1 );
|
||||
mBitRateInterface->SetInteger( mBitRate );
|
||||
|
||||
AddInterface( mInputChannelInterface.get() );
|
||||
// AddInterface( mInputChannelInterface.get() );
|
||||
AddInterface( mBitRateInterface.get() );
|
||||
|
||||
AddExportOption( 0, "Export as text/csv file" );
|
||||
AddExportExtension( 0, "text", "txt" );
|
||||
AddExportExtension( 0, "csv", "csv" );
|
||||
|
||||
ClearChannels();
|
||||
AddChannel( mInputChannel, "Serial", false );
|
||||
// ClearChannels();
|
||||
AddChannel( mFrameChannel, "Frame", false );
|
||||
}
|
||||
|
||||
SimpleSerialAnalyzerSettings::~SimpleSerialAnalyzerSettings()
|
||||
LPCClocklessAnalyzerSettings::~LPCClocklessAnalyzerSettings()
|
||||
{
|
||||
}
|
||||
|
||||
bool SimpleSerialAnalyzerSettings::SetSettingsFromInterfaces()
|
||||
bool LPCClocklessAnalyzerSettings::SetSettingsFromInterfaces()
|
||||
{
|
||||
mInputChannel = mInputChannelInterface->GetChannel();
|
||||
// mInputChannel = mInputChannelInterface->GetChannel();
|
||||
mFrameChannel = mFrameChannelInterface->GetChannel();
|
||||
for(int i=0; i < 4; i++) {
|
||||
mLaddChannel[i] = mLaddChannelInterface[i]->GetChannel();
|
||||
}
|
||||
mBitRate = mBitRateInterface->GetInteger();
|
||||
|
||||
ClearChannels();
|
||||
AddChannel( mInputChannel, "Simple Serial", true );
|
||||
for(int i=0; i < 4; i++) {
|
||||
AddChannel( mLaddChannel[i], std::string("Ladd" + std::to_string(i)).c_str(), true);
|
||||
}
|
||||
// AddChannel( mInputChannel, "LPC Clockless", true );
|
||||
AddChannel( mFrameChannel, "Frame", true );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerSettings::UpdateInterfacesFromSettings()
|
||||
void LPCClocklessAnalyzerSettings::UpdateInterfacesFromSettings()
|
||||
{
|
||||
mInputChannelInterface->SetChannel( mInputChannel );
|
||||
for(int i=0; i < 4; i++) {
|
||||
mLaddChannelInterface[i]->SetChannel( mLaddChannel[i] );
|
||||
}
|
||||
mFrameChannelInterface->SetChannel( mFrameChannel );
|
||||
// mInputChannelInterface->SetChannel( mInputChannel );
|
||||
mBitRateInterface->SetInteger( mBitRate );
|
||||
}
|
||||
|
||||
void SimpleSerialAnalyzerSettings::LoadSettings( const char* settings )
|
||||
void LPCClocklessAnalyzerSettings::LoadSettings( const char* settings )
|
||||
{
|
||||
SimpleArchive text_archive;
|
||||
text_archive.SetString( settings );
|
||||
|
||||
text_archive >> mInputChannel;
|
||||
for(int i=0; i < 4; i++) {
|
||||
text_archive >> mLaddChannel[i];
|
||||
}
|
||||
text_archive >> mFrameChannel;
|
||||
text_archive >> mBitRate;
|
||||
|
||||
ClearChannels();
|
||||
AddChannel( mInputChannel, "Simple Serial", true );
|
||||
for(int i=0; i < 4; i++) {
|
||||
AddChannel( mLaddChannel[i], std::string("Ladd" + std::to_string(i)).c_str(), true);
|
||||
}
|
||||
// AddChannel( mInputChannel, "LPC Clockless", true );
|
||||
AddChannel( mFrameChannel, "Frame", true );
|
||||
// AddChannel( mInputChannel, "LPC Clockless", true );
|
||||
|
||||
UpdateInterfacesFromSettings();
|
||||
}
|
||||
|
||||
const char* SimpleSerialAnalyzerSettings::SaveSettings()
|
||||
const char* LPCClocklessAnalyzerSettings::SaveSettings()
|
||||
{
|
||||
SimpleArchive text_archive;
|
||||
|
||||
text_archive << mInputChannel;
|
||||
for(int i=0; i < 4; i++) {
|
||||
text_archive << mLaddChannel[i];
|
||||
}
|
||||
text_archive << mFrameChannel;
|
||||
// text_archive << mInputChannel;
|
||||
text_archive << mBitRate;
|
||||
|
||||
return SetReturnString( text_archive.GetString() );
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#ifndef SIMPLESERIAL_ANALYZER_SETTINGS
|
||||
#define SIMPLESERIAL_ANALYZER_SETTINGS
|
||||
#ifndef LPCCLOCKLESS_ANALYZER_SETTINGS
|
||||
#define LPCCLOCKLESS_ANALYZER_SETTINGS
|
||||
|
||||
#include <AnalyzerSettings.h>
|
||||
#include <AnalyzerTypes.h>
|
||||
|
||||
class SimpleSerialAnalyzerSettings : public AnalyzerSettings
|
||||
class LPCClocklessAnalyzerSettings : public AnalyzerSettings
|
||||
{
|
||||
public:
|
||||
SimpleSerialAnalyzerSettings();
|
||||
virtual ~SimpleSerialAnalyzerSettings();
|
||||
LPCClocklessAnalyzerSettings();
|
||||
virtual ~LPCClocklessAnalyzerSettings();
|
||||
|
||||
virtual bool SetSettingsFromInterfaces();
|
||||
void UpdateInterfacesFromSettings();
|
||||
@@ -16,12 +16,16 @@ public:
|
||||
virtual const char* SaveSettings();
|
||||
|
||||
|
||||
Channel mInputChannel;
|
||||
// Channel mInputChannel;
|
||||
Channel mLaddChannel[4];
|
||||
Channel mFrameChannel;
|
||||
U32 mBitRate;
|
||||
|
||||
protected:
|
||||
std::auto_ptr< AnalyzerSettingInterfaceChannel > mInputChannelInterface;
|
||||
std::auto_ptr< AnalyzerSettingInterfaceInteger > mBitRateInterface;
|
||||
// std::unique_ptr< AnalyzerSettingInterfaceChannel > mInputChannelInterface;
|
||||
std::unique_ptr< AnalyzerSettingInterfaceChannel > mLaddChannelInterface[4];
|
||||
std::unique_ptr< AnalyzerSettingInterfaceChannel > mFrameChannelInterface;
|
||||
std::unique_ptr< AnalyzerSettingInterfaceInteger > mBitRateInterface;
|
||||
};
|
||||
|
||||
#endif //SIMPLESERIAL_ANALYZER_SETTINGS
|
||||
#endif //LPCCLOCKLESS_ANALYZER_SETTINGS
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
#include "SimpleSerialSimulationDataGenerator.h"
|
||||
#include "SimpleSerialAnalyzerSettings.h"
|
||||
|
||||
#include <AnalyzerHelpers.h>
|
||||
|
||||
SimpleSerialSimulationDataGenerator::SimpleSerialSimulationDataGenerator()
|
||||
: mSerialText( "My first analyzer, woo hoo!" ),
|
||||
mStringIndex( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
SimpleSerialSimulationDataGenerator::~SimpleSerialSimulationDataGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
void SimpleSerialSimulationDataGenerator::Initialize( U32 simulation_sample_rate, SimpleSerialAnalyzerSettings* settings )
|
||||
{
|
||||
mSimulationSampleRateHz = simulation_sample_rate;
|
||||
mSettings = settings;
|
||||
|
||||
mSerialSimulationData.SetChannel( mSettings->mInputChannel );
|
||||
mSerialSimulationData.SetSampleRate( simulation_sample_rate );
|
||||
mSerialSimulationData.SetInitialBitState( BIT_HIGH );
|
||||
}
|
||||
|
||||
U32 SimpleSerialSimulationDataGenerator::GenerateSimulationData( U64 largest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channel )
|
||||
{
|
||||
U64 adjusted_largest_sample_requested = AnalyzerHelpers::AdjustSimulationTargetSample( largest_sample_requested, sample_rate, mSimulationSampleRateHz );
|
||||
|
||||
while( mSerialSimulationData.GetCurrentSampleNumber() < adjusted_largest_sample_requested )
|
||||
{
|
||||
CreateSerialByte();
|
||||
}
|
||||
|
||||
*simulation_channel = &mSerialSimulationData;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void SimpleSerialSimulationDataGenerator::CreateSerialByte()
|
||||
{
|
||||
U32 samples_per_bit = mSimulationSampleRateHz / mSettings->mBitRate;
|
||||
|
||||
U8 byte = mSerialText[ mStringIndex ];
|
||||
mStringIndex++;
|
||||
if( mStringIndex == mSerialText.size() )
|
||||
mStringIndex = 0;
|
||||
|
||||
//we're currenty high
|
||||
//let's move forward a little
|
||||
mSerialSimulationData.Advance( samples_per_bit * 10 );
|
||||
|
||||
mSerialSimulationData.Transition(); //low-going edge for start bit
|
||||
mSerialSimulationData.Advance( samples_per_bit ); //add start bit time
|
||||
|
||||
U8 mask = 0x1 << 7;
|
||||
for( U32 i=0; i<8; i++ )
|
||||
{
|
||||
if( ( byte & mask ) != 0 )
|
||||
mSerialSimulationData.TransitionIfNeeded( BIT_HIGH );
|
||||
else
|
||||
mSerialSimulationData.TransitionIfNeeded( BIT_LOW );
|
||||
|
||||
mSerialSimulationData.Advance( samples_per_bit );
|
||||
mask = mask >> 1;
|
||||
}
|
||||
|
||||
mSerialSimulationData.TransitionIfNeeded( BIT_HIGH ); //we need to end high
|
||||
|
||||
//lets pad the end a bit for the stop bit:
|
||||
mSerialSimulationData.Advance( samples_per_bit );
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef SIMPLESERIAL_SIMULATION_DATA_GENERATOR
|
||||
#define SIMPLESERIAL_SIMULATION_DATA_GENERATOR
|
||||
|
||||
#include <SimulationChannelDescriptor.h>
|
||||
#include <string>
|
||||
class SimpleSerialAnalyzerSettings;
|
||||
|
||||
class SimpleSerialSimulationDataGenerator
|
||||
{
|
||||
public:
|
||||
SimpleSerialSimulationDataGenerator();
|
||||
~SimpleSerialSimulationDataGenerator();
|
||||
|
||||
void Initialize( U32 simulation_sample_rate, SimpleSerialAnalyzerSettings* settings );
|
||||
U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channel );
|
||||
|
||||
protected:
|
||||
SimpleSerialAnalyzerSettings* mSettings;
|
||||
U32 mSimulationSampleRateHz;
|
||||
|
||||
protected:
|
||||
void CreateSerialByte();
|
||||
std::string mSerialText;
|
||||
U32 mStringIndex;
|
||||
|
||||
SimulationChannelDescriptor mSerialSimulationData;
|
||||
|
||||
};
|
||||
#endif //SIMPLESERIAL_SIMULATION_DATA_GENERATOR
|
||||
Reference in New Issue
Block a user