systimer_hal.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2020 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. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include <stdint.h>
  19. #include "hal/systimer_types.h"
  20. /**
  21. * @brief enable systimer counter
  22. */
  23. void systimer_hal_enable_counter(systimer_counter_id_t counter_id);
  24. /**
  25. * @brief get current counter value
  26. */
  27. uint64_t systimer_hal_get_counter_value(systimer_counter_id_t counter_id);
  28. /**
  29. * @brief get current time (in microseconds)
  30. */
  31. uint64_t systimer_hal_get_time(systimer_counter_id_t counter_id);
  32. /**
  33. * @brief set alarm time
  34. */
  35. void systimer_hal_set_alarm_value(systimer_alarm_id_t alarm_id, uint64_t timestamp);
  36. /**
  37. * @brief get alarm time
  38. */
  39. uint64_t systimer_hal_get_alarm_value(systimer_alarm_id_t alarm_id);
  40. /**
  41. * @brief enable alarm interrupt
  42. */
  43. void systimer_hal_enable_alarm_int(systimer_alarm_id_t alarm_id);
  44. /**
  45. * @brief select alarm mode
  46. */
  47. void systimer_hal_select_alarm_mode(systimer_alarm_id_t alarm_id, systimer_alarm_mode_t mode);
  48. /**
  49. * @brief update systimer step when apb clock gets changed
  50. */
  51. void systimer_hal_on_apb_freq_update(uint32_t apb_ticks_per_us);
  52. /**
  53. * @brief move systimer counter value forward or backward
  54. */
  55. void systimer_hal_counter_value_advance(systimer_counter_id_t counter_id, int64_t time_us);
  56. /**
  57. * @brief initialize systimer in HAL layer
  58. */
  59. void systimer_hal_init(void);
  60. #ifdef __cplusplus
  61. }
  62. #endif