|
|
@ -77,6 +77,10 @@ static std::array<adcsample_t, CACHE_SIZE_ALIGN(adcsample_t, MAX_SAMPLE_BUFFER_S
|
|
|
|
CC_ALIGN(CACHE_LINE_SIZE)
|
|
|
|
CC_ALIGN(CACHE_LINE_SIZE)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
static std::array<dacsample_t, CACHE_SIZE_ALIGN(dacsample_t, MAX_SAMPLE_BUFFER_SIZE)> dac_samples;
|
|
|
|
static std::array<dacsample_t, CACHE_SIZE_ALIGN(dacsample_t, MAX_SAMPLE_BUFFER_SIZE)> dac_samples;
|
|
|
|
|
|
|
|
#if CACHE_LINE_SIZE > 0
|
|
|
|
|
|
|
|
CC_ALIGN(CACHE_LINE_SIZE)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static std::array<dacsample_t, CACHE_SIZE_ALIGN(dacsample_t, MAX_SAMPLE_BUFFER_SIZE)> dac2_samples;
|
|
|
|
|
|
|
|
|
|
|
|
static uint8_t elf_file_store[MAX_ELF_FILE_SIZE];
|
|
|
|
static uint8_t elf_file_store[MAX_ELF_FILE_SIZE];
|
|
|
|
static elf::entry_t elf_entry = nullptr;
|
|
|
|
static elf::entry_t elf_entry = nullptr;
|
|
|
@ -112,6 +116,7 @@ int main()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static unsigned int dac_sample_count = MAX_SAMPLE_BUFFER_SIZE;
|
|
|
|
static unsigned int dac_sample_count = MAX_SAMPLE_BUFFER_SIZE;
|
|
|
|
|
|
|
|
static unsigned int dac2_sample_count = MAX_SAMPLE_BUFFER_SIZE;
|
|
|
|
static unsigned int adc_sample_count = MAX_SAMPLE_BUFFER_SIZE;
|
|
|
|
static unsigned int adc_sample_count = MAX_SAMPLE_BUFFER_SIZE;
|
|
|
|
static bool adc_preloaded = false;
|
|
|
|
static bool adc_preloaded = false;
|
|
|
|
static bool dac_preloaded = false;
|
|
|
|
static bool dac_preloaded = false;
|
|
|
@ -133,6 +138,8 @@ void main_loop()
|
|
|
|
usbserial::read(&adc_samples[0], adc_sample_count * sizeof(adcsample_t));
|
|
|
|
usbserial::read(&adc_samples[0], adc_sample_count * sizeof(adcsample_t));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'b':
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'B':
|
|
|
|
case 'B':
|
|
|
|
if (run_status == RunStatus::Idle) {
|
|
|
|
if (run_status == RunStatus::Idle) {
|
|
|
|
if (usbserial::read(&cmd[1], 2) == 2) {
|
|
|
|
if (usbserial::read(&cmd[1], 2) == 2) {
|
|
|
@ -155,7 +162,17 @@ void main_loop()
|
|
|
|
usbserial::write(dac_samples.data(), dac_sample_count * sizeof(dacsample_t));
|
|
|
|
usbserial::write(dac_samples.data(), dac_sample_count * sizeof(dacsample_t));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
case 'D':
|
|
|
|
usbserial::read(&dac_samples[0], dac_sample_count * sizeof(dacsample_t));
|
|
|
|
if (usbserial::read(&cmd[1], 2) == 2) {
|
|
|
|
|
|
|
|
unsigned int count = cmd[1] | (cmd[2] << 8);
|
|
|
|
|
|
|
|
if (count <= MAX_SAMPLE_BUFFER_SIZE / 2) {
|
|
|
|
|
|
|
|
dac2_sample_count = count;
|
|
|
|
|
|
|
|
usbserial::read(&dac2_samples[0], dac2_sample_count * sizeof(dacsample_t));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
error_queue_add(Error::BadParam);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
error_queue_add(Error::BadParamSize);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
// 'E' - Reads in and loads the compiled conversion code binary from USB.
|
|
|
|
// 'E' - Reads in and loads the compiled conversion code binary from USB.
|
|
|
@ -211,7 +228,7 @@ void main_loop()
|
|
|
|
if (!adc_preloaded)
|
|
|
|
if (!adc_preloaded)
|
|
|
|
adc::read_start(signal_operate_measure, &adc_samples[0], adc_sample_count);
|
|
|
|
adc::read_start(signal_operate_measure, &adc_samples[0], adc_sample_count);
|
|
|
|
if (!dac_preloaded)
|
|
|
|
if (!dac_preloaded)
|
|
|
|
dac::write_start(&dac_samples[0], dac_sample_count);
|
|
|
|
dac::write_start(0, &dac_samples[0], dac_sample_count);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
error_queue_add(Error::NotIdle);
|
|
|
|
error_queue_add(Error::NotIdle);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -232,7 +249,7 @@ void main_loop()
|
|
|
|
if (!adc_preloaded)
|
|
|
|
if (!adc_preloaded)
|
|
|
|
adc::read_start(signal_operate, &adc_samples[0], adc_sample_count);
|
|
|
|
adc::read_start(signal_operate, &adc_samples[0], adc_sample_count);
|
|
|
|
if (!dac_preloaded)
|
|
|
|
if (!dac_preloaded)
|
|
|
|
dac::write_start(&dac_samples[0], dac_sample_count);
|
|
|
|
dac::write_start(0, &dac_samples[0], dac_sample_count);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
error_queue_add(Error::NotIdle);
|
|
|
|
error_queue_add(Error::NotIdle);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -251,13 +268,20 @@ void main_loop()
|
|
|
|
case 'S':
|
|
|
|
case 'S':
|
|
|
|
if (run_status == RunStatus::Running) {
|
|
|
|
if (run_status == RunStatus::Running) {
|
|
|
|
if (!dac_preloaded)
|
|
|
|
if (!dac_preloaded)
|
|
|
|
dac::write_stop();
|
|
|
|
dac::write_stop(0);
|
|
|
|
if (!adc_preloaded)
|
|
|
|
if (!adc_preloaded)
|
|
|
|
adc::read_stop();
|
|
|
|
adc::read_stop();
|
|
|
|
run_status = RunStatus::Idle;
|
|
|
|
run_status = RunStatus::Idle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'W':
|
|
|
|
|
|
|
|
dac::write_start(1, &dac2_samples[0], dac2_sample_count);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'w':
|
|
|
|
|
|
|
|
dac::write_stop(1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -272,7 +296,7 @@ void conversion_abort()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
elf_entry = nullptr;
|
|
|
|
elf_entry = nullptr;
|
|
|
|
if (!dac_preloaded)
|
|
|
|
if (!dac_preloaded)
|
|
|
|
dac::write_stop();
|
|
|
|
dac::write_stop(0);
|
|
|
|
if (!adc_preloaded)
|
|
|
|
if (!adc_preloaded)
|
|
|
|
adc::read_stop();
|
|
|
|
adc::read_stop();
|
|
|
|
error_queue_add(Error::ConversionAborted);
|
|
|
|
error_queue_add(Error::ConversionAborted);
|
|
|
|