Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file timing.h |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 3 | * |
Paul Bakker | 37ca75d | 2011-01-06 12:28:03 +0000 | [diff] [blame] | 4 | * \brief Portable interface to the CPU cycle counter |
| 5 | * |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame^] | 6 | * Copyright (C) 2006-2013, Brainspark B.V. |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 7 | * |
| 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
Paul Bakker | 84f12b7 | 2010-07-18 10:13:04 +0000 | [diff] [blame] | 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 10 | * |
Paul Bakker | 77b385e | 2009-07-28 17:23:11 +0000 | [diff] [blame] | 11 | * All rights reserved. |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 12 | * |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License along |
| 24 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 26 | */ |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 27 | #ifndef POLARSSL_TIMING_H |
| 28 | #define POLARSSL_TIMING_H |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 29 | |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame^] | 30 | #ifdef __cplusplus |
| 31 | extern "C" { |
| 32 | #endif |
| 33 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 34 | /** |
| 35 | * \brief timer structure |
| 36 | */ |
| 37 | struct hr_time |
| 38 | { |
| 39 | unsigned char opaque[32]; |
| 40 | }; |
| 41 | |
Paul Bakker | 2eee902 | 2011-04-24 15:28:55 +0000 | [diff] [blame] | 42 | extern volatile int alarmed; |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * \brief Return the CPU cycle counter value |
| 46 | */ |
| 47 | unsigned long hardclock( void ); |
| 48 | |
| 49 | /** |
| 50 | * \brief Return the elapsed time in milliseconds |
| 51 | * |
| 52 | * \param val points to a timer structure |
| 53 | * \param reset if set to 1, the timer is restarted |
| 54 | */ |
| 55 | unsigned long get_timer( struct hr_time *val, int reset ); |
| 56 | |
| 57 | /** |
| 58 | * \brief Setup an alarm clock |
| 59 | * |
| 60 | * \param seconds delay before the "alarmed" flag is set |
| 61 | */ |
| 62 | void set_alarm( int seconds ); |
| 63 | |
| 64 | /** |
| 65 | * \brief Sleep for a certain amount of time |
Paul Bakker | 13e2dfe | 2009-07-28 07:18:38 +0000 | [diff] [blame] | 66 | * |
Paul Bakker | 37ca75d | 2011-01-06 12:28:03 +0000 | [diff] [blame] | 67 | * \param milliseconds delay in milliseconds |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 68 | */ |
| 69 | void m_sleep( int milliseconds ); |
| 70 | |
| 71 | #ifdef __cplusplus |
| 72 | } |
| 73 | #endif |
| 74 | |
| 75 | #endif /* timing.h */ |