timer_hal.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /*******************************************************************************
  7. * NOTICE
  8. * The hal is not public api, don't use in application code.
  9. * See readme.md in hal/include/hal/readme.md
  10. ******************************************************************************/
  11. #pragma once
  12. #include <stdint.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. typedef struct timg_dev_t *gptimer_soc_handle_t; // GPTimer SOC layer handle
  17. /**
  18. * Context that should be maintained by both the driver and the HAL
  19. */
  20. typedef struct {
  21. gptimer_soc_handle_t dev; // Timer SOC layer handle (i.e. register base address)
  22. uint32_t timer_id; // Timer ID (i.e. index of the timer in the group)
  23. } timer_hal_context_t;
  24. /**
  25. * @brief Init the timer hal. This function should be called first before other hal layer function is called
  26. *
  27. * @param hal Context of the HAL layer
  28. * @param group_num The timer group number
  29. * @param timer_num The timer number
  30. */
  31. void timer_hal_init(timer_hal_context_t *hal, uint32_t group_num, uint32_t timer_num);
  32. /**
  33. * @brief Load counter value into time-base counter
  34. *
  35. * @param hal Context of the HAL layer
  36. * @param load_val Counter value
  37. */
  38. void timer_hal_set_counter_value(timer_hal_context_t *hal, uint64_t load_val);
  39. #ifdef __cplusplus
  40. }
  41. #endif