diff options
Diffstat (limited to 'lib/chibios/os/hal/templates/hal_rtc_lld.h')
-rw-r--r-- | lib/chibios/os/hal/templates/hal_rtc_lld.h | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/templates/hal_rtc_lld.h b/lib/chibios/os/hal/templates/hal_rtc_lld.h new file mode 100644 index 000000000..1cd22de50 --- /dev/null +++ b/lib/chibios/os/hal/templates/hal_rtc_lld.h | |||
@@ -0,0 +1,149 @@ | |||
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 | /** | ||
43 | * @brief Callback support int the driver. | ||
44 | */ | ||
45 | #define RTC_SUPPORTS_CALLBACKS TRUE | ||
46 | |||
47 | /** | ||
48 | * @brief Number of alarms available. | ||
49 | */ | ||
50 | #define RTC_ALARMS 2 | ||
51 | |||
52 | /** | ||
53 | * @brief Presence of a local persistent storage. | ||
54 | */ | ||
55 | #define RTC_HAS_STORAGE FALSE | ||
56 | /** @} */ | ||
57 | |||
58 | /*===========================================================================*/ | ||
59 | /* Driver pre-compile time settings. */ | ||
60 | /*===========================================================================*/ | ||
61 | |||
62 | /** | ||
63 | * @name PLATFORM configuration options | ||
64 | * @{ | ||
65 | */ | ||
66 | /** | ||
67 | * @brief RTCD1 driver enable switch. | ||
68 | * @details If set to @p TRUE the support for RTC1 is included. | ||
69 | * @note The default is @p FALSE. | ||
70 | */ | ||
71 | #if !defined(PLATFORM_RTC_USE_RTC1) || defined(__DOXYGEN__) | ||
72 | #define PLATFORM_RTC_USE_RTC1 FALSE | ||
73 | #endif | ||
74 | /** @} */ | ||
75 | |||
76 | /*===========================================================================*/ | ||
77 | /* Derived constants and error checks. */ | ||
78 | /*===========================================================================*/ | ||
79 | |||
80 | /*===========================================================================*/ | ||
81 | /* Driver data structures and types. */ | ||
82 | /*===========================================================================*/ | ||
83 | |||
84 | #if (RTC_SUPPORTS_CALLBACKS == TRUE) || defined(__DOXYGEN__) | ||
85 | /** | ||
86 | * @brief Type of an RTC event. | ||
87 | */ | ||
88 | typedef enum { | ||
89 | RTC_EVENT_SECOND = 0 /** Triggered every second. */ | ||
90 | } rtcevent_t; | ||
91 | |||
92 | /** | ||
93 | * @brief Type of a generic RTC callback. | ||
94 | */ | ||
95 | typedef void (*rtccb_t)(RTCDriver *rtcp, rtcevent_t event); | ||
96 | #endif | ||
97 | |||
98 | /** | ||
99 | * @brief Type of a structure representing an RTC alarm time stamp. | ||
100 | */ | ||
101 | typedef struct { | ||
102 | /* End of the mandatory fields.*/ | ||
103 | uint32_t dummy; | ||
104 | } RTCAlarm; | ||
105 | |||
106 | /** | ||
107 | * @brief Implementation-specific @p RTCDriver fields. | ||
108 | */ | ||
109 | #define rtc_lld_driver_fields \ | ||
110 | uint32_t dummy | ||
111 | |||
112 | /*===========================================================================*/ | ||
113 | /* Driver macros. */ | ||
114 | /*===========================================================================*/ | ||
115 | |||
116 | /*===========================================================================*/ | ||
117 | /* External declarations. */ | ||
118 | /*===========================================================================*/ | ||
119 | |||
120 | #if (PLATFORM_RTC_USE_RTC1 == TRUE) && !defined(__DOXYGEN__) | ||
121 | extern RTCDriver RTCD1; | ||
122 | #endif | ||
123 | |||
124 | #ifdef __cplusplus | ||
125 | extern "C" { | ||
126 | #endif | ||
127 | void rtc_lld_init(void); | ||
128 | void rtc_lld_set_time(RTCDriver *rtcp, const RTCDateTime *timespec); | ||
129 | void rtc_lld_get_time(RTCDriver *rtcp, RTCDateTime *timespec); | ||
130 | #if RTC_ALARMS > 0 | ||
131 | void rtc_lld_set_alarm(RTCDriver *rtcp, | ||
132 | rtcalarm_t alarm, | ||
133 | const RTCAlarm *alarmspec); | ||
134 | void rtc_lld_get_alarm(RTCDriver *rtcp, | ||
135 | rtcalarm_t alarm, | ||
136 | RTCAlarm *alarmspec); | ||
137 | #endif | ||
138 | #if RTC_SUPPORTS_CALLBACKS == TRUE | ||
139 | void rtc_lld_set_callback(RTCDriver *rtcp, rtccb_t callback); | ||
140 | #endif | ||
141 | #ifdef __cplusplus | ||
142 | } | ||
143 | #endif | ||
144 | |||
145 | #endif /* HAL_USE_RTC == TRUE */ | ||
146 | |||
147 | #endif /* HAL_RTC_LLD_H */ | ||
148 | |||
149 | /** @} */ | ||