OSAL_Clock.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /******************************************************************************
  2. Filename: OSAL_Clock.h
  3. Revised: $Date: 2011-02-02 14:21:10 -0800 (Wed, 02 Feb 2011) $
  4. Revision: $Revision: 24962 $
  5. Description: OSAL Clock definition and manipulation functions.
  6. Copyright 2008-2011 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. ******************************************************************************/
  33. #ifndef OSAL_CLOCK_H
  34. #define OSAL_CLOCK_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /*********************************************************************
  40. * INCLUDES
  41. */
  42. /*********************************************************************
  43. * MACROS
  44. */
  45. #define IsLeapYear(yr) (!((yr) % 400) || (((yr) % 100) && !((yr) % 4)))
  46. /*********************************************************************
  47. * CONSTANTS
  48. */
  49. /*********************************************************************
  50. * TYPEDEFS
  51. */
  52. // number of seconds since 0 hrs, 0 minutes, 0 seconds, on the
  53. // 1st of January 2000 UTC
  54. typedef uint32 UTCTime;
  55. // To be used with
  56. typedef struct
  57. {
  58. uint8 seconds; // 0-59
  59. uint8 minutes; // 0-59
  60. uint8 hour; // 0-23
  61. uint8 day; // 0-30
  62. uint8 month; // 0-11
  63. uint16 year; // 2000+
  64. } UTCTimeStruct;
  65. /*********************************************************************
  66. * GLOBAL VARIABLES
  67. */
  68. /*********************************************************************
  69. * FUNCTIONS
  70. */
  71. /*
  72. * Updates the OSAL clock and Timers from the MAC 320us timer tick.
  73. */
  74. extern void osalTimeUpdate( void );
  75. /*
  76. * Set the new time. This will only set the seconds portion
  77. * of time and doesn't change the factional second counter.
  78. * newTime - number of seconds since 0 hrs, 0 minutes,
  79. * 0 seconds, on the 1st of January 2000 UTC
  80. */
  81. extern void osal_setClock( UTCTime newTime );
  82. /*
  83. * Gets the current time. This will only return the seconds
  84. * portion of time and doesn't include the factional second counter.
  85. * returns: number of seconds since 0 hrs, 0 minutes,
  86. * 0 seconds, on the 1st of January 2000 UTC
  87. */
  88. extern UTCTime osal_getClock( void );
  89. /*
  90. * Converts UTCTime to UTCTimeStruct
  91. *
  92. * secTime - number of seconds since 0 hrs, 0 minutes,
  93. * 0 seconds, on the 1st of January 2000 UTC
  94. * tm - pointer to breakdown struct
  95. */
  96. extern void osal_ConvertUTCTime( UTCTimeStruct *tm, UTCTime secTime );
  97. /*
  98. * Converts UTCTimeStruct to UTCTime (seconds since 00:00:00 01/01/2000)
  99. *
  100. * tm - pointer to UTC time struct
  101. */
  102. extern UTCTime osal_ConvertUTCSecs( UTCTimeStruct *tm );
  103. /*********************************************************************
  104. *********************************************************************/
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif /* OSAL_CLOCK_H */