diff --git a/cores/nRF5/freertos/config/FreeRTOSConfig.h b/cores/nRF5/freertos/config/FreeRTOSConfig.h index b7cc5cc2..c080ec2d 100644 --- a/cores/nRF5/freertos/config/FreeRTOSConfig.h +++ b/cores/nRF5/freertos/config/FreeRTOSConfig.h @@ -76,7 +76,7 @@ #define configUSE_IDLE_HOOK 1 #define configUSE_TICK_HOOK 0 #define configCHECK_FOR_STACK_OVERFLOW 1 -#define configUSE_MALLOC_FAILED_HOOK (CFG_DEBUG > 0 ? 1 : 0) +#define configUSE_MALLOC_FAILED_HOOK 1 /* Run time and task stats gathering related definitions. */ #define configGENERATE_RUN_TIME_STATS 0 diff --git a/cores/nRF5/main.cpp b/cores/nRF5/main.cpp index d4c65cc5..8207c233 100644 --- a/cores/nRF5/main.cpp +++ b/cores/nRF5/main.cpp @@ -51,6 +51,7 @@ static void loop_task(void* arg) // If Serial is not begin(), call it to avoid hard fault if ( !Serial ) Serial.begin(115200); dbgPrintVersion(); + // dbgMemInfo(); Bluefruit_printInfo(); #endif @@ -64,9 +65,6 @@ static void loop_task(void* arg) // Serial events if (serialEvent && serialEventRun) serialEventRun(); - - // To compatible with most code where loop is not rtos-aware - taskYIELD(); // vTaskDelay(1); } } diff --git a/cores/nRF5/rtos.cpp b/cores/nRF5/rtos.cpp index b4063bbf..32c6f4a9 100644 --- a/cores/nRF5/rtos.cpp +++ b/cores/nRF5/rtos.cpp @@ -43,7 +43,6 @@ void yield(void) taskYIELD(); } - static void _redirect_task(void* arg) { SchedulerRTOS::taskfunc_t taskfunc = (SchedulerRTOS::taskfunc_t) arg; @@ -51,9 +50,6 @@ static void _redirect_task(void* arg) while(1) { taskfunc(); - - // yield() anyway just in case user forgot - taskYIELD(); } } @@ -91,6 +87,16 @@ bool SchedulerRTOS::startLoop(taskfunc_t task, const char* name, uint32_t stack_ extern "C" { +void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName ) +{ + LOG_LV1("RTOS", "%s Stack Overflow !!!", pcTaskName); +} + +void vApplicationMallocFailedHook(void) +{ + LOG_LV1("RTOS", "Failed to Malloc"); +} + void vApplicationIdleHook( void ) { // Internal background task diff --git a/cores/nRF5/sysview/Config/SEGGER_RTT_Conf.h b/cores/nRF5/sysview/Config/SEGGER_RTT_Conf.h index 45abb069..bc4473d1 100644 --- a/cores/nRF5/sysview/Config/SEGGER_RTT_Conf.h +++ b/cores/nRF5/sysview/Config/SEGGER_RTT_Conf.h @@ -125,7 +125,7 @@ Revision: $Rev: 12706 $ // or define SEGGER_RTT_LOCK() to completely disable interrupts. // -#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20) +#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (2 << 5) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20) /********************************************************************* * diff --git a/cores/nRF5/utility/debug.cpp b/cores/nRF5/utility/debug.cpp index 7c9024c3..524fde6b 100644 --- a/cores/nRF5/utility/debug.cpp +++ b/cores/nRF5/utility/debug.cpp @@ -71,16 +71,6 @@ int cprintf(const char * format, ...) return len; } -void vApplicationMallocFailedHook(void) -{ - cprintf("Failed to Malloc"); -} - -void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName ) -{ - cprintf("%s Stack Overflow !!!", pcTaskName); -} - int dbgHeapTotal(void) { return ((uint32_t) __HeapLimit) - ((uint32_t) __HeapBase);