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
|
|
|
/**
|
2020-03-12 01:59:53 -04:00
|
|
|
* @brief Calls user defined shared stack space function
|
2019-11-15 03:07:57 -05:00
|
|
|
* @param lock Mutex object to protect in case of shared stack
|
2019-11-26 14:31:56 -05:00
|
|
|
* @param stack Pointer to user alocated stack
|
|
|
|
* @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
|