aboutsummaryrefslogtreecommitdiffstats
path: root/source/main.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2020-10-20 12:27:21 -0400
committerClyne Sullivan <clyne@bitgloo.com>2020-10-20 12:27:21 -0400
commit30cd119dba0e2caf48b6bf5016f60dcede62f511 (patch)
treedfc6d4321938bfb2e32cf9b6ca6af82274ac2625 /source/main.cpp
parentf1ad9796741daa8368f4885bbce360522df24367 (diff)
signal gen with dac channel 2
Diffstat (limited to 'source/main.cpp')
-rw-r--r--source/main.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/source/main.cpp b/source/main.cpp
index c46685f..63bd66b 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -77,6 +77,10 @@ static std::array<adcsample_t, CACHE_SIZE_ALIGN(adcsample_t, MAX_SAMPLE_BUFFER_S
CC_ALIGN(CACHE_LINE_SIZE)
#endif
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 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 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;
@@ -133,6 +138,8 @@ void main_loop()
usbserial::read(&adc_samples[0], adc_sample_count * sizeof(adcsample_t));
break;
+ case 'b':
+ break;
case 'B':
if (run_status == RunStatus::Idle) {
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));
break;
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;
// 'E' - Reads in and loads the compiled conversion code binary from USB.
@@ -211,7 +228,7 @@ void main_loop()
if (!adc_preloaded)
adc::read_start(signal_operate_measure, &adc_samples[0], adc_sample_count);
if (!dac_preloaded)
- dac::write_start(&dac_samples[0], dac_sample_count);
+ dac::write_start(0, &dac_samples[0], dac_sample_count);
} else {
error_queue_add(Error::NotIdle);
}
@@ -232,7 +249,7 @@ void main_loop()
if (!adc_preloaded)
adc::read_start(signal_operate, &adc_samples[0], adc_sample_count);
if (!dac_preloaded)
- dac::write_start(&dac_samples[0], dac_sample_count);
+ dac::write_start(0, &dac_samples[0], dac_sample_count);
} else {
error_queue_add(Error::NotIdle);
}
@@ -251,13 +268,20 @@ void main_loop()
case 'S':
if (run_status == RunStatus::Running) {
if (!dac_preloaded)
- dac::write_stop();
+ dac::write_stop(0);
if (!adc_preloaded)
adc::read_stop();
run_status = RunStatus::Idle;
}
break;
+ case 'W':
+ dac::write_start(1, &dac2_samples[0], dac2_sample_count);
+ break;
+ case 'w':
+ dac::write_stop(1);
+ break;
+
default:
break;
}
@@ -272,7 +296,7 @@ void conversion_abort()
{
elf_entry = nullptr;
if (!dac_preloaded)
- dac::write_stop();
+ dac::write_stop(0);
if (!adc_preloaded)
adc::read_stop();
error_queue_add(Error::ConversionAborted);