9191/* This demo uses heap_3.c (the libc provided malloc() and free()). */
9292
9393/*-----------------------------------------------------------*/
94+
9495extern void main_blinky ( void );
9596extern void main_full ( void );
9697static void traceOnEnter ( void );
@@ -118,11 +119,15 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
118119 StackType_t * * ppxTimerTaskStackBuffer ,
119120 uint32_t * pulTimerTaskStackSize );
120121
121- /*
122- * Writes trace data to a disk file when the trace recording is stopped.
123- * This function will simply overwrite any trace files that already exist.
124- */
125- static void prvSaveTraceFile ( void );
122+ #if ( projENABLE_TRACING == 1 )
123+
124+ /*
125+ * Writes trace data to a disk file when the trace recording is stopped.
126+ * This function will simply overwrite any trace files that already exist.
127+ */
128+ static void prvSaveTraceFile ( void );
129+
130+ #endif /* if ( projENABLE_TRACING == 1 ) */
126131
127132/*
128133 * Signal handler for Ctrl_C to cause the program to exit, and generate the
@@ -139,8 +144,6 @@ static void handle_sigint( int signal );
139144 * in a different file. */
140145StackType_t uxTimerTaskStack [ configTIMER_TASK_STACK_DEPTH ];
141146
142- static clockid_t cid = CLOCK_THREAD_CPUTIME_ID ;
143-
144147/*-----------------------------------------------------------*/
145148
146149int main ( void )
@@ -183,6 +186,7 @@ int main( void )
183186
184187 return 0 ;
185188}
189+
186190/*-----------------------------------------------------------*/
187191
188192void vApplicationMallocFailedHook ( void )
@@ -201,6 +205,7 @@ void vApplicationMallocFailedHook( void )
201205 * information. */
202206 vAssertCalled ( __FILE__ , __LINE__ );
203207}
208+
204209/*-----------------------------------------------------------*/
205210
206211void vApplicationIdleHook ( void )
@@ -227,6 +232,7 @@ void vApplicationIdleHook( void )
227232 }
228233 #endif
229234}
235+
230236/*-----------------------------------------------------------*/
231237
232238void vApplicationStackOverflowHook ( TaskHandle_t pxTask ,
@@ -242,6 +248,7 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask,
242248 * when running the FreeRTOS POSIX port. */
243249 vAssertCalled ( __FILE__ , __LINE__ );
244250}
251+
245252/*-----------------------------------------------------------*/
246253
247254void vApplicationTickHook ( void )
@@ -259,6 +266,8 @@ void vApplicationTickHook( void )
259266 #endif /* mainSELECTED_APPLICATION */
260267}
261268
269+ /*-----------------------------------------------------------*/
270+
262271void traceOnEnter ()
263272{
264273 #if ( TRACE_ON_ENTER == 1 )
@@ -286,6 +295,8 @@ void traceOnEnter()
286295 #endif /* if ( TRACE_ON_ENTER == 1 ) */
287296}
288297
298+ /*-----------------------------------------------------------*/
299+
289300void vLoggingPrintf ( const char * pcFormat ,
290301 ... )
291302{
@@ -295,15 +306,17 @@ void vLoggingPrintf( const char * pcFormat,
295306 vprintf ( pcFormat , arg );
296307 va_end ( arg );
297308}
309+
298310/*-----------------------------------------------------------*/
299311
300312void vApplicationDaemonTaskStartupHook ( void )
301313{
302314 /* This function will be called once only, when the daemon task starts to
303- * execute (sometimes called the timer task). This is useful if the
315+ * execute (sometimes called the timer task). This is useful if the
304316 * application includes initialisation code that would benefit from executing
305317 * after the scheduler has been started. */
306318}
319+
307320/*-----------------------------------------------------------*/
308321
309322void vAssertCalled ( const char * const pcFileName ,
@@ -345,9 +358,11 @@ void vAssertCalled( const char * const pcFileName,
345358 }
346359 taskEXIT_CRITICAL ();
347360}
361+
348362/*-----------------------------------------------------------*/
349363
350364#if ( projENABLE_TRACING == 1 )
365+
351366 static void prvSaveTraceFile ( void )
352367 {
353368 FILE * pxOutputFile ;
@@ -367,7 +382,9 @@ void vAssertCalled( const char * const pcFileName,
367382 printf ( "\r\nFailed to create trace dump file\r\n" );
368383 }
369384 }
385+
370386#endif /* if ( projENABLE_TRACING == 1 ) */
387+
371388/*-----------------------------------------------------------*/
372389
373390/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
@@ -377,9 +394,9 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
377394 StackType_t * * ppxIdleTaskStackBuffer ,
378395 uint32_t * pulIdleTaskStackSize )
379396{
380- /* If the buffers to be provided to the Idle task are declared inside this
381- * function then they must be declared static - otherwise they will be allocated on
382- * the stack and so not exists after this function exits. */
397+ /* If the buffers to be provided to the Idle task are declared inside this
398+ * function then they must be declared static - otherwise they will be allocated on
399+ * the stack and so not exists after this function exits. */
383400 static StaticTask_t xIdleTaskTCB ;
384401 static StackType_t uxIdleTaskStack [ configMINIMAL_STACK_SIZE ];
385402
@@ -395,6 +412,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
395412 * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
396413 * pulIdleTaskStackSize = configMINIMAL_STACK_SIZE ;
397414}
415+
398416/*-----------------------------------------------------------*/
399417
400418/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
@@ -404,9 +422,9 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
404422 StackType_t * * ppxTimerTaskStackBuffer ,
405423 uint32_t * pulTimerTaskStackSize )
406424{
407- /* If the buffers to be provided to the Timer task are declared inside this
408- * function then they must be declared static - otherwise they will be allocated on
409- * the stack and so not exists after this function exits. */
425+ /* If the buffers to be provided to the Timer task are declared inside this
426+ * function then they must be declared static - otherwise they will be allocated on
427+ * the stack and so not exists after this function exits. */
410428 static StaticTask_t xTimerTaskTCB ;
411429
412430 /* Pass out a pointer to the StaticTask_t structure in which the Timer
@@ -422,11 +440,15 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
422440 * pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH ;
423441}
424442
443+ /*-----------------------------------------------------------*/
444+
425445void handle_sigint ( int signal )
426446{
427447 int xReturn ;
428448
429- xReturn = chdir ( BUILD ); /* changing dir to place gmon.out inside build */
449+ ( void ) signal ;
450+
451+ xReturn = chdir ( BUILD ); /* Changing dir to place gmon.out inside build. */
430452
431453 if ( xReturn == -1 )
432454 {
@@ -436,19 +458,27 @@ void handle_sigint( int signal )
436458 exit ( 2 );
437459}
438460
461+ /*-----------------------------------------------------------*/
462+
439463static uint32_t ulEntryTime = 0 ;
440464
441465void vTraceTimerReset ( void )
442466{
443467 ulEntryTime = xTaskGetTickCount ();
444468}
445469
470+ /*-----------------------------------------------------------*/
471+
446472uint32_t uiTraceTimerGetFrequency ( void )
447473{
448474 return configTICK_RATE_HZ ;
449475}
450476
477+ /*-----------------------------------------------------------*/
478+
451479uint32_t uiTraceTimerGetValue ( void )
452480{
453481 return ( xTaskGetTickCount () - ulEntryTime );
454482}
483+
484+ /*-----------------------------------------------------------*/
0 commit comments