hal_rtc_lld.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /*
  14. Concepts and parts of this file have been contributed by Uladzimir Pylinsky
  15. aka barthess.
  16. */
  17. /**
  18. * @file hal_rtc_lld.h
  19. * @brief PLATFORM RTC subsystem low level driver header.
  20. *
  21. * @addtogroup RTC
  22. * @{
  23. */
  24. #ifndef HAL_RTC_LLD_H
  25. #define HAL_RTC_LLD_H
  26. #if (HAL_USE_RTC == TRUE) || defined(__DOXYGEN__)
  27. /*===========================================================================*/
  28. /* Driver constants. */
  29. /*===========================================================================*/
  30. /**
  31. * @name Implementation capabilities
  32. */
  33. /**
  34. * @brief Callback support int the driver.
  35. */
  36. #define RTC_SUPPORTS_CALLBACKS TRUE
  37. /**
  38. * @brief Number of alarms available.
  39. */
  40. #define RTC_ALARMS 2
  41. /**
  42. * @brief Presence of a local persistent storage.
  43. */
  44. #define RTC_HAS_STORAGE FALSE
  45. /** @} */
  46. /*===========================================================================*/
  47. /* Driver pre-compile time settings. */
  48. /*===========================================================================*/
  49. /**
  50. * @name PLATFORM configuration options
  51. * @{
  52. */
  53. /**
  54. * @brief RTCD1 driver enable switch.
  55. * @details If set to @p TRUE the support for RTC1 is included.
  56. * @note The default is @p FALSE.
  57. */
  58. #if !defined(PLATFORM_RTC_USE_RTC1) || defined(__DOXYGEN__)
  59. #define PLATFORM_RTC_USE_RTC1 FALSE
  60. #endif
  61. /** @} */
  62. /*===========================================================================*/
  63. /* Derived constants and error checks. */
  64. /*===========================================================================*/
  65. /*===========================================================================*/
  66. /* Driver data structures and types. */
  67. /*===========================================================================*/
  68. #if (RTC_SUPPORTS_CALLBACKS == TRUE) || defined(__DOXYGEN__)
  69. /**
  70. * @brief Type of an RTC event.
  71. */
  72. typedef enum {
  73. RTC_EVENT_SECOND = 0 /** Triggered every second. */
  74. } rtcevent_t;
  75. /**
  76. * @brief Type of a generic RTC callback.
  77. */
  78. typedef void (*rtccb_t)(RTCDriver *rtcp, rtcevent_t event);
  79. #endif
  80. /**
  81. * @brief Type of a structure representing an RTC alarm time stamp.
  82. */
  83. typedef struct {
  84. /* End of the mandatory fields.*/
  85. uint32_t dummy;
  86. } RTCAlarm;
  87. /**
  88. * @brief Implementation-specific @p RTCDriver fields.
  89. */
  90. #define rtc_lld_driver_fields \
  91. uint32_t dummy
  92. /*===========================================================================*/
  93. /* Driver macros. */
  94. /*===========================================================================*/
  95. /*===========================================================================*/
  96. /* External declarations. */
  97. /*===========================================================================*/
  98. #if (PLATFORM_RTC_USE_RTC1 == TRUE) && !defined(__DOXYGEN__)
  99. extern RTCDriver RTCD1;
  100. #endif
  101. #ifdef __cplusplus
  102. extern "C" {
  103. #endif
  104. void rtc_lld_init(void);
  105. void rtc_lld_set_time(RTCDriver *rtcp, const RTCDateTime *timespec);
  106. void rtc_lld_get_time(RTCDriver *rtcp, RTCDateTime *timespec);
  107. #if RTC_ALARMS > 0
  108. void rtc_lld_set_alarm(RTCDriver *rtcp,
  109. rtcalarm_t alarm,
  110. const RTCAlarm *alarmspec);
  111. void rtc_lld_get_alarm(RTCDriver *rtcp,
  112. rtcalarm_t alarm,
  113. RTCAlarm *alarmspec);
  114. #endif
  115. #if RTC_SUPPORTS_CALLBACKS == TRUE
  116. void rtc_lld_set_callback(RTCDriver *rtcp, rtccb_t callback);
  117. #endif
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #endif /* HAL_USE_RTC == TRUE */
  122. #endif /* HAL_RTC_LLD_H */
  123. /** @} */