amiro-blt / Host / Source / SerialBoot / port / linux / timeutil.c @ 69661903
History | View | Annotate | Download (3.36 KB)
1 | 69661903 | Thomas Schöpping | /************************************************************************************//** |
---|---|---|---|
2 | * \file port\linux\timeutil.c
|
||
3 | * \brief Time utility source file.
|
||
4 | * \ingroup SerialBoot
|
||
5 | * \internal
|
||
6 | *----------------------------------------------------------------------------------------
|
||
7 | * C O P Y R I G H T
|
||
8 | *----------------------------------------------------------------------------------------
|
||
9 | * Copyright (c) 2014 by Feaser http://www.feaser.com All rights reserved
|
||
10 | *
|
||
11 | *----------------------------------------------------------------------------------------
|
||
12 | * L I C E N S E
|
||
13 | *----------------------------------------------------------------------------------------
|
||
14 | * This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
||
15 | * modify it under the terms of the GNU General Public License as published by the Free
|
||
16 | * Software Foundation, either version 3 of the License, or (at your option) any later
|
||
17 | * version.
|
||
18 | *
|
||
19 | * OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||
20 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
21 | * PURPOSE. See the GNU General Public License for more details.
|
||
22 | *
|
||
23 | * You should have received a copy of the GNU General Public License along with OpenBLT.
|
||
24 | * If not, see <http://www.gnu.org/licenses/>.
|
||
25 | *
|
||
26 | * A special exception to the GPL is included to allow you to distribute a combined work
|
||
27 | * that includes OpenBLT without being obliged to provide the source code for any
|
||
28 | * proprietary components. The exception text is included at the bottom of the license
|
||
29 | * file <license.html>.
|
||
30 | *
|
||
31 | * \endinternal
|
||
32 | ****************************************************************************************/
|
||
33 | |||
34 | /****************************************************************************************
|
||
35 | * Include files
|
||
36 | ****************************************************************************************/
|
||
37 | #include <assert.h> /* assertion module */ |
||
38 | #include <sb_types.h> /* C types */ |
||
39 | #include <unistd.h> /* UNIX standard functions */ |
||
40 | #include <fcntl.h> /* file control definitions */ |
||
41 | #include <sys/time.h> /* time definitions */ |
||
42 | |||
43 | |||
44 | /************************************************************************************//** |
||
45 | ** \brief Get the system time in milliseconds.
|
||
46 | ** \return Time in milliseconds.
|
||
47 | **
|
||
48 | ****************************************************************************************/
|
||
49 | sb_uint32 TimeUtilGetSystemTimeMs(void)
|
||
50 | { |
||
51 | struct timeval tv;
|
||
52 | |||
53 | if (gettimeofday(&tv, SB_NULL) != 0) |
||
54 | { |
||
55 | return 0; |
||
56 | } |
||
57 | |||
58 | return (sb_uint32)((tv.tv_sec * 1000ul) + (tv.tv_usec / 1000ul)); |
||
59 | } /*** end of XcpTransportClose ***/
|
||
60 | |||
61 | |||
62 | /************************************************************************************//** |
||
63 | ** \brief Performs a delay of the specified amount of milliseconds.
|
||
64 | ** \param delay Delay time in milliseconds.
|
||
65 | ** \return none.
|
||
66 | **
|
||
67 | ****************************************************************************************/
|
||
68 | void TimeUtilDelayMs(sb_uint16 delay)
|
||
69 | { |
||
70 | usleep(1000 * delay);
|
||
71 | } /*** end of TimeUtilDelayMs **/
|
||
72 | |||
73 | |||
74 | /*********************************** end of xcptransport.c *****************************/ |