ai_time.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. * Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved.
  3. *
  4. * @file
  5. *
  6. * @brief The header file of al time module
  7. *
  8. */
  9. #ifndef _AI_TIME_H_
  10. #define _AI_TIME_H_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #include "al_basictypes.h"
  15. /**
  16. * @brief Define message type of time component, usted to notify framwork.
  17. */
  18. typedef enum
  19. {
  20. AI_TIME_UPDATE, /**< Received TOT or TDT */
  21. AI_MAX,
  22. } AI_Time_Message_Type_t;
  23. /**
  24. * @brief Call back function prototype for framwork to register.
  25. */
  26. typedef al_int32 (* AI_pfTimeCallback)(AI_Time_Message_Type_t EventType, al_uint32 u32Param);
  27. /**
  28. * @brief Init al time module
  29. *
  30. * @param none
  31. *
  32. * @retval AL_SUCCESS means succss. AL_INITIALIZE_ALREADY means already initialised.
  33. * AL_FAILURE means failed
  34. */
  35. AL_Return_t AI_Time_Init(AI_pfTimeCallback pfTimeCallbks);
  36. /**
  37. * @brief Terminate al time module
  38. *
  39. * @param none
  40. *
  41. * @retval AL_SUCCESS means succss. lised. AL_FAILURE means failed
  42. *
  43. */
  44. AL_Return_t AI_Time_Term(al_void);
  45. /**
  46. * @brief This API is used to store next time offset, and it will be applied when time of change is met
  47. *
  48. * @param usMjd MJD
  49. *
  50. * @param ucHour Hour
  51. *
  52. * @param ucMin Minute
  53. *
  54. * @param ucSec Second
  55. *
  56. * @retval None
  57. */
  58. void AI_Time_UpdateNextTime(al_uint32 usMjd,al_uint8 ucHour, al_uint8 ucMin, al_uint8 ucSec);
  59. /**
  60. * @brief This API is used to set current system time, it's applied right after this API is called
  61. *
  62. * @param usMjd MJD
  63. *
  64. * @param ucHour Hour
  65. *
  66. * @param ucMin Minute
  67. *
  68. * @param ucSec Second
  69. *
  70. * @retval None
  71. */
  72. void AI_Time_UpdateTime(al_uint32 usMjd, al_uint8 ucHour, al_uint8 ucMin, al_uint8 ucSec);
  73. /**
  74. * @brief This API is used to set next time offset value which is used for tot update
  75. *
  76. * @param iTimeOffset time offset applied to
  77. *
  78. * @retval None
  79. */
  80. void AI_Time_SetNextTimeOffset(al_int32 iTimeOffset);
  81. /**
  82. * === Time Related With Time-zone and Daylight Saving etc===
  83. */
  84. /**
  85. * @brief :This API is used to get time sync status which indicates if TDT or TOT is received
  86. *
  87. * @param None
  88. *
  89. * @retval al_true means TOT or TDT is received and al_false otherwise.
  90. */
  91. al_bool AI_Time_GetTimeSync(void);
  92. /**
  93. * @brief This API is used to set time sync status if TDT or TOT is recieved
  94. *
  95. * @param bTimeSync al_true mean set, and al_false mean unset
  96. *
  97. * @retval None
  98. */
  99. void AI_Time_SetTimeSync(al_bool bTimeSync);
  100. /**
  101. * @brief :This API is used to get time sync status which indicates if (TDT or TOT is received/get system time by use set )from boot.
  102. * System time may vary depending on the stream of time, can vary depending on the manual setting.
  103. * @param None
  104. *
  105. * @retval al_true means TOT or TDT first is received and al_false otherwise..
  106. */
  107. al_bool AI_Time_GetTimeFristPowerON(void);
  108. /**
  109. * @brief This API is used to set time sync status if (TDT or TOT is recieved/get system time by use set) from boot.
  110. *System time may vary depending on the stream of time, can vary depending on the manual setting.
  111. * @param bTimeSync al_true mean TOT or TDT first is received from boot , and al_false mean unset
  112. *
  113. * @retval None
  114. */
  115. void AI_Time_SetTimeFristPowerON(al_bool bTimeSync);
  116. /**
  117. * @brief This API is used to get next time in seconds
  118. *
  119. * @param None
  120. *
  121. * @retval Next time second
  122. */
  123. al_uint32 AI_Time_GetNextTimeSec(void);
  124. /**
  125. * @brief This API is used to get nex raw MJD
  126. *
  127. * @param None
  128. *
  129. * @retval next raw MJD
  130. */
  131. al_uint32 AI_Time_GetNextRawMjd(void);
  132. /**
  133. * @brief This API is used to set old time offset
  134. *
  135. * @param iOffset offset defined by time zone
  136. *
  137. * @retval none
  138. */
  139. void AI_Time_SetOldTimeOffset(al_int32 iOffset);
  140. /**
  141. * @brief This API is used to set time sync status if TDT or TOT is recieved
  142. *
  143. * @param bTimeSync al_true mean set, and al_false mean unset
  144. *
  145. * @retval None
  146. */
  147. al_int32 AI_Time_GetOldTimeOffset(void);
  148. /**
  149. * @brief This API is used to record the difference of time changing
  150. * in TOD/TDT callback.
  151. *
  152. * @param iOffset offset get from TOT callback
  153. *
  154. * @retval none
  155. */
  156. al_int32 AI_Time_GetTimeDiff(al_void);
  157. al_void AI_Time_SetTimeDiff(al_int32 diff);
  158. void AI_Time_SetForceUpdateOffset(al_uint8 bForceUpdate);
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162. #endif /* _AI_TIME_H_ */