|
|
@ -118,8 +118,6 @@ 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 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 dac_preloaded = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main_loop()
|
|
|
|
void main_loop()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -223,10 +221,8 @@ void main_loop()
|
|
|
|
if (run_status == RunStatus::Idle) {
|
|
|
|
if (run_status == RunStatus::Idle) {
|
|
|
|
run_status = RunStatus::Running;
|
|
|
|
run_status = RunStatus::Running;
|
|
|
|
dac_samples.fill(0);
|
|
|
|
dac_samples.fill(0);
|
|
|
|
//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);
|
|
|
|
dac::write_start(0, &dac_samples[0], dac_sample_count);
|
|
|
|
//if (!dac_preloaded)
|
|
|
|
|
|
|
|
dac::write_start(0, &dac_samples[0], dac_sample_count);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
error_queue_add(Error::NotIdle);
|
|
|
|
error_queue_add(Error::NotIdle);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -244,36 +240,33 @@ void main_loop()
|
|
|
|
if (run_status == RunStatus::Idle) {
|
|
|
|
if (run_status == RunStatus::Idle) {
|
|
|
|
run_status = RunStatus::Running;
|
|
|
|
run_status = RunStatus::Running;
|
|
|
|
dac_samples.fill(0);
|
|
|
|
dac_samples.fill(0);
|
|
|
|
//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);
|
|
|
|
dac::write_start(0, &dac_samples[0], dac_sample_count);
|
|
|
|
//if (!dac_preloaded)
|
|
|
|
|
|
|
|
dac::write_start(0, &dac_samples[0], dac_sample_count);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
error_queue_add(Error::NotIdle);
|
|
|
|
error_queue_add(Error::NotIdle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 'r':
|
|
|
|
case 'r':
|
|
|
|
if (usbserial::read(&cmd[1], 1) == 1) {
|
|
|
|
if (usbserial::read(&cmd[1], 1) == 1)
|
|
|
|
adc::set_rate(static_cast<adc::rate>(cmd[1]));
|
|
|
|
adc::set_rate(static_cast<adc::rate>(cmd[1]));
|
|
|
|
// adc_preloaded = cmd[1] & (1 << 0);
|
|
|
|
else
|
|
|
|
// dac_preloaded = cmd[1] & (1 << 1);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
error_queue_add(Error::BadParamSize);
|
|
|
|
error_queue_add(Error::BadParamSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
// 'S' - Stops the continuous sampling/conversion.
|
|
|
|
// 'S' - Stops the continuous sampling/conversion.
|
|
|
|
case 'S':
|
|
|
|
case 'S':
|
|
|
|
if (run_status == RunStatus::Running) {
|
|
|
|
if (run_status == RunStatus::Running) {
|
|
|
|
//if (!dac_preloaded)
|
|
|
|
dac::write_stop(0);
|
|
|
|
dac::write_stop(0);
|
|
|
|
adc::read_stop();
|
|
|
|
//if (!adc_preloaded)
|
|
|
|
|
|
|
|
adc::read_stop();
|
|
|
|
|
|
|
|
run_status = RunStatus::Idle;
|
|
|
|
run_status = RunStatus::Idle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 's':
|
|
|
|
|
|
|
|
usbserial::write(dac_samples.data(), dac_sample_count * sizeof(dacsample_t));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 'W':
|
|
|
|
case 'W':
|
|
|
|
dac::write_start(1, &dac2_samples[0], dac2_sample_count);
|
|
|
|
dac::write_start(1, &dac2_samples[0], dac2_sample_count);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -294,10 +287,8 @@ void main_loop()
|
|
|
|
void conversion_abort()
|
|
|
|
void conversion_abort()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
elf_entry = nullptr;
|
|
|
|
elf_entry = nullptr;
|
|
|
|
//if (!dac_preloaded)
|
|
|
|
dac::write_stop(0);
|
|
|
|
dac::write_stop(0);
|
|
|
|
adc::read_stop();
|
|
|
|
//if (!adc_preloaded)
|
|
|
|
|
|
|
|
adc::read_stop();
|
|
|
|
|
|
|
|
error_queue_add(Error::ConversionAborted);
|
|
|
|
error_queue_add(Error::ConversionAborted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|