timer.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "esp_err.h"
  8. #include "esp_attr.h"
  9. #include "soc/soc.h"
  10. #include "soc/soc_caps.h"
  11. #include "soc/timer_periph.h"
  12. #include "esp_intr_alloc.h"
  13. #include "hal/timer_types.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /**
  18. * @brief Frequency of the clock on the input of the timer groups
  19. * @note This macro is not correct for Timer Groups with multiple clock sources (e.g. APB, XTAL)
  20. * So please don't use it in your application, we keep it here only for backward compatible
  21. */
  22. #define TIMER_BASE_CLK (APB_CLK_FREQ)
  23. /**
  24. * @brief Selects a Timer-Group out of 2 available groups
  25. */
  26. typedef enum {
  27. TIMER_GROUP_0 = 0, /*!< Hw timer group 0 */
  28. #if SOC_TIMER_GROUPS > 1
  29. TIMER_GROUP_1 = 1, /*!< Hw timer group 1 */
  30. #endif
  31. TIMER_GROUP_MAX /*!< Maximum number of Hw timer groups */
  32. } timer_group_t;
  33. /**
  34. * @brief Select a hardware timer from timer groups
  35. */
  36. typedef enum {
  37. TIMER_0 = 0, /*!<Select timer0 of GROUPx*/
  38. #if SOC_TIMER_GROUP_TIMERS_PER_GROUP > 1
  39. TIMER_1 = 1, /*!<Select timer1 of GROUPx*/
  40. #endif
  41. TIMER_MAX,
  42. } timer_idx_t;
  43. /**
  44. * @brief Interrupt types of the timer.
  45. */
  46. typedef enum {
  47. TIMER_INTR_T0 = 1 << 0, /*!< interrupt of timer 0 */
  48. #if SOC_TIMER_GROUP_TIMERS_PER_GROUP > 1
  49. TIMER_INTR_T1 = 1 << 1, /*!< interrupt of timer 1 */
  50. TIMER_INTR_WDT = 1 << 2, /*!< interrupt of watchdog */
  51. #else
  52. TIMER_INTR_WDT = 1 << 1, /*!< interrupt of watchdog */
  53. #endif
  54. TIMER_INTR_NONE = 0
  55. } timer_intr_t;
  56. FLAG_ATTR(timer_intr_t)
  57. /**
  58. * @brief Decides the direction of counter
  59. */
  60. typedef enum {
  61. TIMER_COUNT_DOWN = GPTIMER_COUNT_DOWN, /*!< Descending Count from cnt.high|cnt.low*/
  62. TIMER_COUNT_UP = GPTIMER_COUNT_UP, /*!< Ascending Count from Zero*/
  63. TIMER_COUNT_MAX /*!< Maximum number of timer count directions */
  64. } timer_count_dir_t;
  65. /**
  66. * @brief Decides whether timer is on or paused
  67. */
  68. typedef enum {
  69. TIMER_PAUSE, /*!<Pause timer counter*/
  70. TIMER_START, /*!<Start timer counter*/
  71. } timer_start_t;
  72. /**
  73. * @brief Decides whether to enable alarm mode
  74. */
  75. typedef enum {
  76. TIMER_ALARM_DIS = 0, /*!< Disable timer alarm*/
  77. TIMER_ALARM_EN = 1, /*!< Enable timer alarm*/
  78. TIMER_ALARM_MAX
  79. } timer_alarm_t;
  80. /**
  81. * @brief Select interrupt type if running in alarm mode.
  82. */
  83. typedef enum {
  84. TIMER_INTR_LEVEL = 0, /*!< Interrupt mode: level mode*/
  85. TIMER_INTR_MAX
  86. } timer_intr_mode_t;
  87. /**
  88. * @brief Select if Alarm needs to be loaded by software or automatically reload by hardware.
  89. */
  90. typedef enum {
  91. TIMER_AUTORELOAD_DIS = 0, /*!< Disable auto-reload: hardware will not load counter value after an alarm event*/
  92. TIMER_AUTORELOAD_EN = 1, /*!< Enable auto-reload: hardware will load counter value after an alarm event*/
  93. TIMER_AUTORELOAD_MAX,
  94. } timer_autoreload_t;
  95. /**
  96. * @brief Select timer source clock.
  97. */
  98. typedef enum {
  99. TIMER_SRC_CLK_APB = GPTIMER_CLK_SRC_APB, /*!< Select APB as the source clock*/
  100. #if SOC_TIMER_GROUP_SUPPORT_XTAL
  101. TIMER_SRC_CLK_XTAL = GPTIMER_CLK_SRC_XTAL, /*!< Select XTAL as the source clock*/
  102. #endif
  103. } timer_src_clk_t;
  104. /**
  105. * @brief Data structure with timer's configuration settings
  106. */
  107. typedef struct {
  108. timer_alarm_t alarm_en; /*!< Timer alarm enable */
  109. timer_start_t counter_en; /*!< Counter enable */
  110. timer_intr_mode_t intr_type; /*!< Interrupt mode */
  111. timer_count_dir_t counter_dir; /*!< Counter direction */
  112. timer_autoreload_t auto_reload; /*!< Timer auto-reload */
  113. timer_src_clk_t clk_src; /*!< Selects source clock. */
  114. uint32_t divider; /*!< Counter clock divider */
  115. } timer_config_t;
  116. /**
  117. * @brief Interrupt handle callback function. User need to retrun a bool value
  118. * in callback.
  119. *
  120. * @return
  121. * - True Do task yield at the end of ISR
  122. * - False Not do task yield at the end of ISR
  123. *
  124. * @note If you called FreeRTOS functions in callback, you need to return true or false based on
  125. * the retrun value of argument `pxHigherPriorityTaskWoken`.
  126. * For example, `xQueueSendFromISR` is called in callback, if the return value `pxHigherPriorityTaskWoken`
  127. * of any FreeRTOS calls is pdTRUE, return true; otherwise return false.
  128. */
  129. typedef bool (*timer_isr_t)(void *);
  130. /**
  131. * @brief Interrupt handle, used in order to free the isr after use.
  132. * Aliases to an int handle for now.
  133. */
  134. typedef intr_handle_t timer_isr_handle_t;
  135. /**
  136. * @brief Read the counter value of hardware timer.
  137. *
  138. * @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
  139. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  140. * @param timer_val Pointer to accept timer counter value.
  141. *
  142. * @return
  143. * - ESP_OK Success
  144. * - ESP_ERR_INVALID_ARG Parameter error
  145. */
  146. esp_err_t timer_get_counter_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t *timer_val);
  147. /**
  148. * @brief Read the counter value of hardware timer, in unit of a given scale.
  149. *
  150. * @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
  151. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  152. * @param time Pointer, type of double*, to accept timer counter value, in seconds.
  153. *
  154. * @return
  155. * - ESP_OK Success
  156. * - ESP_ERR_INVALID_ARG Parameter error
  157. */
  158. esp_err_t timer_get_counter_time_sec(timer_group_t group_num, timer_idx_t timer_num, double *time);
  159. /**
  160. * @brief Set counter value to hardware timer.
  161. *
  162. * @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
  163. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  164. * @param load_val Counter value to write to the hardware timer.
  165. *
  166. * @return
  167. * - ESP_OK Success
  168. * - ESP_ERR_INVALID_ARG Parameter error
  169. */
  170. esp_err_t timer_set_counter_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t load_val);
  171. /**
  172. * @brief Start the counter of hardware timer.
  173. *
  174. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  175. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  176. *
  177. * @return
  178. * - ESP_OK Success
  179. * - ESP_ERR_INVALID_ARG Parameter error
  180. */
  181. esp_err_t timer_start(timer_group_t group_num, timer_idx_t timer_num);
  182. /**
  183. * @brief Pause the counter of hardware timer.
  184. *
  185. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  186. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  187. *
  188. * @return
  189. * - ESP_OK Success
  190. * - ESP_ERR_INVALID_ARG Parameter error
  191. */
  192. esp_err_t timer_pause(timer_group_t group_num, timer_idx_t timer_num);
  193. /**
  194. * @brief Set counting mode for hardware timer.
  195. *
  196. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  197. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  198. * @param counter_dir Counting direction of timer, count-up or count-down
  199. *
  200. * @return
  201. * - ESP_OK Success
  202. * - ESP_ERR_INVALID_ARG Parameter error
  203. */
  204. esp_err_t timer_set_counter_mode(timer_group_t group_num, timer_idx_t timer_num, timer_count_dir_t counter_dir);
  205. /**
  206. * @brief Enable or disable counter reload function when alarm event occurs.
  207. *
  208. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  209. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  210. * @param reload Counter reload mode.
  211. *
  212. * @return
  213. * - ESP_OK Success
  214. * - ESP_ERR_INVALID_ARG Parameter error
  215. */
  216. esp_err_t timer_set_auto_reload(timer_group_t group_num, timer_idx_t timer_num, timer_autoreload_t reload);
  217. /**
  218. * @brief Set hardware divider of the source clock to the timer group.
  219. * By default, the source clock is APB clock running at 80 MHz.
  220. * For more information, please check Chapter Reset and Clock in Chip Technical Reference Manual.
  221. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  222. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  223. * @param divider Timer clock divider value. The divider's range is from from 2 to 65536.
  224. *
  225. * @return
  226. * - ESP_OK Success
  227. * - ESP_ERR_INVALID_ARG Parameter error
  228. */
  229. esp_err_t timer_set_divider(timer_group_t group_num, timer_idx_t timer_num, uint32_t divider);
  230. /**
  231. * @brief Set timer alarm value.
  232. *
  233. * @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
  234. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  235. * @param alarm_value A 64-bit value to set the alarm value.
  236. *
  237. * @return
  238. * - ESP_OK Success
  239. * - ESP_ERR_INVALID_ARG Parameter error
  240. */
  241. esp_err_t timer_set_alarm_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t alarm_value);
  242. /**
  243. * @brief Get timer alarm value.
  244. *
  245. * @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
  246. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  247. * @param alarm_value Pointer of A 64-bit value to accept the alarm value.
  248. *
  249. * @return
  250. * - ESP_OK Success
  251. * - ESP_ERR_INVALID_ARG Parameter error
  252. */
  253. esp_err_t timer_get_alarm_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t *alarm_value);
  254. /**
  255. * @brief Enable or disable generation of timer alarm events.
  256. *
  257. * @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
  258. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  259. * @param alarm_en To enable or disable timer alarm function.
  260. *
  261. * @return
  262. * - ESP_OK Success
  263. * - ESP_ERR_INVALID_ARG Parameter error
  264. */
  265. esp_err_t timer_set_alarm(timer_group_t group_num, timer_idx_t timer_num, timer_alarm_t alarm_en);
  266. /**
  267. * @brief Add ISR handle callback for the corresponding timer.
  268. *
  269. * @param group_num Timer group number
  270. * @param timer_num Timer index of timer group
  271. * @param isr_handler Interrupt handler function, it is a callback function.
  272. * @param arg Parameter for handler function
  273. * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
  274. * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
  275. *
  276. * @note This ISR handler will be called from an ISR.
  277. * This ISR handler do not need to handle interrupt status, and should be kept short.
  278. * If you want to realize some specific applications or write the whole ISR, you can
  279. * call timer_isr_register(...) to register ISR.
  280. *
  281. * The callback should return a bool value to determine whether need to do YIELD at
  282. * the end of the ISR.
  283. *
  284. * If the intr_alloc_flags value ESP_INTR_FLAG_IRAM is set,
  285. * the handler function must be declared with IRAM_ATTR attribute
  286. * and can only call functions in IRAM or ROM. It cannot call other timer APIs.
  287. *
  288. * @return
  289. * - ESP_OK Success
  290. * - ESP_ERR_INVALID_ARG Parameter error
  291. */
  292. esp_err_t timer_isr_callback_add(timer_group_t group_num, timer_idx_t timer_num, timer_isr_t isr_handler, void *arg, int intr_alloc_flags);
  293. /**
  294. * @brief Remove ISR handle callback for the corresponding timer.
  295. *
  296. * @param group_num Timer group number
  297. * @param timer_num Timer index of timer group
  298. *
  299. * @return
  300. * - ESP_OK Success
  301. * - ESP_ERR_INVALID_ARG Parameter error
  302. */
  303. esp_err_t timer_isr_callback_remove(timer_group_t group_num, timer_idx_t timer_num);
  304. /**
  305. * @brief Register Timer interrupt handler, the handler is an ISR.
  306. * The handler will be attached to the same CPU core that this function is running on.
  307. *
  308. * @param group_num Timer group number
  309. * @param timer_num Timer index of timer group
  310. * @param fn Interrupt handler function.
  311. * @param arg Parameter for handler function
  312. * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
  313. * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
  314. * @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will
  315. * be returned here.
  316. *
  317. * @note If use this function to reigster ISR, you need to write the whole ISR.
  318. * In the interrupt handler, you need to call timer_spinlock_take(..) before
  319. * your handling, and call timer_spinlock_give(...) after your handling.
  320. *
  321. * If the intr_alloc_flags value ESP_INTR_FLAG_IRAM is set,
  322. * the handler function must be declared with IRAM_ATTR attribute
  323. * and can only call functions in IRAM or ROM. It cannot call other timer APIs.
  324. * Use direct register access to configure timers from inside the ISR in this case.
  325. *
  326. * @return
  327. * - ESP_OK Success
  328. * - ESP_ERR_INVALID_ARG Parameter error
  329. */
  330. esp_err_t timer_isr_register(timer_group_t group_num, timer_idx_t timer_num, void (*fn)(void *), void *arg, int intr_alloc_flags, timer_isr_handle_t *handle);
  331. /** @brief Initializes and configure the timer.
  332. *
  333. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  334. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  335. * @param config Pointer to timer initialization parameters.
  336. *
  337. * @return
  338. * - ESP_OK Success
  339. * - ESP_ERR_INVALID_ARG Parameter error
  340. */
  341. esp_err_t timer_init(timer_group_t group_num, timer_idx_t timer_num, const timer_config_t *config);
  342. /** @brief Deinitializes the timer.
  343. *
  344. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  345. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  346. *
  347. * @return
  348. * - ESP_OK Success
  349. * - ESP_ERR_INVALID_ARG Parameter error
  350. */
  351. esp_err_t timer_deinit(timer_group_t group_num, timer_idx_t timer_num);
  352. /** @brief Get timer configure value.
  353. *
  354. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  355. * @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
  356. * @param config Pointer of struct to accept timer parameters.
  357. *
  358. * @return
  359. * - ESP_OK Success
  360. * - ESP_ERR_INVALID_ARG Parameter error
  361. */
  362. esp_err_t timer_get_config(timer_group_t group_num, timer_idx_t timer_num, timer_config_t *config);
  363. /** @brief Enable timer group interrupt, by enable mask
  364. *
  365. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  366. * @param intr_mask Timer interrupt enable mask.
  367. * - TIMER_INTR_T0: t0 interrupt
  368. * - TIMER_INTR_T1: t1 interrupt
  369. * - TIMER_INTR_WDT: watchdog interrupt
  370. *
  371. * @return
  372. * - ESP_OK Success
  373. * - ESP_ERR_INVALID_ARG Parameter error
  374. */
  375. esp_err_t timer_group_intr_enable(timer_group_t group_num, timer_intr_t intr_mask);
  376. /** @brief Disable timer group interrupt, by disable mask
  377. *
  378. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  379. * @param intr_mask Timer interrupt disable mask.
  380. * - TIMER_INTR_T0: t0 interrupt
  381. * - TIMER_INTR_T1: t1 interrupt
  382. * - TIMER_INTR_WDT: watchdog interrupt
  383. *
  384. * @return
  385. * - ESP_OK Success
  386. * - ESP_ERR_INVALID_ARG Parameter error
  387. */
  388. esp_err_t timer_group_intr_disable(timer_group_t group_num, timer_intr_t intr_mask);
  389. /** @brief Enable timer interrupt
  390. *
  391. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  392. * @param timer_num Timer index.
  393. *
  394. * @return
  395. * - ESP_OK Success
  396. * - ESP_ERR_INVALID_ARG Parameter error
  397. */
  398. esp_err_t timer_enable_intr(timer_group_t group_num, timer_idx_t timer_num);
  399. /** @brief Disable timer interrupt
  400. *
  401. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  402. * @param timer_num Timer index.
  403. *
  404. * @return
  405. * - ESP_OK Success
  406. * - ESP_ERR_INVALID_ARG Parameter error
  407. */
  408. esp_err_t timer_disable_intr(timer_group_t group_num, timer_idx_t timer_num);
  409. /** @brief Clear timer interrupt status, just used in ISR
  410. *
  411. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  412. * @param timer_num Timer index.
  413. *
  414. */
  415. void timer_group_intr_clr_in_isr(timer_group_t group_num, timer_idx_t timer_num) __attribute__((deprecated));
  416. /** @brief Clear timer interrupt status, just used in ISR
  417. *
  418. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  419. * @param timer_num Timer index.
  420. *
  421. */
  422. void timer_group_clr_intr_status_in_isr(timer_group_t group_num, timer_idx_t timer_num);
  423. /** @brief Enable alarm interrupt, just used in ISR
  424. *
  425. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  426. * @param timer_num Timer index.
  427. *
  428. */
  429. void timer_group_enable_alarm_in_isr(timer_group_t group_num, timer_idx_t timer_num);
  430. /** @brief Get the current counter value, just used in ISR
  431. *
  432. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  433. * @param timer_num Timer index.
  434. *
  435. * @return
  436. * - Counter value
  437. */
  438. uint64_t timer_group_get_counter_value_in_isr(timer_group_t group_num, timer_idx_t timer_num);
  439. /** @brief Set the alarm threshold for the timer, just used in ISR
  440. *
  441. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  442. * @param timer_num Timer index.
  443. * @param alarm_val Alarm threshold.
  444. *
  445. */
  446. void timer_group_set_alarm_value_in_isr(timer_group_t group_num, timer_idx_t timer_num, uint64_t alarm_val);
  447. /** @brief Enable/disable a counter, just used in ISR
  448. *
  449. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  450. * @param timer_num Timer index.
  451. * @param counter_en Enable/disable.
  452. *
  453. */
  454. void timer_group_set_counter_enable_in_isr(timer_group_t group_num, timer_idx_t timer_num, timer_start_t counter_en);
  455. /** @brief Get the masked interrupt status, just used in ISR
  456. *
  457. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  458. *
  459. * @return
  460. * - Interrupt status
  461. */
  462. timer_intr_t timer_group_intr_get_in_isr(timer_group_t group_num) __attribute__((deprecated));
  463. /** @brief Get interrupt status, just used in ISR
  464. *
  465. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  466. *
  467. * @return
  468. * - Interrupt status
  469. */
  470. uint32_t timer_group_get_intr_status_in_isr(timer_group_t group_num);
  471. /** @brief Clear the masked interrupt status, just used in ISR
  472. *
  473. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  474. * @param intr_mask Masked interrupt.
  475. *
  476. */
  477. void timer_group_clr_intr_sta_in_isr(timer_group_t group_num, timer_intr_t intr_mask) __attribute__((deprecated));
  478. /** @brief Get auto reload enable status, just used in ISR
  479. *
  480. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  481. * @param timer_num Timer index
  482. *
  483. * @return
  484. * - True Auto reload enabled
  485. * - False Auto reload disabled
  486. */
  487. bool timer_group_get_auto_reload_in_isr(timer_group_t group_num, timer_idx_t timer_num);
  488. /** @brief Take timer spinlock to enter critical protect
  489. *
  490. * @note Deprecated, the recommended way is to use ISR callbacks instead, see timer_group_example_main
  491. *
  492. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  493. *
  494. * @return
  495. * - ESP_OK Success
  496. * - ESP_ERR_INVALID_ARG Parameter error
  497. */
  498. esp_err_t timer_spinlock_take(timer_group_t group_num) __attribute__ ((deprecated));
  499. /** @brief Give timer spinlock to exit critical protect
  500. *
  501. * @note Deprecated, the recommended way is to use ISR callbacks instead, see timer_group_example_main
  502. *
  503. * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
  504. *
  505. * @return
  506. * - ESP_OK Success
  507. * - ESP_ERR_INVALID_ARG Parameter error
  508. */
  509. esp_err_t timer_spinlock_give(timer_group_t group_num) __attribute__ ((deprecated));
  510. #ifdef __cplusplus
  511. }
  512. #endif