2024-01-17 01:16:06 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-01-06 15:28:37 -05:00
|
|
|
#pragma once
|
2019-11-15 03:07:57 -05:00
|
|
|
|
2020-03-12 01:59:53 -04:00
|
|
|
#include <stdbool.h>
|
2019-11-15 03:07:57 -05:00
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/semphr.h"
|
2020-02-10 10:03:24 -05:00
|
|
|
#include "freertos/task.h"
|
2019-11-26 14:31:56 -05:00
|
|
|
#include "esp_debug_helpers.h"
|
2020-01-06 15:28:37 -05:00
|
|
|
#include "esp_log.h"
|
2019-11-26 14:31:56 -05:00
|
|
|
|
2020-01-06 15:28:37 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2019-11-15 03:07:57 -05:00
|
|
|
|
2020-11-10 02:40:01 -05:00
|
|
|
typedef void (*shared_stack_function)(void);
|
2020-03-12 01:59:53 -04:00
|
|
|
|
|
|
|
#define ESP_EXECUTE_EXPRESSION_WITH_STACK(lock, stack, stack_size, expression) \
|
|
|
|
esp_execute_shared_stack_function(lock, stack, stack_size, expression)
|
|
|
|
|
2019-11-15 03:07:57 -05:00
|
|
|
/**
|
2023-12-12 21:40:29 -05:00
|
|
|
* @brief Calls function on user defined shared stack space
|
|
|
|
*
|
|
|
|
* After returning, the original stack is used again.
|
|
|
|
*
|
|
|
|
* @warning This function does minimal preparation of the provided piece of memory (\c stack).
|
|
|
|
* DO NOT do any of the following in \c function or any of its callees:
|
|
|
|
* * Use Thread-local storage
|
|
|
|
* * Use the Floating-point unit on ESP32-P4
|
|
|
|
* * Use the AI co-processor on ESP32-P4
|
|
|
|
* * Call vTaskDelete(NULL) (deleting the currently running task)
|
|
|
|
* Furthermore, backtraces will be wrong when called from \c function or any of its callees.
|
|
|
|
* The limitations are quite sever, so that we might deprecate this function in the future.
|
|
|
|
* If you have any use case which can only be implemented using this function, please open
|
|
|
|
* an issue on github.
|
|
|
|
*
|
2019-11-15 03:07:57 -05:00
|
|
|
* @param lock Mutex object to protect in case of shared stack
|
2023-12-12 21:40:29 -05:00
|
|
|
* @param stack Pointer to user allocated stack
|
2019-11-26 14:31:56 -05:00
|
|
|
* @param stack_size Size of current stack in bytes
|
2020-03-12 01:59:53 -04:00
|
|
|
* @param function pointer to the shared stack function to be executed
|
2020-01-06 15:28:37 -05:00
|
|
|
* @note if either lock, stack or stack size is invalid, the expression will
|
|
|
|
* be called using the current stack.
|
2019-11-15 03:07:57 -05:00
|
|
|
*/
|
2020-11-10 02:40:01 -05:00
|
|
|
void esp_execute_shared_stack_function(SemaphoreHandle_t lock,
|
2020-03-12 01:59:53 -04:00
|
|
|
void *stack,
|
|
|
|
size_t stack_size,
|
|
|
|
shared_stack_function function);
|
2019-11-27 11:52:27 -05:00
|
|
|
|
2019-11-15 03:07:57 -05:00
|
|
|
|
2020-01-06 15:28:37 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2020-11-10 02:40:01 -05:00
|
|
|
#endif
|