Skip to content
Permalink
Browse files

add timings for different sample points

  • Loading branch information...
HubertD committed May 17, 2016
1 parent 227fb22 commit 88b023d1a3f0b5645f13b929c2541f28099b72bb
@@ -4,7 +4,8 @@ SOURCES += \
$$PWD/CandleApiDriver.cpp \
$$PWD/CandleApiInterface.cpp \
$$PWD/api/candle.c \
$$PWD/api/candle_ctrl_req.c
$$PWD/api/candle_ctrl_req.c \
$$PWD/CandleApiTiming.cpp

#win32:LIBS += -L$$PWD/api/ -lcandle_api
win32: LIBS += -lSetupApi
@@ -17,6 +18,7 @@ HEADERS += \
$$PWD/CandleApiInterface.h \
$$PWD/api/candle_ctrl_req.h \
$$PWD/api/candle_defs.h \
$$PWD/api/ch_9.h
$$PWD/api/ch_9.h \
$$PWD/CandleApiTiming.h

FORMS +=
@@ -16,6 +16,56 @@ CandleApiInterface::CandleApiInterface(CandleApiDriver *driver, candle_handle ha
_perfTicksPerSecond = tps.QuadPart;
_settings.setBitrate(500000);
_settings.setSamplePoint(0.875);

_timings
// sample point: 50.0%
<< CandleApiTiming(48000000, 10000, 500, 300, 6, 8)
<< CandleApiTiming(48000000, 20000, 500, 150, 6, 8)
<< CandleApiTiming(48000000, 50000, 500, 60, 6, 8)
<< CandleApiTiming(48000000, 83333, 500, 36, 6, 8)
<< CandleApiTiming(48000000, 100000, 500, 30, 6, 8)
<< CandleApiTiming(48000000, 125000, 500, 24, 6, 8)
<< CandleApiTiming(48000000, 250000, 500, 12, 6, 8)
<< CandleApiTiming(48000000, 500000, 500, 6, 6, 8)
<< CandleApiTiming(48000000, 800000, 500, 3, 8, 9)
<< CandleApiTiming(48000000, 1000000, 500, 3, 6, 8)

// sample point: 62.5%
<< CandleApiTiming(48000000, 10000, 625, 300, 8, 6)
<< CandleApiTiming(48000000, 20000, 625, 150, 8, 6)
<< CandleApiTiming(48000000, 50000, 625, 60, 8, 6)
<< CandleApiTiming(48000000, 83333, 625, 36, 8, 6)
<< CandleApiTiming(48000000, 100000, 625, 30, 8, 6)
<< CandleApiTiming(48000000, 125000, 625, 24, 8, 6)
<< CandleApiTiming(48000000, 250000, 625, 12, 8, 6)
<< CandleApiTiming(48000000, 500000, 625, 6, 8, 6)
<< CandleApiTiming(48000000, 800000, 600, 4, 7, 6)
<< CandleApiTiming(48000000, 1000000, 625, 3, 8, 6)

// sample point: 75.0%
<< CandleApiTiming(48000000, 10000, 750, 300, 10, 4)
<< CandleApiTiming(48000000, 20000, 750, 150, 10, 4)
<< CandleApiTiming(48000000, 50000, 750, 60, 10, 4)
<< CandleApiTiming(48000000, 83333, 750, 36, 10, 4)
<< CandleApiTiming(48000000, 100000, 750, 30, 10, 4)
<< CandleApiTiming(48000000, 125000, 750, 24, 10, 4)
<< CandleApiTiming(48000000, 250000, 750, 12, 10, 4)
<< CandleApiTiming(48000000, 500000, 750, 6, 10, 4)
<< CandleApiTiming(48000000, 800000, 750, 3, 13, 5)
<< CandleApiTiming(48000000, 1000000, 750, 3, 10, 4)

// sample point: 87.5%
<< CandleApiTiming(48000000, 10000, 875, 300, 12, 2)
<< CandleApiTiming(48000000, 20000, 875, 150, 12, 2)
<< CandleApiTiming(48000000, 50000, 875, 60, 12, 2)
<< CandleApiTiming(48000000, 83333, 875, 36, 12, 2)
<< CandleApiTiming(48000000, 100000, 875, 30, 12, 2)
<< CandleApiTiming(48000000, 125000, 875, 24, 12, 2)
<< CandleApiTiming(48000000, 250000, 875, 12, 12, 2)
<< CandleApiTiming(48000000, 500000, 875, 6, 12, 2)
<< CandleApiTiming(48000000, 800000, 867, 4, 11, 2)
<< CandleApiTiming(48000000, 1000000, 875, 3, 12, 2);

}

