Embedded TCP/IP stack: fnet_timer.h Source File

FNET

fnet_timer.h
1 /**************************************************************************
2 *
3 * Copyright 2011-2015 by Andrey Butok. FNET Community.
4 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 ***************************************************************************
21 *
22 * FNET Timer API.
23 *
24 ***************************************************************************/
25 
26 #ifndef _FNET_TIMER_H
27 
28 #define _FNET_TIMER_H
29 
38 /**************************************************************************/
41 #define FNET_TIMER_PERIOD_MS (10U) /* It may be 1-100ms */
42 
43 /**************************************************************************/
46 #define FNET_TIMER_TICKS_IN_HOUR ((1000U*60U*60U)/FNET_TIMER_PERIOD_MS)
47 
48 /**************************************************************************/
51 #define FNET_TIMER_TICKS_IN_MIN ((1000U*60U)/FNET_TIMER_PERIOD_MS)
52 
53 /**************************************************************************/
56 #define FNET_TIMER_TICKS_IN_SEC (1000U/FNET_TIMER_PERIOD_MS)
57 
58 #if defined(__cplusplus)
59 extern "C" {
60 #endif
61 
62 /**************************************************************************/
66 typedef fnet_uint32_t fnet_time_t;
67 
68 /***************************************************************************/
84 fnet_time_t fnet_timer_get_ticks( void );
85 
86 /***************************************************************************/
102 fnet_time_t fnet_timer_get_seconds( void );
103 
104 /***************************************************************************/
120 fnet_time_t fnet_timer_get_ms( void );
121 
122 /***************************************************************************/
137 fnet_time_t fnet_timer_ms2ticks( fnet_time_t time_ms );
138 
139 /***************************************************************************/
157 fnet_time_t fnet_timer_get_interval( fnet_time_t start, fnet_time_t end );
158 
159 /***************************************************************************/
171 void fnet_timer_delay( fnet_time_t delay_ticks );
172 
173 /***************************************************************************/
189 void fnet_timer_poll(void);
190 
193 #ifndef FNET_HW_TIMER_INIT
194 #define FNET_HW_TIMER_INIT fnet_cpu_timer_init
195 #endif
196 #ifndef FNET_HW_TIMER_RELEASE
197 #define FNET_HW_TIMER_RELEASE fnet_cpu_timer_release
198 #endif
199 
200 #if defined(__cplusplus)
201 }
202 #endif
203 
204 #endif /* _FNET_TIMER_H */
fnet_time_t fnet_timer_get_ticks(void)
Gets the timer counter value in ticks.
fnet_uint32_t fnet_time_t
Unsigned integer type representing time uinits. It can be ticks, seconds or milliseconds.
Definition: fnet_timer.h:66
fnet_time_t fnet_timer_get_ms(void)
Gets the timer counter value in milliseconds.
fnet_time_t fnet_timer_get_seconds(void)
Gets the timer counter value in seconds.
fnet_time_t fnet_timer_get_interval(fnet_time_t start, fnet_time_t end)
Calculates an interval between two moments in time.
void fnet_timer_delay(fnet_time_t delay_ticks)
Performs a delay for the given number of timer ticks.
fnet_time_t fnet_timer_ms2ticks(fnet_time_t time_ms)
Converts milliseconds to timer ticks.
void fnet_timer_poll(void)
SW Timer polling function.

© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net