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