mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-21 19:09:13 +00:00
esp_common/shared_stack: modifed the stack switch procedure to a simpler way
esp_common/shared_stack: refactored the implemenation of shared stack function (still not working properly) esp_expression_with_stack: refactored the shared stack function calling mechanism and updated the documentation
This commit is contained in:
@@ -8,25 +8,32 @@
|
||||
#include "test_utils.h"
|
||||
#include "esp_expression_with_stack.h"
|
||||
|
||||
//makes sure this is not the task stack...
|
||||
void external_stack_function(void)
|
||||
{
|
||||
printf("Executing this printf from external stack! sp=%p\n", get_sp());
|
||||
}
|
||||
|
||||
void another_external_stack_function(void)
|
||||
{
|
||||
//We can even use Freertos resources inside of this context.
|
||||
printf("We can even use FreeRTOS resources delaying..., sp=%p\n", get_sp());
|
||||
vTaskDelay(100);
|
||||
printf("Executing this another printf inside a function with external stack");
|
||||
printf("Done!, sp=%p\n", get_sp());
|
||||
}
|
||||
|
||||
TEST_CASE("test printf using shared buffer stack", "[newlib]")
|
||||
{
|
||||
portSTACK_TYPE *shared_stack = malloc(8192 * sizeof(portSTACK_TYPE));
|
||||
portSTACK_TYPE *shared_stack = malloc(8192);
|
||||
|
||||
TEST_ASSERT(shared_stack != NULL);
|
||||
|
||||
SemaphoreHandle_t printf_lock = xSemaphoreCreateMutex();
|
||||
TEST_ASSERT_NOT_NULL(printf_lock);
|
||||
printf("SP: %p\n", get_sp());
|
||||
printf("shared_stack: %p\n", (void *)shared_stack);
|
||||
|
||||
ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,printf("Executing this printf from external stack! \n"));
|
||||
ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,another_external_stack_function());
|
||||
esp_execute_shared_stack_function(printf_lock, shared_stack,8192,external_stack_function);
|
||||
esp_execute_shared_stack_function(printf_lock, shared_stack,8192,another_external_stack_function);
|
||||
vSemaphoreDelete(printf_lock);
|
||||
free(shared_stack);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user