ff_time.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * FreeRTOS+FAT V2.3.3
  3. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. * this software and associated documentation files (the "Software"), to deal in
  7. * the Software without restriction, including without limitation the rights to
  8. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. * the Software, and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  18. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * https://www.FreeRTOS.org
  23. * https://github.com/FreeRTOS
  24. *
  25. */
  26. /**
  27. * @file ff_time.h
  28. * @ingroup TIME
  29. *
  30. * Provides a means for receiving the time on any platform.
  31. **/
  32. #ifndef _FF_TIME_H_
  33. #define _FF_TIME_H_
  34. #include <time.h>
  35. #include "FreeRTOSFATConfig.h"
  36. /* _HT_
  37. * The following declarations and functions may be moved to a common directory?
  38. */
  39. typedef struct xTIME_STRUCT
  40. {
  41. int tm_sec; /* Seconds */
  42. int tm_min; /* Minutes */
  43. int tm_hour; /* Hour (0--23) */
  44. int tm_mday; /* Day of month (1--31) */
  45. int tm_mon; /* Month (0--11) */
  46. int tm_year; /* Year (calendar year minus 1900) */
  47. int tm_wday; /* Weekday (0--6; Sunday = 0) */
  48. int tm_yday; /* Day of year (0--365) */
  49. int tm_isdst; /* 0 if daylight savings time is not in effect) */
  50. } FF_TimeStruct_t;
  51. /* Equivalent of time() : returns the number of seconds after 1-1-1970. */
  52. time_t FreeRTOS_time( time_t * pxTime );
  53. /* Equivalent of mktime() : calculates the number of seconds after 1-1-1970. */
  54. time_t FreeRTOS_mktime( const FF_TimeStruct_t * pxTimeBuf );
  55. /* Equivalent of gmtime_r() : Fills a 'struct tm'. */
  56. FF_TimeStruct_t * FreeRTOS_gmtime_r( const time_t * pxTime,
  57. FF_TimeStruct_t * pxTimeBuf );
  58. /**
  59. * @public
  60. * @brief A TIME and DATE object for FreeRTOS+FAT. A FreeRTOS+FAT time driver must populate these values.
  61. *
  62. **/
  63. typedef struct
  64. {
  65. uint16_t Year; /* Year (e.g. 2009). */
  66. uint16_t Month; /* Month (e.g. 1 = Jan, 12 = Dec). */
  67. uint16_t Day; /* Day (1 - 31). */
  68. uint16_t Hour; /* Hour (0 - 23). */
  69. uint16_t Minute; /* Min (0 - 59). */
  70. uint16_t Second; /* Second (0 - 59). */
  71. } FF_SystemTime_t;
  72. /*---------- PROTOTYPES */
  73. int32_t FF_GetSystemTime( FF_SystemTime_t * pxTime );
  74. #endif /* ifndef _FF_TIME_H_ */