esp_expression_with_stack.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <stdbool.h>
  16. #include "freertos/FreeRTOS.h"
  17. #include "freertos/semphr.h"
  18. #include "freertos/task.h"
  19. #include "esp_debug_helpers.h"
  20. #include "esp_log.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. typedef void (*shared_stack_function)(void);
  25. #define ESP_EXECUTE_EXPRESSION_WITH_STACK(lock, stack, stack_size, expression) \
  26. esp_execute_shared_stack_function(lock, stack, stack_size, expression)
  27. /**
  28. * @brief Calls user defined shared stack space function
  29. * @param lock Mutex object to protect in case of shared stack
  30. * @param stack Pointer to user alocated stack
  31. * @param stack_size Size of current stack in bytes
  32. * @param function pointer to the shared stack function to be executed
  33. * @note if either lock, stack or stack size is invalid, the expression will
  34. * be called using the current stack.
  35. */
  36. void esp_execute_shared_stack_function(SemaphoreHandle_t lock,
  37. void *stack,
  38. size_t stack_size,
  39. shared_stack_function function);
  40. #ifdef __cplusplus
  41. }
  42. #endif