-
-
Save perimeno/2e257bf4001569b6a35b8ba84aa64618 to your computer and use it in GitHub Desktop.
FreeRTOS get stack size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* task.h | |
* <PRE>UBaseType_t uxTaskGetStackSize( TaskHandle_t xTask );</PRE> | |
* | |
* INCLUDE_pxTaskGetStackSize must be set to 1 in FreeRTOSConfig.h for | |
* this function to be available. | |
* | |
* Returns the stack size associated with xTask in bytes. | |
* | |
* @param xTask Handle of the task associated with the stack to be checked. | |
* Set xTask to NULL to check the stack of the calling task. | |
* | |
* @return The stack size (in words) associated with xTask. | |
*/ | |
UBaseType_t uxTaskGetStackSize( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if ( INCLUDE_pxTaskGetStackSize == 1 ) | |
UBaseType_t uxTaskGetStackSize( TaskHandle_t xTask ) | |
{ | |
TCB_t *pxTCB; | |
UBaseType_t uxReturn; | |
pxTCB = prvGetTCBFromHandle( xTask ); | |
#if( portSTACK_GROWTH < 0 ) | |
{ | |
uxReturn = pxTCB->pxEndOfStack - pxTCB->pxStack + sizeof(UBaseType_t); | |
} | |
#else /* portSTACK_GROWTH */ | |
{ | |
uxReturn = pxTCB->pxStack - pxTCB->pxEndOfStack + sizeof(UBaseType_t); | |
} | |
#endif /* portSTACK_GROWTH */ | |
uxReturn/=sizeof(StackType_t); | |
return uxReturn; | |
} | |
#endif /* INCLUDE_pxTaskGetStackSize */ | |
/*-----------------------------------------------------------*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment