esp_freertos_hooks.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2015-2016 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. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __ESP_FREERTOS_HOOKS_H__
  14. #define __ESP_FREERTOS_HOOKS_H__
  15. #include <stdbool.h>
  16. #include "esp_err.h"
  17. #ifdef __cplusplus
  18. extern "C"
  19. {
  20. #endif
  21. /*
  22. Definitions for the tickhook and idlehook callbacks
  23. */
  24. typedef bool (*esp_freertos_idle_cb_t)();
  25. typedef void (*esp_freertos_tick_cb_t)();
  26. /**
  27. * @brief Register a callback to be called on the freertos idle hook
  28. * The callback should return true if it's okay for the core to
  29. * sleep until an interrupt (or FreeRTOS tick) happens and false
  30. * if it should be called again as fast as possible.
  31. *
  32. * @warning Idle callbacks MUST NOT, UNDER ANY CIRCUMSTANCES, CALL
  33. * A FUNCTION THAT MIGHT BLOCK.
  34. *
  35. * @param esp_freertos_idle_cb_t new_idle_cb : Callback to be called
  36. *
  37. * @return ESP_OK : Callback registered
  38. * @return ESP_ERR_NO_MEM : No more space to register hook
  39. */
  40. esp_err_t esp_register_freertos_idle_hook(esp_freertos_idle_cb_t new_idle_cb);
  41. /**
  42. * @brief Register a callback to be called on the freertos tick hook
  43. *
  44. * @param esp_freertos_tick_cb_t new_tick_cb : Callback to be called
  45. *
  46. * @return ESP_OK : Callback registered
  47. * @return ESP_ERR_NO_MEM : No more space to register hook
  48. */
  49. esp_err_t esp_register_freertos_tick_hook(esp_freertos_tick_cb_t tick_cb);
  50. /**
  51. * @brief Unregister an idle callback registered earlier
  52. *
  53. * @param esp_freertos_idle_cb_t new_idle_cb : Callback to be unregistered
  54. *
  55. * @return void
  56. */
  57. void esp_deregister_freertos_idle_hook(esp_freertos_idle_cb_t old_idle_cb);
  58. /**
  59. * @brief Unregister a tick callback registered earlier
  60. *
  61. * @param esp_freertos_idle_cb_t new_idle_cb : Callback to be unregistered
  62. *
  63. * @return void
  64. */
  65. void esp_deregister_freertos_tick_hook(esp_freertos_tick_cb_t old_tick_cb);
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69. #endif