esp_ieee802154_timer.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "soc/soc.h"
  7. #include "hal/ieee802154_ll.h"
  8. #include "esp_check.h"
  9. #include "esp_ieee802154_timer.h"
  10. static const char *TAG = "ieee802154_timer";
  11. void ieee802154_timer0_start(void)
  12. {
  13. ieee802154_ll_set_cmd(IEEE802154_CMD_TIMER0_START);
  14. }
  15. void ieee802154_timer0_stop(void)
  16. {
  17. ieee802154_ll_set_cmd(IEEE802154_CMD_TIMER0_STOP);
  18. }
  19. esp_err_t ieee802154_timer0_set_threshold(uint32_t value)
  20. {
  21. ESP_RETURN_ON_FALSE((value < IEEE802154_TIMER0_THRESHOLD), ESP_ERR_INVALID_ARG, TAG, "invalid timer0 threshold\r\n");
  22. ieee802154_ll_timer0_set_threshold(value);
  23. return ESP_OK;
  24. }
  25. uint32_t ieee802154_timer0_get_value(void)
  26. {
  27. return ieee802154_ll_timer0_get_value();
  28. }
  29. void ieee802154_timer1_start(void)
  30. {
  31. ieee802154_ll_set_cmd(IEEE802154_CMD_TIMER1_START);
  32. }
  33. void ieee802154_timer1_stop(void)
  34. {
  35. ieee802154_ll_set_cmd(IEEE802154_CMD_TIMER1_STOP);
  36. }
  37. esp_err_t ieee802154_timer1_set_threshold(uint32_t value)
  38. {
  39. ESP_RETURN_ON_FALSE((value < IEEE802154_TIMER1_THRESHOLD), ESP_ERR_INVALID_ARG, TAG, "invalid timer1 threshold\r\n");
  40. ieee802154_ll_timer1_set_threshold(value);
  41. return ESP_OK;
  42. }
  43. uint32_t ieee802154_timer1_get_value(void)
  44. {
  45. return ieee802154_ll_timer1_get_value();
  46. }