dynamic code time measurement

master
Clyne 3 years ago
parent 1310b7f0f6
commit 30cf6ea38b
Signed by: clyne
GPG Key ID: 3267C8EBF3F9AFC7

@ -32,7 +32,7 @@ static void setBufferSize(unsigned char *);
static void updateGenerator(unsigned char *);
static void loadAlgorithm(unsigned char *);
static void readStatus(unsigned char *);
static void startConversionMeasure(unsigned char *);
static void measureConversion(unsigned char *);
static void startConversion(unsigned char *);
static void stopConversion(unsigned char *);
static void startGenerator(unsigned char *);
@ -53,7 +53,7 @@ static const std::array<std::pair<char, void (*)(unsigned char *)>, 19> commandT
{'D', updateGenerator},
{'E', loadAlgorithm},
{'I', readStatus},
{'M', startConversionMeasure},
{'M', measureConversion},
{'R', startConversion},
{'S', stopConversion},
{'W', startGenerator},
@ -159,12 +159,10 @@ void readStatus(unsigned char *)
USBSerial::write(buf, sizeof(buf));
}
void startConversionMeasure(unsigned char *)
void measureConversion(unsigned char *)
{
if (EM.assert(run_status == RunStatus::Idle, Error::NotIdle)) {
run_status = RunStatus::Running;
ConversionManager::startMeasured();
}
if (EM.assert(run_status == RunStatus::Running, Error::NotRunning))
ConversionManager::startMeasurement();
}
void startConversion(unsigned char *)
@ -177,7 +175,7 @@ void startConversion(unsigned char *)
void stopConversion(unsigned char *)
{
if (run_status == RunStatus::Running) {
if (EM.assert(run_status == RunStatus::Running, Error::NotRunning)) {
ConversionManager::stop();
run_status = RunStatus::Idle;
}

@ -65,11 +65,9 @@ void ConversionManager::start()
DAC::start(0, Samples::Out.data(), Samples::Out.size());
}
void ConversionManager::startMeasured()
void ConversionManager::startMeasurement()
{
Samples::Out.clear();
ADC::start(Samples::In.data(), Samples::In.size(), adcReadHandlerMeasure);
DAC::start(0, Samples::Out.data(), Samples::Out.size());
ADC::setOperation(adcReadHandlerMeasure);
}
void ConversionManager::stop()
@ -157,12 +155,14 @@ void ConversionManager::threadRunner(void *)
asm("mov %0, sp" : "=r" (sp));
samples = entry(samples, size);
asm("mov sp, %0" :: "r" (sp));
volatile auto testRead = *samples;
} else {
// Start execution timer:
asm("mov %0, sp; eor r0, r0; svc 2" : "=r" (sp));
samples = entry(samples, size);
// Stop execution timer:
asm("mov r0, #1; svc 2; mov sp, %0" :: "r" (sp));
volatile auto testRead = *samples;
}
}

@ -31,8 +31,8 @@ public:
// Begins sample conversion.
static void start();
// Begins conversion with execution time measured.
static void startMeasured();
// Prepare to measure execution time of next conversion.
static void startMeasurement();
// Stops conversion.
static void stop();

@ -22,7 +22,8 @@ enum class Error : char
BadUserCodeLoad,
BadUserCodeSize,
NotIdle,
ConversionAborted
ConversionAborted,
NotRunning
};
class ErrorManager

Loading…
Cancel
Save