diff --git a/main.c b/main.c index 62250fb..c5ca879 100644 --- a/main.c +++ b/main.c @@ -244,6 +244,7 @@ toggle_sweep(void) // Shell commands output int shell_printf(const char *fmt, ...) { + if (shell_stream == NULL) return 0; va_list ap; int formatted_bytes = 0; if (shell_stream) { @@ -1888,7 +1889,7 @@ static void shell_init_connection(void){ #else // Only USB console, shell_stream always on USB -#define PREPARE_STREAM +#define PREPARE_STREAM shell_stream = (BaseSequentialStream *)&SDU1; #if 0 // Not used // Check connection as Active, if no suspend input @@ -1918,7 +1919,7 @@ static void shell_init_connection(void){ /* * Set I/O stream SDU1 for shell */ - shell_stream = (BaseSequentialStream *)&SDU1; + PREPARE_STREAM; } #endif @@ -2029,10 +2030,8 @@ void sd_card_load_config(char *filename){ if (f_open(fs_file, filename, FA_OPEN_EXISTING | FA_READ) != FR_OK) return; - - BaseSequentialStream *old_shell_stream = shell_stream; - shell_stream = (BaseSequentialStream *)NULL; - + // Reset IO stream + shell_stream = NULL; char *buf = (char *)spi_buffer; UINT size = 0; @@ -2061,7 +2060,8 @@ void sd_card_load_config(char *filename){ } } f_close(fs_file); - shell_stream = old_shell_stream; + // Prepare I/O for shell_stream + PREPARE_STREAM; return; } #endif @@ -2221,8 +2221,6 @@ int main(void) shell_init_connection(); - - set_sweep_points(POINTS_COUNT); #ifdef __AUDIO__ @@ -2275,10 +2273,6 @@ int main(void) dacPutChannelX(&DACD2, 0, config.dac_value); #endif dacStart(&DACD1, &dac1cfg1); -#ifdef TINYSA4 - disk_initialize(0); -// SD_PowerOn(); -#endif chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL);