mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
shared_stack: added minimal stack size for shared stack, configurable via menuconfig
This commit is contained in:
parent
c309112b8a
commit
57edda15a0
@ -77,6 +77,13 @@ menu "Common ESP-related"
|
|||||||
FreeRTOS timer task size, see "FreeRTOS timer task stack size" option
|
FreeRTOS timer task size, see "FreeRTOS timer task stack size" option
|
||||||
in "FreeRTOS" menu.
|
in "FreeRTOS" menu.
|
||||||
|
|
||||||
|
config ESP_MINIMAL_SHARED_STACK_SIZE
|
||||||
|
int "Minimal allowed size for shared stack"
|
||||||
|
default 2048
|
||||||
|
help
|
||||||
|
Minimal value of size, in bytes, accepted to execute a expression
|
||||||
|
with shared stack.
|
||||||
|
|
||||||
choice ESP_CONSOLE_UART
|
choice ESP_CONSOLE_UART
|
||||||
prompt "UART for console output"
|
prompt "UART for console output"
|
||||||
default ESP_CONSOLE_UART_DEFAULT
|
default ESP_CONSOLE_UART_DEFAULT
|
||||||
|
@ -11,14 +11,16 @@
|
|||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
#pragma once
|
||||||
#ifndef __ESP_EXPRESSION_WITH_STACK_H
|
|
||||||
#define __ESP_EXPRESSION_WITH_STACK_H
|
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "esp_debug_helpers.h"
|
#include "esp_debug_helpers.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Executes a 1-line expression with a application alocated stack
|
* @brief Executes a 1-line expression with a application alocated stack
|
||||||
@ -26,20 +28,21 @@
|
|||||||
* @param stack Pointer to user alocated stack
|
* @param stack Pointer to user alocated stack
|
||||||
* @param stack_size Size of current stack in bytes
|
* @param stack_size Size of current stack in bytes
|
||||||
* @param expression Expression or function to be executed using the stack
|
* @param expression Expression or function to be executed using the stack
|
||||||
|
* @note if either lock, stack or stack size is invalid, the expression will
|
||||||
|
* be called using the current stack.
|
||||||
*/
|
*/
|
||||||
#define ESP_EXECUTE_EXPRESSION_WITH_STACK(lock, stack, stack_size, expression) \
|
#define ESP_EXECUTE_EXPRESSION_WITH_STACK(lock, stack, stack_size, expression) \
|
||||||
({ \
|
({ \
|
||||||
if (lock && stack && stack_size) { \
|
assert(lock && stack && (stack_size >= CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE)); \
|
||||||
uint32_t backup; \
|
uint32_t backup; \
|
||||||
xSemaphoreTake(lock, portMAX_DELAY); \
|
xSemaphoreTake(lock, portMAX_DELAY); \
|
||||||
StackType_t *top_of_stack = esp_switch_stack_setup(stack, stack_size);\
|
StackType_t *top_of_stack = esp_switch_stack_setup(stack, stack_size); \
|
||||||
esp_switch_stack_enter(top_of_stack, &backup); \
|
esp_switch_stack_enter(top_of_stack, &backup); \
|
||||||
{ \
|
{ \
|
||||||
expression; \
|
expression; \
|
||||||
} \
|
} \
|
||||||
esp_switch_stack_exit(&backup); \
|
esp_switch_stack_exit(&backup); \
|
||||||
xSemaphoreGive(lock); \
|
xSemaphoreGive(lock); \
|
||||||
} \
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,4 +69,6 @@ extern void esp_switch_stack_enter(StackType_t *stack, uint32_t *backup_stack);
|
|||||||
*/
|
*/
|
||||||
extern void esp_switch_stack_exit(uint32_t *backup_stack);
|
extern void esp_switch_stack_exit(uint32_t *backup_stack);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
#endif
|
#endif
|
@ -1,4 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
@ -29,3 +30,4 @@ TEST_CASE("test printf using shared buffer stack", "[newlib]")
|
|||||||
vSemaphoreDelete(printf_lock);
|
vSemaphoreDelete(printf_lock);
|
||||||
free(shared_stack);
|
free(shared_stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user