Skip to content

Commit 8045b1e

Browse files
committed
rtos clean up, remove yield at the end of loop()
1 parent 1b2b85c commit 8045b1e

File tree

5 files changed

+13
-19
lines changed

5 files changed

+13
-19
lines changed

cores/nRF5/freertos/config/FreeRTOSConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
#define configUSE_IDLE_HOOK 1
7777
#define configUSE_TICK_HOOK 0
7878
#define configCHECK_FOR_STACK_OVERFLOW 1
79-
#define configUSE_MALLOC_FAILED_HOOK (CFG_DEBUG > 0 ? 1 : 0)
79+
#define configUSE_MALLOC_FAILED_HOOK 1
8080

8181
/* Run time and task stats gathering related definitions. */
8282
#define configGENERATE_RUN_TIME_STATS 0

cores/nRF5/main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static void loop_task(void* arg)
5151
// If Serial is not begin(), call it to avoid hard fault
5252
if ( !Serial ) Serial.begin(115200);
5353
dbgPrintVersion();
54+
// dbgMemInfo();
5455
Bluefruit_printInfo();
5556
#endif
5657

@@ -64,9 +65,6 @@ static void loop_task(void* arg)
6465

6566
// Serial events
6667
if (serialEvent && serialEventRun) serialEventRun();
67-
68-
// To compatible with most code where loop is not rtos-aware
69-
taskYIELD(); // vTaskDelay(1);
7068
}
7169
}
7270

cores/nRF5/rtos.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,13 @@ void yield(void)
4343
taskYIELD();
4444
}
4545

46-
4746
static void _redirect_task(void* arg)
4847
{
4948
SchedulerRTOS::taskfunc_t taskfunc = (SchedulerRTOS::taskfunc_t) arg;
5049

5150
while(1)
5251
{
5352
taskfunc();
54-
55-
// yield() anyway just in case user forgot
56-
taskYIELD();
5753
}
5854
}
5955

@@ -91,6 +87,16 @@ bool SchedulerRTOS::startLoop(taskfunc_t task, const char* name, uint32_t stack_
9187
extern "C"
9288
{
9389

90+
void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName )
91+
{
92+
LOG_LV1("RTOS", "%s Stack Overflow !!!", pcTaskName);
93+
}
94+
95+
void vApplicationMallocFailedHook(void)
96+
{
97+
LOG_LV1("RTOS", "Failed to Malloc");
98+
}
99+
94100
void vApplicationIdleHook( void )
95101
{
96102
// Internal background task

cores/nRF5/sysview/Config/SEGGER_RTT_Conf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Revision: $Rev: 12706 $
125125
// or define SEGGER_RTT_LOCK() to completely disable interrupts.
126126
//
127127

128-
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
128+
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (2 << 5) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
129129

130130
/*********************************************************************
131131
*

cores/nRF5/utility/debug.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,6 @@ int cprintf(const char * format, ...)
7171
return len;
7272
}
7373

74-
void vApplicationMallocFailedHook(void)
75-
{
76-
cprintf("Failed to Malloc");
77-
}
78-
79-
void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName )
80-
{
81-
cprintf("%s Stack Overflow !!!", pcTaskName);
82-
}
83-
8474
int dbgHeapTotal(void)
8575
{
8676
return ((uint32_t) __HeapLimit) - ((uint32_t) __HeapBase);

0 commit comments

Comments
 (0)