|
|
@ -112,22 +112,23 @@ void updateGenerator(unsigned char *cmd)
|
|
|
|
if (EM.assert(USBSerial::read(&cmd[1], 2) == 2, Error::BadParamSize)) {
|
|
|
|
if (EM.assert(USBSerial::read(&cmd[1], 2) == 2, Error::BadParamSize)) {
|
|
|
|
unsigned int count = cmd[1] | (cmd[2] << 8);
|
|
|
|
unsigned int count = cmd[1] | (cmd[2] << 8);
|
|
|
|
if (EM.assert(count <= MAX_SAMPLE_BUFFER_SIZE, Error::BadParam)) {
|
|
|
|
if (EM.assert(count <= MAX_SAMPLE_BUFFER_SIZE, Error::BadParam)) {
|
|
|
|
if (run_status == RunStatus::Idle) {
|
|
|
|
if (!DAC::isSigGenRunning()) {
|
|
|
|
Samples::Generator.setSize(count);
|
|
|
|
Samples::Generator.setSize(count);
|
|
|
|
USBSerial::read(
|
|
|
|
USBSerial::read(
|
|
|
|
reinterpret_cast<uint8_t *>(Samples::Generator.data()),
|
|
|
|
reinterpret_cast<uint8_t *>(Samples::Generator.data()),
|
|
|
|
Samples::Generator.bytesize());
|
|
|
|
Samples::Generator.bytesize());
|
|
|
|
} else if (run_status == RunStatus::Running) {
|
|
|
|
} else {
|
|
|
|
int more;
|
|
|
|
const int more = DAC::sigGenWantsMore();
|
|
|
|
do {
|
|
|
|
if (more == -1) {
|
|
|
|
chThdSleepMicroseconds(10);
|
|
|
|
USBSerial::write(reinterpret_cast<const uint8_t *>("\0"), 1);
|
|
|
|
more = DAC::sigGenWantsMore();
|
|
|
|
} else {
|
|
|
|
} while (more == -1);
|
|
|
|
USBSerial::write(reinterpret_cast<const uint8_t *>("\1"), 1);
|
|
|
|
|
|
|
|
|
|
|
|
// Receive streamed samples in half-buffer chunks.
|
|
|
|
// Receive streamed samples in half-buffer chunks.
|
|
|
|
USBSerial::read(reinterpret_cast<uint8_t *>(
|
|
|
|
USBSerial::read(reinterpret_cast<uint8_t *>(
|
|
|
|
more == 0 ? Samples::Generator.data() : Samples::Generator.middata()),
|
|
|
|
more == 0 ? Samples::Generator.data() : Samples::Generator.middata()),
|
|
|
|
Samples::Generator.bytesize() / 2);
|
|
|
|
Samples::Generator.bytesize() / 2);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|