ccomp_timer.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 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 <stdint.h>
  16. #include "esp_err.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /**
  21. * @brief Start the timer on the current core.
  22. *
  23. * @return
  24. * - ESP_OK: Success
  25. * - ESP_ERR_INVALID_STATE: The timer has already been started previously.
  26. * - Others: Fail
  27. */
  28. esp_err_t ccomp_timer_start(void);
  29. /**
  30. * @brief Stop the timer on the current core.
  31. *
  32. * @note Returns -1 if an error has occured and stopping the timer failed.
  33. *
  34. * @return The time elapsed from the last ccomp_timer_start call on the current
  35. * core.
  36. */
  37. int64_t ccomp_timer_stop(void);
  38. /**
  39. * Return the current timer value on the current core without stopping the timer.
  40. *
  41. * @note Returns -1 if an error has occured and stopping the timer failed.
  42. *
  43. * @note If called while timer is active i.e. between ccomp_timer_start and ccomp_timer_stop,
  44. * this function returns the elapsed time from ccomp_timer_start. Once ccomp_timer_stop
  45. * has been called, the timer becomes inactive and stops keeping time. As a result, if this function gets
  46. * called after esp_cccomp_timer_stop, this function will return the same value as when the timer was stopped.
  47. *
  48. * @return The elapsed time from the last ccomp_timer_start call on the current
  49. * core.
  50. */
  51. int64_t ccomp_timer_get_time(void);
  52. #ifdef __cplusplus
  53. }
  54. #endif