mirror of
https://github.com/stacksmashing/LPCClocklessAnalyzer.git
synced 2026-01-30 19:08:38 +03:00
start and addr working
This commit is contained in:
@@ -23,59 +23,166 @@ void LPCClocklessAnalyzer::SetupResults()
|
||||
// mResults->AddChannelBubblesWillAppearOn( mSettings->mInputChannel );
|
||||
}
|
||||
|
||||
uint8_t LPCClocklessAnalyzer::getBits() {
|
||||
return (mLadd[3]->GetBitState() << 3) |
|
||||
(mLadd[2]->GetBitState() << 2) |
|
||||
(mLadd[1]->GetBitState() << 1) |
|
||||
(mLadd[0]->GetBitState() << 0);
|
||||
}
|
||||
|
||||
void LPCClocklessAnalyzer::advanceAllToFrame() {
|
||||
for(int i=0; i < 4; i++) {
|
||||
mLadd[i]->AdvanceToAbsPosition(mFrame->GetSampleNumber());
|
||||
}
|
||||
}
|
||||
|
||||
void LPCClocklessAnalyzer::addFrameLabel(uint64_t start, uint64_t end, uint64_t label) {
|
||||
Frame frame;
|
||||
frame.mData1 = label;
|
||||
frame.mFlags = 0;
|
||||
frame.mStartingSampleInclusive = start;
|
||||
frame.mEndingSampleInclusive = end;
|
||||
|
||||
mResults->AddFrame( frame );
|
||||
mResults->CommitResults();
|
||||
ReportProgress(end);
|
||||
}
|
||||
|
||||
void LPCClocklessAnalyzer::WorkerThread()
|
||||
{
|
||||
mSampleRateHz = GetSampleRate();
|
||||
mFrame = GetAnalyzerChannelData( mSettings->mFrameChannel );
|
||||
for(int i=0; i < 4; i++) {
|
||||
mLadd[i] = GetAnalyzerChannelData( mSettings->mLaddChannel[i] );
|
||||
}
|
||||
|
||||
// mSerial = GetAnalyzerChannelData( mSettings->mInputChannel );
|
||||
|
||||
if( mFrame->GetBitState() == BIT_HIGH )
|
||||
mFrame->AdvanceToNextEdge();
|
||||
|
||||
|
||||
|
||||
// - U32 samples_per_bit = mSampleRateHz / mSettings->mBitRate;
|
||||
|
||||
U32 samples_per_bit = mSampleRateHz / 33000000;
|
||||
U32 samples_per_bit = mSampleRateHz / (mSettings->mBitRate * 1000);
|
||||
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( ; ; )
|
||||
{
|
||||
bool is_write = false;
|
||||
|
||||
U8 data = 0;
|
||||
U8 mask = 1 << 7;
|
||||
// std::cout << "Advancing..." << mFrame->GetSampleNumber() << std::endl;
|
||||
|
||||
|
||||
if( mFrame->GetBitState() == BIT_HIGH )
|
||||
mFrame->AdvanceToNextEdge();
|
||||
|
||||
mFrame->Advance(samples_per_bit/2);
|
||||
advanceAllToFrame();
|
||||
// Check pattern
|
||||
uint8_t bits = getBits();
|
||||
// printf("Bits: %d\n", bits);
|
||||
if(getBits() == 0b0101) {
|
||||
mResults->AddMarker( mFrame->GetSampleNumber(), AnalyzerResults::Start, mSettings->mFrameChannel );
|
||||
} else {
|
||||
mResults->AddMarker( mFrame->GetSampleNumber(), AnalyzerResults::ErrorX, mSettings->mFrameChannel );
|
||||
mFrame->AdvanceToNextEdge();
|
||||
mResults->CommitResults();
|
||||
ReportProgress( mFrame->GetSampleNumber() );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// mLadd[0]->AdvanceToAbsPosition(mFrame->GetSampleNumber());
|
||||
// // Often the ladd lines are delayed to the actual clock transition in my testing.
|
||||
// if( mLadd[0]->GetBitState() == BIT_HIGH ) {
|
||||
// mLadd[0]->AdvanceToNextEdge();
|
||||
// }
|
||||
|
||||
|
||||
// mFrame->AdvanceToAbsPosition(mLadd[0]->GetSampleNumber());
|
||||
// for(int i=1; i < 4; i++) {
|
||||
// mLadd[i]->AdvanceToAbsPosition(mLadd[0]->GetSampleNumber());
|
||||
// }
|
||||
|
||||
// std::cout << "Advancing..." << mFrame->GetSampleNumber() << std::endl;
|
||||
|
||||
// mFrame->Advance(samples_per_bit/2);
|
||||
|
||||
// mSerial->AdvanceToNextEdge(); //falling edge -- beginning of the start bit
|
||||
|
||||
U64 starting_sample = mFrame->GetSampleNumber();
|
||||
|
||||
// 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:
|
||||
// Go to CYCTYPE + DIR
|
||||
// 0000 = read
|
||||
// 0010 = write
|
||||
|
||||
mFrame->Advance( samples_per_bit );
|
||||
advanceAllToFrame();
|
||||
|
||||
uint8_t cyctype_dir = getBits();
|
||||
if(cyctype_dir == 0x02) {
|
||||
printf("Is write\n");
|
||||
is_write = true;
|
||||
}
|
||||
addFrameLabel(starting_sample, mFrame->GetSampleNumber(), cyctype_dir);
|
||||
// Frame frame;
|
||||
// frame.mData1 = cyctype_dir;
|
||||
// frame.mFlags = 0;
|
||||
// frame.mStartingSampleInclusive = starting_sample;
|
||||
// frame.mEndingSampleInclusive = mFrame->GetSampleNumber();
|
||||
|
||||
// mResults->AddFrame( frame );
|
||||
// mResults->CommitResults();
|
||||
//let's put a dot exactly where we sample this bit:
|
||||
mResults->AddMarker( mFrame->GetSampleNumber(), AnalyzerResults::Dot, mSettings->mFrameChannel );
|
||||
|
||||
starting_sample = mFrame->GetSampleNumber();
|
||||
// Iterate over address fields
|
||||
uint32_t address = 0;
|
||||
for(int i=0; i < 4; i++) {
|
||||
mFrame->Advance( samples_per_bit );
|
||||
advanceAllToFrame();
|
||||
|
||||
address |= getBits() << 4 * (3-i);
|
||||
mResults->AddMarker( mFrame->GetSampleNumber(), AnalyzerResults::Dot, mSettings->mFrameChannel );
|
||||
}
|
||||
addFrameLabel(starting_sample, mFrame->GetSampleNumber(), address);
|
||||
// frame.mData1 = address;
|
||||
// frame.mFlags = 0;
|
||||
// frame.mStartingSampleInclusive = starting_sample;
|
||||
// frame.mEndingSampleInclusive = mFrame->GetSampleNumber();
|
||||
|
||||
// mResults->AddFrame( frame );
|
||||
// mResults->CommitResults();
|
||||
|
||||
|
||||
// Next bits depend on whether read or write
|
||||
|
||||
|
||||
|
||||
// if( mSerial->GetBitState() == BIT_HIGH )
|
||||
// data |= mask;
|
||||
|
||||
mFrame->Advance( samples_per_bit );
|
||||
// mFrame->Advance( samples_per_bit );
|
||||
|
||||
// mask = mask >> 1;
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
//we have a byte to save.
|
||||
Frame frame;
|
||||
// frame.mData1 = data;
|
||||
frame.mFlags = 0;
|
||||
frame.mStartingSampleInclusive = starting_sample;
|
||||
frame.mEndingSampleInclusive = mFrame->GetSampleNumber();
|
||||
// Frame frame;
|
||||
// // frame.mData1 = data;
|
||||
// frame.mFlags = 0;
|
||||
// frame.mStartingSampleInclusive = starting_sample;
|
||||
// frame.mEndingSampleInclusive = mFrame->GetSampleNumber();
|
||||
|
||||
mResults->AddFrame( frame );
|
||||
mResults->CommitResults();
|
||||
ReportProgress( frame.mEndingSampleInclusive );
|
||||
// mResults->AddFrame( frame );
|
||||
// mResults->CommitResults();
|
||||
// ReportProgress( frame.mEndingSampleInclusive );
|
||||
|
||||
mFrame->AdvanceToNextEdge();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@ protected: //vars
|
||||
U32 mSampleRateHz;
|
||||
U32 mStartOfStopBitOffset;
|
||||
U32 mEndOfStopBitOffset;
|
||||
|
||||
private:
|
||||
uint8_t getBits();
|
||||
void advanceAllToFrame();
|
||||
void addFrameLabel(uint64_t start, uint64_t end, uint64_t label);
|
||||
};
|
||||
|
||||
extern "C" ANALYZER_EXPORT const char* __cdecl GetAnalyzerName();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
LPCClocklessAnalyzerSettings::LPCClocklessAnalyzerSettings() :
|
||||
// : mInputChannel( UNDEFINED_CHANNEL ),
|
||||
mFrameChannel( UNDEFINED_CHANNEL ),
|
||||
mBitRate( 9600 )
|
||||
mBitRate( 25000000 )
|
||||
{
|
||||
ClearChannels();
|
||||
for(int i=0; i < 4; i++) {
|
||||
@@ -29,7 +29,7 @@ LPCClocklessAnalyzerSettings::LPCClocklessAnalyzerSettings() :
|
||||
|
||||
mBitRateInterface.reset( new AnalyzerSettingInterfaceInteger() );
|
||||
mBitRateInterface->SetTitleAndTooltip( "Bit Rate (Bits/S)", "Specify the bit rate in bits per second." );
|
||||
mBitRateInterface->SetMax( 6000000 );
|
||||
mBitRateInterface->SetMax( 50000000 );
|
||||
mBitRateInterface->SetMin( 1 );
|
||||
mBitRateInterface->SetInteger( mBitRate );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user