2019-11-15 04:14:48 -05:00
|
|
|
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
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-03-12 01:59:53 -04:00
|
|
|
typedef void (*shared_stack_function)(void);
|
|
|
|
|
|
|
|
#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-03-12 01:59:53 -04:00
|
|
|
void esp_execute_shared_stack_function(SemaphoreHandle_t lock,
|
|
|
|
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
|
|
|
|
}
|
2019-11-15 03:07:57 -05:00
|
|
|
#endif
|