CandleApiInterface::~CandleApiInterface()
@@ -69,14 +119,9 @@ QList<CanTiming> CandleApiInterface::getAvailableBitrates()
{
QList<CanTiming> retval;

QList<unsigned> bitrates = QList<unsigned>() << 10000 << 20000 << 50000 << 100000 << 125000 << 250000 << 500000 << 800000 << 1000000;
QList<unsigned> spoints = QList<unsigned>() << 500 << 625 << 750 << 875;

int i = 0;
foreach (unsigned br, bitrates) {
foreach (unsigned sp, spoints) {
retval << CanTiming(i++, br, 0, sp);
}
foreach (const CandleApiTiming t, _timings) {
retval << CanTiming(i++, t.getBitrate(), 0, t.getSamplePoint());
}

return retval;
@@ -4,7 +4,9 @@
#include <driver/CanInterface.h>
#include <core/MeasurementInterface.h>
#include "api/candle.h"
#include "CandleApiTiming.h"
#include <windows.h>
#include <QList>

class CandleApiDriver;

@@ -43,6 +45,7 @@ class CandleApiInterface : public CanInterface
void update(candle_handle dev);

private:

uint64_t _perfTicksPerSecond;
uint64_t _perfCountStart;

@@ -56,6 +59,8 @@ class CandleApiInterface : public CanInterface
uint64_t _numTx;
uint64_t _numTxErr;

QList<CandleApiTiming> _timings;

void syncTimestamp();
void checkSyncTimestamp();
};
@@ -0,0 +1,33 @@
#include "CandleApiTiming.h"

CandleApiTiming::CandleApiTiming(uint32_t baseClk, uint32_t bitrate, uint32_t samplePoint, uint32_t brp, uint32_t phase_seg1, uint32_t phase_seg2)
: _baseClk(baseClk),
_bitrate(bitrate),
_samplePoint(samplePoint)
{
_timing.brp = brp;
_timing.phase_seg1 = phase_seg1;
_timing.phase_seg2 = phase_seg2;
_timing.sjw = 1;
_timing.prop_seg = 1;
}

uint32_t CandleApiTiming::getBaseClk() const
{
return _baseClk;
}

uint32_t CandleApiTiming::getBitrate() const
{
return _bitrate;
}

uint32_t CandleApiTiming::getSamplePoint() const
{
return _samplePoint;
}

candle_bittiming_t CandleApiTiming::getTiming() const
{
return _timing;
}
@@ -0,0 +1,31 @@
#ifndef CANDLEAPITIMING_H
#define CANDLEAPITIMING_H

#include "api/candle.h"

class CandleApiTiming
{
public:
CandleApiTiming(
uint32_t baseClk,
uint32_t bitrate,
uint32_t samplePoint,
uint32_t brp,
uint32_t phase_seg1,
uint32_t phase_seg2
);

uint32_t getBaseClk() const;
uint32_t getBitrate() const;
uint32_t getSamplePoint() const;
candle_bittiming_t getTiming() const;

private:
uint32_t _baseClk;
uint32_t _bitrate;
uint32_t _samplePoint;
candle_bittiming_t _timing;

};

#endif // CANDLEAPITIMING_H

0 comments on commit 88b023d

Please sign in to comment.
You can’t perform that action at this time.