1
0

rtc_ut.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * @brief RTC tick to (a more) Universal Time
  3. * Adds conversion functions to use an RTC that only provides a
  4. * seconds capability to provide "struct tm" support.
  5. *
  6. * @note
  7. * Copyright(C) NXP Semiconductors, 2014
  8. * All rights reserved.
  9. *
  10. * @par
  11. * Software that is described herein is for illustrative purposes only
  12. * which provides customers with programming information regarding the
  13. * LPC products. This software is supplied "AS IS" without any warranties of
  14. * any kind, and NXP Semiconductors and its licenser disclaim any and
  15. * all warranties, express or implied, including all implied warranties of
  16. * merchantability, fitness for a particular purpose and non-infringement of
  17. * intellectual property rights. NXP Semiconductors assumes no responsibility
  18. * or liability for the use of the software, conveys no license or rights under any
  19. * patent, copyright, mask work right, or any other intellectual property rights in
  20. * or to any products. NXP Semiconductors reserves the right to make changes
  21. * in the software without notification. NXP Semiconductors also makes no
  22. * representation or warranty that such application will be suitable for the
  23. * specified use without further testing or modification.
  24. *
  25. * @par
  26. * Permission to use, copy, modify, and distribute this software and its
  27. * documentation is hereby granted, under NXP Semiconductors' and its
  28. * licensor's relevant copyrights in the software, without fee, provided that it
  29. * is used in conjunction with NXP Semiconductors microcontrollers. This
  30. * copyright, permission, and disclaimer notice must appear in all copies of
  31. * this code.
  32. */
  33. #ifndef __RTC_UT_H_
  34. #define __RTC_UT_H_
  35. #include "chip.h"
  36. #include <stdlib.h>
  37. #include <sys/time.h>
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /** @defgroup RTC_UT CHIP: RTC tick to (a more) Universal Time conversion functions
  42. * @ingroup CHIP_Common
  43. * This driver converts between a RTC 1-second tick value and
  44. * a Universal time format in a structure of type 'struct tm'.
  45. * @{
  46. */
  47. /* Starting year and starting day of week for the driver */
  48. #define TM_YEAR_BASE (1900)
  49. #define TM_DAYOFWEEK (1)
  50. /**
  51. * @brief Converts a RTC tick time to Universal time
  52. * @param rtcTick : Current RTC time value
  53. * @param pTime : Pointer to time structure to fill
  54. * @return Nothing
  55. * @note When setting time, the 'tm_wday', 'tm_yday', and 'tm_isdst'
  56. * fields are not used.
  57. */
  58. void ConvertRtcTime(uint32_t rtcTick, struct tm *pTime);
  59. /**
  60. * @brief Converts a Universal time to RTC tick time
  61. * @param pTime : Pointer to time structure to use
  62. * @param rtcTick : Pointer to RTC time value to fill
  63. * @return Nothing
  64. * @note When converting time, the 'tm_isdst' field is not
  65. * populated by the conversion function.
  66. */
  67. void ConvertTimeRtc(struct tm *pTime, uint32_t *rtcTick);
  68. /**
  69. * @}
  70. */
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif /* __RTC_UT_H_ */