From 5476d0729af954d0e54afacb097146e26d2e4523 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 29 Oct 2018 21:46:04 +0700 Subject: [PATCH] clean up --- cores/nRF5/main.cpp | 17 ++--------------- cores/nRF5/usb/USBSerial.cpp | 8 ++++++-- .../External_Format/External_Format.ino | 6 +++++- libraries/FileSystem/src/ExternalFS.cpp | 1 + 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/cores/nRF5/main.cpp b/cores/nRF5/main.cpp index 92691832..d4c65cc5 100644 --- a/cores/nRF5/main.cpp +++ b/cores/nRF5/main.cpp @@ -16,9 +16,6 @@ #define ARDUINO_MAIN #include "Arduino.h" -#define DBG_MEM_INFO 0 -#define DBG_MEM_INFO_INTERVAL 60000 - // DEBUG Level 1 #if CFG_DEBUG // weak function to avoid compilation error with @@ -61,23 +58,13 @@ static void loop_task(void* arg) { loop(); - #ifdef NRF52840_XXAA +#ifdef NRF52840_XXAA tud_cdc_write_flush(); - #endif +#endif // Serial events if (serialEvent && serialEventRun) serialEventRun(); - #if CFG_DEBUG >= 2 && DBG_MEM_INFO - static uint32_t meminfo_ms = 0; - if (meminfo_ms + DBG_MEM_INFO_INTERVAL < millis()) - { - meminfo_ms += millis(); - Serial.printf("Memory Info (print every %d seconds)\n", DBG_MEM_INFO_INTERVAL/1000); - dbgMemInfo(); - } - #endif - // To compatible with most code where loop is not rtos-aware taskYIELD(); // vTaskDelay(1); } diff --git a/cores/nRF5/usb/USBSerial.cpp b/cores/nRF5/usb/USBSerial.cpp index 6bbfd5c2..33fd2df1 100644 --- a/cores/nRF5/usb/USBSerial.cpp +++ b/cores/nRF5/usb/USBSerial.cpp @@ -104,8 +104,12 @@ size_t USBSerial::write(const uint8_t *buffer, size_t size) size -= wrcount; buffer += wrcount; - // Write FIFO is full, flush and re-write - if ( size ) tud_cdc_write_flush(); + // Write FIFO is full, flush and re-try + if ( size ) + { + tud_cdc_write_flush(); + delay(1); + } } } diff --git a/libraries/FileSystem/examples/External_Format/External_Format.ino b/libraries/FileSystem/examples/External_Format/External_Format.ino index 8b423515..804fc71e 100644 --- a/libraries/FileSystem/examples/External_Format/External_Format.ino +++ b/libraries/FileSystem/examples/External_Format/External_Format.ino @@ -34,11 +34,15 @@ void setup() ExternalFS.begin(); Serial.print("Formating ..."); + Serial.println(flash_qspi_size()); + Serial.flush(); // Format without erase - ExternalFS.format(true); + // Pass true for full external flash erasing (take time) + ExternalFS.format(false); Serial.println("Done"); + Serial.flush(); } // the loop function runs over and over again forever diff --git a/libraries/FileSystem/src/ExternalFS.cpp b/libraries/FileSystem/src/ExternalFS.cpp index 0ae61bfb..0f60cac1 100644 --- a/libraries/FileSystem/src/ExternalFS.cpp +++ b/libraries/FileSystem/src/ExternalFS.cpp @@ -157,6 +157,7 @@ bool FatFS::format (bool eraseall) { if ( eraseall ) { + LOG_LV2("EFLASH", "full erasing"); VERIFY(flash_qspi_chiperase()); }