Embedded TCP/IP stack  4.7.0
fnet_timer.h
1 /**************************************************************************
2 *
3 * Copyright 2008-2018 by Andrey Butok. FNET Community
4 *
5 ***************************************************************************
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ***************************************************************************
20 *
21 * FNET Timer API.
22 *
23 ***************************************************************************/
24 
25 #ifndef _FNET_TIMER_H
26 
27 #define _FNET_TIMER_H
28 
36 /**************************************************************************/
39 #define FNET_TIMER_PERIOD_MS (10U) /* It may be 1-100ms */
40 
41 /**************************************************************************/
44 #define FNET_TIMER_MS_IN_SEC (1000U)
45 
46 /**************************************************************************/
49 #define FNET_TIMER_MS_IN_MIN (FNET_TIMER_MS_IN_SEC*60U)
50 
51 /**************************************************************************/
54 #define FNET_TIMER_MS_IN_HOUR (FNET_TIMER_MS_IN_MIN*60U)
55 
56 #if defined(__cplusplus)
57 extern "C" {
58 #endif
59 
60 /**************************************************************************/
64 typedef fnet_uint32_t fnet_time_t;
65 
66 /***************************************************************************/
81 
82 /***************************************************************************/
94 void fnet_timer_delay( fnet_time_t delay_ms );
95 
96 /***************************************************************************/
112 void fnet_timer_poll(void);
113 
114 #if FNET_CFG_TIME || defined(__DOXYGEN__)
115 #include <time.h>
116 
117 #define fnet_time time /* Compliance with <time.h> */
118 
119 /***************************************************************************/
134 void fnet_time_set(time_t sec);
135 
136 /***************************************************************************/
153 time_t fnet_time(time_t *sec);
154 
155 #endif /* FNET_CFG_TIME */
156 
159 #if !FNET_CFG_TIMER_ALT /* Use bare-metal timer */
160 
161 #ifndef FNET_HW_TIMER_INIT
162 #define FNET_HW_TIMER_INIT fnet_cpu_timer_init
163 #endif
164 #ifndef FNET_HW_TIMER_RELEASE
165 #define FNET_HW_TIMER_RELEASE fnet_cpu_timer_release
166 #endif
167 
168 #endif /* !FNET_CFG_TIMER_ALT */
169 
170 #if defined(__cplusplus)
171 }
172 #endif
173 
174 #endif /* _FNET_TIMER_H */
fnet_uint32_t fnet_time_t
Unsigned integer type representing time uinits. It can be seconds or milliseconds.
Definition: fnet_timer.h:64
void fnet_timer_delay(fnet_time_t delay_ms)
Perform a delay for the given number of milliseconds.
void fnet_time_set(time_t sec)
Set time since the Epoch (00:00:00 UTC, January 1, 1970).
fnet_time_t fnet_timer_get_ms(void)
Get the timer counter value in milliseconds.
void fnet_timer_poll(void)
Poll SW timers.
time_t fnet_time(time_t *sec)
Get time since the Epoch (00:00:00 UTC, January 1, 1970).

© 2005-2020 by Andrej Butok. http://fnet.sourceforge.net