aboutsummaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2020-10-27 20:27:30 -0400
committerClyne Sullivan <clyne@bitgloo.com>2020-10-27 20:27:30 -0400
commit1b5ca39ba78010bd4ae097982fe71ec609b4937f (patch)
tree92cdd178614dacac6df516f1abdf53130d96f248 /source
parentf58821430754f5ea3627d50672415548e2fbd59f (diff)
allow output recording
Diffstat (limited to 'source')
-rw-r--r--source/main.cpp37
1 files changed, 14 insertions, 23 deletions
diff --git a/source/main.cpp b/source/main.cpp
index 67a39a3..43abc22 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -118,8 +118,6 @@ int main()
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 bool adc_preloaded = false;
-//static bool dac_preloaded = false;
void main_loop()
{
@@ -223,10 +221,8 @@ void main_loop()
if (run_status == RunStatus::Idle) {
run_status = RunStatus::Running;
dac_samples.fill(0);
- //if (!adc_preloaded)
- adc::read_start(signal_operate_measure, &adc_samples[0], adc_sample_count);
- //if (!dac_preloaded)
- dac::write_start(0, &dac_samples[0], dac_sample_count);
+ adc::read_start(signal_operate_measure, &adc_samples[0], adc_sample_count);
+ dac::write_start(0, &dac_samples[0], dac_sample_count);
} else {
error_queue_add(Error::NotIdle);
}
@@ -244,36 +240,33 @@ void main_loop()
if (run_status == RunStatus::Idle) {
run_status = RunStatus::Running;
dac_samples.fill(0);
- //if (!adc_preloaded)
- adc::read_start(signal_operate, &adc_samples[0], adc_sample_count);
- //if (!dac_preloaded)
- dac::write_start(0, &dac_samples[0], dac_sample_count);
+ adc::read_start(signal_operate, &adc_samples[0], adc_sample_count);
+ dac::write_start(0, &dac_samples[0], dac_sample_count);
} else {
error_queue_add(Error::NotIdle);
}
break;
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_preloaded = cmd[1] & (1 << 0);
- // dac_preloaded = cmd[1] & (1 << 1);
- } else {
+ else
error_queue_add(Error::BadParamSize);
- }
break;
// 'S' - Stops the continuous sampling/conversion.
case 'S':
if (run_status == RunStatus::Running) {
- //if (!dac_preloaded)
- dac::write_stop(0);
- //if (!adc_preloaded)
- adc::read_stop();
+ dac::write_stop(0);
+ adc::read_stop();
run_status = RunStatus::Idle;
}
break;
+ case 's':
+ usbserial::write(dac_samples.data(), dac_sample_count * sizeof(dacsample_t));
+ break;
+
case 'W':
dac::write_start(1, &dac2_samples[0], dac2_sample_count);
break;
@@ -294,10 +287,8 @@ void main_loop()
void conversion_abort()
{
elf_entry = nullptr;
- //if (!dac_preloaded)
- dac::write_stop(0);
- //if (!adc_preloaded)
- adc::read_stop();
+ dac::write_stop(0);
+ adc::read_stop();
error_queue_add(Error::ConversionAborted);
}