firmware can port to L432KC; gui: edit buffer size

pull/3/head
Clyne 4 years ago
parent 30cd119dba
commit ee274be303

@ -55,13 +55,13 @@ endif
# Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),)
USE_PROCESS_STACKSIZE = 8192
USE_PROCESS_STACKSIZE = 4096
endif
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
# stack is used for processing interrupts and exceptions.
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
USE_EXCEPTIONS_STACKSIZE = 0x400
USE_EXCEPTIONS_STACKSIZE = 1024
endif
# Enables the use of FPU (no, softfp, hard).
@ -102,6 +102,8 @@ include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32l4xx.m
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform.mk
include $(CHIBIOS)/os/hal/boards/ST_STM32L476_DISCOVERY/board.mk
#include $(CHIBIOS)/os/hal/boards/ST_NUCLEO32_L432KC/board.mk
#include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform_l432.mk
include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
@ -115,6 +117,7 @@ include $(CHIBIOS)/tools/mk/autobuild.mk
# Define linker script file here.
LDSCRIPT= $(STARTUPLD)/STM32L476xG.ld
#LDSCRIPT= $(STARTUPLD)/STM32L432xC.ld
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.

@ -33,7 +33,7 @@
#define STM32L4xx_MCUCONF
#define STM32L476_MCUCONF
#define STM32L486_MCUCONF
//#define STM32L432_MCUCONF
/*
* HAL driver system settings.
@ -135,8 +135,8 @@
#define STM32_ADC_DUAL_MODE FALSE
#define STM32_ADC_COMPACT_SAMPLES FALSE
#define STM32_ADC_USE_ADC1 TRUE
#define STM32_ADC_USE_ADC2 TRUE
#define STM32_ADC_USE_ADC3 TRUE
#define STM32_ADC_USE_ADC2 FALSE
#define STM32_ADC_USE_ADC3 FALSE
#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
@ -178,10 +178,10 @@
#define STM32_GPT_USE_TIM1 FALSE
#define STM32_GPT_USE_TIM2 FALSE
#define STM32_GPT_USE_TIM3 FALSE
#define STM32_GPT_USE_TIM4 TRUE
#define STM32_GPT_USE_TIM4 FALSE
#define STM32_GPT_USE_TIM5 FALSE
#define STM32_GPT_USE_TIM6 TRUE
#define STM32_GPT_USE_TIM7 FALSE
#define STM32_GPT_USE_TIM7 TRUE
#define STM32_GPT_USE_TIM8 FALSE
#define STM32_GPT_USE_TIM15 FALSE
#define STM32_GPT_USE_TIM16 FALSE
@ -335,9 +335,16 @@
/*
* USB driver system settings.
*/
#ifdef STM32L476_MCUCONF
#define STM32_USB_USE_OTG1 TRUE
#define STM32_USB_OTG1_IRQ_PRIORITY 14
#define STM32_USB_OTG1_RX_FIFO_SIZE 512
#else
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
#endif // STM32L476_MCUCONF
/*
* WDG driver system settings.

@ -41,6 +41,17 @@ namespace stmdsp
}
}*/
void device::continuous_set_buffer_size(unsigned int size) {
if (connected()) {
uint8_t request[3] = {
'B',
static_cast<uint8_t>(size),
static_cast<uint8_t>(size >> 8)
};
m_serial.write(request, 3);
}
}
void device::continuous_start() {
if (connected())
m_serial.write("R");

@ -8,6 +8,8 @@
namespace stmdsp
{
constexpr unsigned int SAMPLES_MAX = 4000;
class scanner
{
private:

@ -28,6 +28,7 @@ enum Id {
MRunMeasure,
MRunUpload,
MRunUnload,
MRunEditBSize,
MRunGenUpload,
MRunGenStart,
MCodeCompile,
@ -103,6 +104,8 @@ MainFrame::MainFrame() : wxFrame(nullptr, wxID_ANY, "stmdspgui", wxPoint(50, 50)
menuRun->Append(MRunUpload, "&Upload code"));
Bind(wxEVT_MENU, &MainFrame::onRunUnload, this, Id::MRunUnload, wxID_ANY,
menuRun->Append(MRunUnload, "U&nload code"));
Bind(wxEVT_MENU, &MainFrame::onRunEditBSize, this, Id::MRunEditBSize, wxID_ANY,
menuRun->Append(MRunEditBSize, "Set &buffer size..."));
menuRun->AppendSeparator();
Bind(wxEVT_MENU, &MainFrame::onRunGenUpload, this, Id::MRunGenUpload, wxID_ANY,
@ -409,10 +412,38 @@ void MainFrame::onRunStart(wxCommandEvent& ce)
}
}
void MainFrame::onRunEditBSize([[maybe_unused]] wxCommandEvent&)
{
if (m_device != nullptr && m_device->connected()) {
wxTextEntryDialog dialog (this, "Enter new buffer size (100-4000)", "Set Buffer Size");
if (dialog.ShowModal() == wxID_OK) {
if (wxString value = dialog.GetValue(); !value.IsEmpty()) {
if (unsigned long n; value.ToULong(&n)) {
if (n >= 100 && n <= stmdsp::SAMPLES_MAX) {
m_device->continuous_set_buffer_size(n);
} else {
m_status_bar->SetStatusText("Error: Invalid buffer size.");
}
} else {
m_status_bar->SetStatusText("Error: Invalid buffer size.");
}
} else {
m_status_bar->SetStatusText("Ready.");
}
} else {
m_status_bar->SetStatusText("Ready.");
}
} else {
wxMessageBox("No device connected!", "Run", wxICON_WARNING);
m_status_bar->SetStatusText("Please connect.");
}
}
void MainFrame::onRunGenUpload([[maybe_unused]] wxCommandEvent&)
{
if (m_device != nullptr && m_device->connected()) {
wxTextEntryDialog dialog (this, "Enter generator values", "Hey");
wxTextEntryDialog dialog (this, "Enter generator values below. Values must be whole numbers "
"between zero and 4095.", "Enter Generator Values");
if (dialog.ShowModal() == wxID_OK) {
if (wxString values = dialog.GetValue(); !values.IsEmpty()) {
std::vector<stmdsp::dacsample_t> samples;
@ -436,8 +467,17 @@ void MainFrame::onRunGenUpload([[maybe_unused]] wxCommandEvent&)
}
}
m_device->siggen_upload(&samples[0], samples.size());
if (samples.size() <= stmdsp::SAMPLES_MAX) {
m_device->siggen_upload(&samples[0], samples.size());
m_status_bar->SetStatusText("Generator ready.");
} else {
m_status_bar->SetStatusText("Error: Too many samples.");
}
} else {
m_status_bar->SetStatusText("Error: No samples given.");
}
} else {
m_status_bar->SetStatusText("Ready.");
}
} else {
wxMessageBox("No device connected!", "Run", wxICON_WARNING);
@ -500,7 +540,7 @@ void MainFrame::onRunCompile([[maybe_unused]] wxCommandEvent&)
void MainFrame::onCodeDisassemble([[maybe_unused]] wxCommandEvent&)
{
auto output = m_temp_file_name + ".asm.log";
wxString command = wxString("arm-none-eabi-objdump -d ") + m_temp_file_name + ".orig.o"
wxString command = wxString("arm-none-eabi-objdump -d --no-show-raw-insn ") + m_temp_file_name + ".orig.o"
" > " + output + " 2>&1";
if (system(command.ToAscii()) == 0) {

@ -36,6 +36,7 @@ public:
void onRunStart(wxCommandEvent&);
void onRunUpload(wxCommandEvent&);
void onRunUnload(wxCommandEvent&);
void onRunEditBSize(wxCommandEvent&);
void onRunGenUpload(wxCommandEvent&);
void onRunGenStart(wxCommandEvent&);

@ -12,7 +12,7 @@
#include "adc.hpp"
constexpr static const auto adcd = &ADCD1;
constexpr static const auto gptd = &GPTD4;
constexpr static const auto gptd = &GPTD7;
constexpr static const ADCConfig adc_config = {
.difsel = 0

@ -19,7 +19,7 @@
#include <array>
constexpr unsigned int MAX_ELF_FILE_SIZE = 12 * 1024;
constexpr unsigned int MAX_ELF_FILE_SIZE = 8 * 1024;
constexpr unsigned int MAX_ERROR_QUEUE_SIZE = 8;
constexpr unsigned int MAX_SAMPLE_BUFFER_SIZE = 8000;
@ -118,8 +118,8 @@ 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;
//static bool adc_preloaded = false;
//static bool dac_preloaded = false;
void main_loop()
{
@ -138,8 +138,6 @@ 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) {
@ -225,9 +223,9 @@ void main_loop()
if (run_status == RunStatus::Idle) {
run_status = RunStatus::Running;
dac_samples.fill(0);
if (!adc_preloaded)
//if (!adc_preloaded)
adc::read_start(signal_operate_measure, &adc_samples[0], adc_sample_count);
if (!dac_preloaded)
//if (!dac_preloaded)
dac::write_start(0, &dac_samples[0], dac_sample_count);
} else {
error_queue_add(Error::NotIdle);
@ -246,30 +244,30 @@ void main_loop()
if (run_status == RunStatus::Idle) {
run_status = RunStatus::Running;
dac_samples.fill(0);
if (!adc_preloaded)
//if (!adc_preloaded)
adc::read_start(signal_operate, &adc_samples[0], adc_sample_count);
if (!dac_preloaded)
//if (!dac_preloaded)
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) {
adc_preloaded = cmd[1] & (1 << 0);
dac_preloaded = cmd[1] & (1 << 1);
} else {
error_queue_add(Error::BadParamSize);
}
break;
//case 'r':
// if (usbserial::read(&cmd[1], 1) == 1) {
// adc_preloaded = cmd[1] & (1 << 0);
// dac_preloaded = cmd[1] & (1 << 1);
// } else {
// error_queue_add(Error::BadParamSize);
// }
// break;
// 'S' - Stops the continuous sampling/conversion.
case 'S':
if (run_status == RunStatus::Running) {
if (!dac_preloaded)
//if (!dac_preloaded)
dac::write_stop(0);
if (!adc_preloaded)
//if (!adc_preloaded)
adc::read_stop();
run_status = RunStatus::Idle;
}
@ -295,9 +293,9 @@ void main_loop()
void conversion_abort()
{
elf_entry = nullptr;
if (!dac_preloaded)
//if (!dac_preloaded)
dac::write_stop(0);
if (!adc_preloaded)
//if (!adc_preloaded)
adc::read_stop();
error_queue_add(Error::ConversionAborted);
}

Loading…
Cancel
Save