linux/drivers/staging/csr/csr_time.h
<<
>>
Prefs
   1#ifndef CSR_TIME_H__
   2#define CSR_TIME_H__
   3/*****************************************************************************
   4
   5            (c) Cambridge Silicon Radio Limited 2010
   6            All rights reserved and confidential information of CSR
   7
   8            Refer to LICENSE.txt included with this source for details
   9            on the license terms.
  10
  11*****************************************************************************/
  12
  13#include <linux/types.h>
  14
  15#ifdef __cplusplus
  16extern "C" {
  17#endif
  18
  19/*******************************************************************************
  20
  21    NAME
  22        CsrTime
  23
  24    DESCRIPTION
  25        Type to hold a value describing the current system time, which is a
  26        measure of time elapsed since some arbitrarily defined fixed time
  27        reference, usually associated with system startup.
  28
  29*******************************************************************************/
  30typedef u32 CsrTime;
  31
  32
  33/*******************************************************************************
  34
  35    NAME
  36        CsrTimeUtc
  37
  38    DESCRIPTION
  39        Type to hold a value describing a UTC wallclock time expressed in
  40        seconds and milliseconds elapsed since midnight January 1st 1970.
  41
  42*******************************************************************************/
  43typedef struct
  44{
  45    u32 sec;
  46    u16 msec;
  47} CsrTimeUtc;
  48
  49
  50/*******************************************************************************
  51
  52    NAME
  53        CsrTimeGet
  54
  55    DESCRIPTION
  56        Returns the current system time in a low and a high part. The low part
  57        is expressed in microseconds. The high part is incremented when the low
  58        part wraps to provide an extended range.
  59
  60        The caller may provide a NULL pointer as the high parameter. In this case
  61        the function just returns the low part and ignores the high parameter.
  62
  63        Although the time is expressed in microseconds the actual resolution is
  64        platform dependent and can be less. It is recommended that the
  65        resolution is at least 10 milliseconds.
  66
  67    PARAMETERS
  68        high - Pointer to variable that will receive the high part of the
  69               current system time. Passing NULL is valid.
  70
  71    RETURNS
  72        Low part of current system time in microseconds.
  73
  74*******************************************************************************/
  75CsrTime CsrTimeGet(CsrTime *high);
  76
  77
  78/*------------------------------------------------------------------*/
  79/* CsrTime Macros */
  80/*------------------------------------------------------------------*/
  81
  82/*----------------------------------------------------------------------------*
  83 *  NAME
  84 *      CsrTimeAdd
  85 *
  86 *  DESCRIPTION
  87 *      Add two time values. Adding the numbers can overflow the range of a
  88 *      CsrTime, so the user must be cautious.
  89 *
  90 *  RETURNS
  91 *      CsrTime - the sum of "t1" and "t2".
  92 *
  93 *----------------------------------------------------------------------------*/
  94#define CsrTimeAdd(t1, t2) ((t1) + (t2))
  95
  96/*----------------------------------------------------------------------------*
  97 *  NAME
  98 *      CsrTimeSub
  99 *
 100 *  DESCRIPTION
 101 *      Subtract two time values. Subtracting the numbers can provoke an
 102 *      underflow, so the user must be cautious.
 103 *
 104 *  RETURNS
 105 *      CsrTime - "t1" - "t2".
 106 *
 107 *----------------------------------------------------------------------------*/
 108#define CsrTimeSub(t1, t2)    ((s32) (t1) - (s32) (t2))
 109
 110#ifdef __cplusplus
 111}
 112#endif
 113
 114#endif
 115