diff --git a/components/freertos/FreeRTOS-Kernel-SMP/portable/riscv/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel-SMP/portable/riscv/include/freertos/portmacro.h index 2e252bb421..7ffcb5e6d4 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/portable/riscv/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel-SMP/portable/riscv/include/freertos/portmacro.h @@ -239,11 +239,11 @@ extern void vTaskExitCritical( void ); // ------------------- Run Time Stats ---------------------- #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() -#define portGET_RUN_TIME_COUNTER_VALUE() 0 #ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER -/* Coarse resolution time (us) */ -#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do {x = (uint32_t)esp_timer_get_time();} while(0) -#endif +#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time()) +#else +#define portGET_RUN_TIME_COUNTER_VALUE() 0 +#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER // --------------------- TCB Cleanup ----------------------- diff --git a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/portmacro.h index 4ac4ffdb55..2e87cd39f9 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/portmacro.h @@ -227,11 +227,11 @@ extern void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus ); //Timers are already configured, so nothing to do for configuration of run time stats timer #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() -//We define get run time counter value regardless because the rest of ESP-IDF uses it -#define portGET_RUN_TIME_COUNTER_VALUE() xthal_get_ccount() #ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER -#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) ({x = (uint32_t)esp_timer_get_time();}) -#endif +#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time()) +#else // Uses CCOUNT +#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) xthal_get_ccount()) +#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER // --------------------- TCB Cleanup ----------------------- diff --git a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h index 099a6ef29d..5df719405c 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h @@ -594,11 +594,11 @@ void vPortTCBPreDeleteHook( void *pxTCB ); // ------------------- Run Time Stats ---------------------- #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() -#define portGET_RUN_TIME_COUNTER_VALUE() 0 #ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER -/* Coarse resolution time (us) */ -#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do {x = (uint32_t)esp_timer_get_time();} while(0) -#endif +#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time()) +#else +#define portGET_RUN_TIME_COUNTER_VALUE() 0 +#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER // --------------------- TCB Cleanup ----------------------- diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h index 91085eb1a9..109bea6d28 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h @@ -8,7 +8,7 @@ * * SPDX-License-Identifier: MIT * - * SPDX-FileContributor: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2023-2024 Espressif Systems (Shanghai) CO LTD * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -513,15 +513,11 @@ extern void _frxt_setup_switch( void ); //Defined in portasm.S #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() -/** - * - Fine resolution uses ccount - * - ALT is coarse and uses esp_timer - * @note [refactor-todo] Make fine and alt timers mutually exclusive - */ -#define portGET_RUN_TIME_COUNTER_VALUE() xthal_get_ccount() #ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER -#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do {x = (uint32_t)esp_timer_get_time();} while(0) -#endif +#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time()) +#else // Uses CCOUNT +#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) xthal_get_ccount()) +#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER // --------------------- TCB Cleanup ----------------------- diff --git a/components/freertos/esp_additions/freertos_tasks_c_additions.h b/components/freertos/esp_additions/freertos_tasks_c_additions.h index 9fcf05dee5..ec2236b87a 100644 --- a/components/freertos/esp_additions/freertos_tasks_c_additions.h +++ b/components/freertos/esp_additions/freertos_tasks_c_additions.h @@ -408,7 +408,7 @@ BaseType_t xTaskGetCoreID( TaskHandle_t xTask ) #if CONFIG_FREERTOS_SMP UBaseType_t uxCoreAffinityMask; - /* Get the core affinity mask and covert it to an ID */ + /* Get the core affinity mask and convert it to an ID */ uxCoreAffinityMask = vTaskCoreAffinityGet( xTask ); /* If the task is not pinned to a particular core, treat it as tskNO_AFFINITY */ @@ -487,7 +487,7 @@ BaseType_t xTaskGetCoreID( TaskHandle_t xTask ) configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounterForCore( BaseType_t xCoreID ) { - uint32_t ulRunTimeCounter; + configRUN_TIME_COUNTER_TYPE ulRunTimeCounter; configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE ); @@ -514,7 +514,11 @@ BaseType_t xTaskGetCoreID( TaskHandle_t xTask ) configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE ); - ulTotalTime = portGET_RUN_TIME_COUNTER_VALUE(); + #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE + portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalTime ); + #else + ulTotalTime = portGET_RUN_TIME_COUNTER_VALUE(); + #endif /* For percentage calculations. */ ulTotalTime /= ( configRUN_TIME_COUNTER_TYPE ) 100; @@ -836,11 +840,11 @@ uint8_t * pxTaskGetStackStart( TaskHandle_t xTask ) /** * @brief Get reentrancy structure of the current task * - * - This funciton is required by newlib (when __DYNAMIC_REENT__ is enabled) + * - This function is required by newlib (when __DYNAMIC_REENT__ is enabled) * - It will return a pointer to the current task's reent struct * - If FreeRTOS is not running, it will return the global reent struct * - * @return Pointer to a the (current taks's)/(globa) reent struct + * @return Pointer to a the (current taks's)/(global) reent struct */ struct _reent * __getreent( void ) { @@ -1000,7 +1004,7 @@ int xTaskGetNext( TaskIterator_t * xIterator ) if( !portVALID_LIST_MEM( pxNextListItem ) ) { /* Nothing to do with the corrupted list item. We will skip to the next task state list. - * pxNextListItem should be NULL at the beggining of each task list. + * pxNextListItem should be NULL at the beginning of each task list. */ pxNextListItem = NULL; continue;