stable signal handling towards 100kHz

pull/3/head
Clyne 4 years ago
parent dccf7ed52d
commit 7077b8d448

@ -100,6 +100,7 @@ public:
auto button = dynamic_cast<wxButton *>(ce.GetEventObject()); auto button = dynamic_cast<wxButton *>(ce.GetEventObject());
if (!m_render_timer->IsRunning()) { if (!m_render_timer->IsRunning()) {
if (m_device == nullptr)
m_device = new stmdsp::device(m_device_combo->GetStringSelection().ToStdString()); m_device = new stmdsp::device(m_device_combo->GetStringSelection().ToStdString());
if (m_device->connected()) { if (m_device->connected()) {
m_device->continuous_start(); m_device->continuous_start();
@ -116,8 +117,8 @@ public:
m_device->continuous_stop(); m_device->continuous_stop();
button->SetLabel("Single"); button->SetLabel("Single");
delete m_device; //delete m_device;
m_device = nullptr; //m_device = nullptr;
} }
} }
@ -129,10 +130,11 @@ public:
if (wxFileInputStream file_stream (/*dialog.GetPath()*/file); file_stream.IsOk()) { if (wxFileInputStream file_stream (/*dialog.GetPath()*/file); file_stream.IsOk()) {
auto size = file_stream.GetSize(); auto size = file_stream.GetSize();
auto buffer = new unsigned char[size]; auto buffer = new unsigned char[size];
auto device = new stmdsp::device(m_device_combo->GetStringSelection().ToStdString()); if (m_device == nullptr)
if (device->connected()) { m_device = new stmdsp::device(m_device_combo->GetStringSelection().ToStdString());
if (m_device->connected()) {
file_stream.ReadAll(buffer, size); file_stream.ReadAll(buffer, size);
device->upload_filter(buffer, size); m_device->upload_filter(buffer, size);
} }
} }
} }

@ -29,7 +29,7 @@ static void adc_read_callback(ADCDriver *);
.cfgr2 = 0, .cfgr2 = 0,
.tr1 = ADC_TR(0, 4095), .tr1 = ADC_TR(0, 4095),
.smpr = { .smpr = {
ADC_SMPR1_SMP_AN5(ADC_SMPR_SMP_247P5), 0 ADC_SMPR1_SMP_AN5(ADC_SMPR_SMP_2P5), 0
}, },
.sqr = { .sqr = {
ADC_SQR1_SQ1_N(ADC_CHANNEL_IN5), ADC_SQR1_SQ1_N(ADC_CHANNEL_IN5),
@ -38,7 +38,7 @@ static void adc_read_callback(ADCDriver *);
}; };
constexpr static const GPTConfig gpt_config = { constexpr static const GPTConfig gpt_config = {
.frequency = 1000000, .frequency = 4000000,
.callback = nullptr, .callback = nullptr,
.cr2 = TIM_CR2_MMS_1, /* TRGO */ .cr2 = TIM_CR2_MMS_1, /* TRGO */
.dier = 0 .dier = 0
@ -65,7 +65,7 @@ namespace adc
adc_is_read_finished = false; adc_is_read_finished = false;
adc_group_config.circular = false; adc_group_config.circular = false;
adcStartConversion(adcd, &adc_group_config, buffer, count); adcStartConversion(adcd, &adc_group_config, buffer, count);
gptStartContinuous(gptd, 100); // 10kHz gptStartContinuous(gptd, 2);
while (!adc_is_read_finished); while (!adc_is_read_finished);
return buffer; return buffer;
} }
@ -77,7 +77,7 @@ namespace adc
adc_operation_func = operation_func; adc_operation_func = operation_func;
adc_group_config.circular = true; adc_group_config.circular = true;
adcStartConversion(adcd, &adc_group_config, buffer, count); adcStartConversion(adcd, &adc_group_config, buffer, count);
gptStartContinuous(gptd, 100); // 10kHz gptStartContinuous(gptd, 2);
} }
void read_stop() void read_stop()

@ -28,7 +28,7 @@ constexpr static const DACConversionGroup dac_group_config = {
}; };
constexpr static const GPTConfig gpt_config = { constexpr static const GPTConfig gpt_config = {
.frequency = 1000000, .frequency = 4000000,
.callback = nullptr, .callback = nullptr,
.cr2 = TIM_CR2_MMS_1, /* TRGO */ .cr2 = TIM_CR2_MMS_1, /* TRGO */
.dier = 0 .dier = 0
@ -48,7 +48,7 @@ namespace dac
void write_start(dacsample_t *buffer, size_t count) void write_start(dacsample_t *buffer, size_t count)
{ {
dacStartConversion(dacd, &dac_group_config, buffer, count); dacStartConversion(dacd, &dac_group_config, buffer, count);
gptStartContinuous(gptd, 100); gptStartContinuous(gptd, 2);
} }
void write_stop() void write_stop()

Loading…
Cancel
Save