# Stack size to be allocated to the Cortex-M process stack. This stack is\r
# the stack used by the main() thread.\r
ifeq ($(USE_PROCESS_STACKSIZE),)\r
- USE_PROCESS_STACKSIZE = 8192\r
+ USE_PROCESS_STACKSIZE = 4096\r
endif\r
\r
# Stack size to the allocated to the Cortex-M main/exceptions stack. This\r
# stack is used for processing interrupts and exceptions.\r
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)\r
- USE_EXCEPTIONS_STACKSIZE = 0x400\r
+ USE_EXCEPTIONS_STACKSIZE = 1024\r
endif\r
\r
# Enables the use of FPU (no, softfp, hard).\r
include $(CHIBIOS)/os/hal/hal.mk\r
include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform.mk\r
include $(CHIBIOS)/os/hal/boards/ST_STM32L476_DISCOVERY/board.mk\r
+#include $(CHIBIOS)/os/hal/boards/ST_NUCLEO32_L432KC/board.mk\r
+#include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform_l432.mk\r
include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk\r
# RTOS files (optional).\r
include $(CHIBIOS)/os/rt/rt.mk\r
\r
# Define linker script file here.\r
LDSCRIPT= $(STARTUPLD)/STM32L476xG.ld\r
+#LDSCRIPT= $(STARTUPLD)/STM32L432xC.ld\r
\r
# C sources that can be compiled in ARM or THUMB mode depending on the global\r
# setting.\r
\r
#define STM32L4xx_MCUCONF\r
#define STM32L476_MCUCONF\r
-#define STM32L486_MCUCONF\r
+//#define STM32L432_MCUCONF\r
\r
/*\r
* HAL driver system settings.\r
#define STM32_ADC_DUAL_MODE FALSE\r
#define STM32_ADC_COMPACT_SAMPLES FALSE\r
#define STM32_ADC_USE_ADC1 TRUE\r
-#define STM32_ADC_USE_ADC2 TRUE\r
-#define STM32_ADC_USE_ADC3 TRUE\r
+#define STM32_ADC_USE_ADC2 FALSE\r
+#define STM32_ADC_USE_ADC3 FALSE \r
#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)\r
#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)\r
#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)\r
#define STM32_GPT_USE_TIM1 FALSE\r
#define STM32_GPT_USE_TIM2 FALSE\r
#define STM32_GPT_USE_TIM3 FALSE\r
-#define STM32_GPT_USE_TIM4 TRUE\r
+#define STM32_GPT_USE_TIM4 FALSE\r
#define STM32_GPT_USE_TIM5 FALSE\r
#define STM32_GPT_USE_TIM6 TRUE\r
-#define STM32_GPT_USE_TIM7 FALSE\r
+#define STM32_GPT_USE_TIM7 TRUE\r
#define STM32_GPT_USE_TIM8 FALSE\r
#define STM32_GPT_USE_TIM15 FALSE\r
#define STM32_GPT_USE_TIM16 FALSE\r
/*\r
* USB driver system settings.\r
*/\r
+#ifdef STM32L476_MCUCONF\r
#define STM32_USB_USE_OTG1 TRUE\r
#define STM32_USB_OTG1_IRQ_PRIORITY 14\r
#define STM32_USB_OTG1_RX_FIFO_SIZE 512\r
+#else\r
+#define STM32_USB_USE_USB1 TRUE\r
+#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE\r
+#define STM32_USB_USB1_HP_IRQ_PRIORITY 13\r
+#define STM32_USB_USB1_LP_IRQ_PRIORITY 14\r
+#endif // STM32L476_MCUCONF\r
\r
/*\r
* WDG driver system settings.\r
}
}*/
+ 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");
namespace stmdsp
{
+ constexpr unsigned int SAMPLES_MAX = 4000;
+
class scanner
{
private:
MRunMeasure,
MRunUpload,
MRunUnload,
+ MRunEditBSize,
MRunGenUpload,
MRunGenStart,
MCodeCompile,
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,
}
}
+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;
}
}
- 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);
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) {
void onRunStart(wxCommandEvent&);
void onRunUpload(wxCommandEvent&);
void onRunUnload(wxCommandEvent&);
+ void onRunEditBSize(wxCommandEvent&);
void onRunGenUpload(wxCommandEvent&);
void onRunGenStart(wxCommandEvent&);
#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
#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;
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()
{
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) {
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);
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;
}
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);
}