1 // Copyright 2017 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 
15 #pragma once
16 
17 /**
18  * @file esp_private/esp_timer_private.h
19  *
20  * @brief Interface between common and platform-specific parts of esp_timer.
21  *
22  * The functions in this header file are implemented for each supported SoC.
23  * High level functions defined in esp_timer.c call the functions here to
24  * interact with the hardware.
25  *
26  * Note: The functions from this file are marked as private and are used exclusively
27  * inside the IDF in the power management and sleep files.
28  */
29 
30 #include <stdint.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /**
37  * @brief Notify esp_timer implementation that APB frequency has changed
38  *
39  * Called by the frequency switching code.
40  *
41  * @param apb_ticks_per_us new number of APB clock ticks per microsecond
42  */
43 void esp_timer_private_update_apb_freq(uint32_t apb_ticks_per_us);
44 
45 /**
46  * @brief Adjust current esp_timer time by a certain value
47  *
48  * Called from light sleep code to synchronize esp_timer time with RTC time.
49  *
50  * @param time_us  adjustment to apply to esp_timer time, in microseconds
51  */
52 void esp_timer_private_advance(int64_t time_us);
53 
54 /**
55  * @brief obtain internal critical section used esp_timer implementation
56  * This can be used when a sequence of calls to esp_timer has to be made,
57  * and it is necessary that the state of the timer is consistent between
58  * the calls. Should be treated in the same way as a spinlock.
59  * Call esp_timer_unlock to release the lock
60  */
61 void esp_timer_private_lock(void);
62 
63 /**
64  * @brief counterpart of esp_timer_lock
65  */
66 void esp_timer_private_unlock(void);
67 
68 #ifdef __cplusplus
69 }
70 #endif
71