diff options
Diffstat (limited to 'lib/chibios/os/hal/templates/hal_rtc_lld.c')
-rw-r--r-- | lib/chibios/os/hal/templates/hal_rtc_lld.c | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/templates/hal_rtc_lld.c b/lib/chibios/os/hal/templates/hal_rtc_lld.c new file mode 100644 index 000000000..434942789 --- /dev/null +++ b/lib/chibios/os/hal/templates/hal_rtc_lld.c | |||
@@ -0,0 +1,153 @@ | |||
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.c | ||
23 | * @brief PLATFORM RTC subsystem low level driver source. | ||
24 | * | ||
25 | * @addtogroup RTC | ||
26 | * @{ | ||
27 | */ | ||
28 | |||
29 | #include "hal.h" | ||
30 | |||
31 | #if (HAL_USE_RTC == TRUE) || defined(__DOXYGEN__) | ||
32 | |||
33 | /*===========================================================================*/ | ||
34 | /* Driver local definitions. */ | ||
35 | /*===========================================================================*/ | ||
36 | |||
37 | /*===========================================================================*/ | ||
38 | /* Driver exported variables. */ | ||
39 | /*===========================================================================*/ | ||
40 | |||
41 | /** | ||
42 | * @brief RTC driver identifier. | ||
43 | */ | ||
44 | #if (PLATFORM_RTC_USE_RTC1 == TRUE) && !defined(__DOXYGEN__) | ||
45 | RTCDriver RTCD1; | ||
46 | #endif | ||
47 | |||
48 | /*===========================================================================*/ | ||
49 | /* Driver local variables and types. */ | ||
50 | /*===========================================================================*/ | ||
51 | |||
52 | /*===========================================================================*/ | ||
53 | /* Driver local functions. */ | ||
54 | /*===========================================================================*/ | ||
55 | |||
56 | /*===========================================================================*/ | ||
57 | /* Driver interrupt handlers. */ | ||
58 | /*===========================================================================*/ | ||
59 | |||
60 | /*===========================================================================*/ | ||
61 | /* Driver exported functions. */ | ||
62 | /*===========================================================================*/ | ||
63 | |||
64 | /** | ||
65 | * @brief Enable access to registers. | ||
66 | * | ||
67 | * @notapi | ||
68 | */ | ||
69 | void rtc_lld_init(void) { | ||
70 | |||
71 | /* RTC object initialization.*/ | ||
72 | #if PLATFORM_RTC_USE_RTC1 == TRUE | ||
73 | rtcObjectInit(&RTCD1); | ||
74 | #endif | ||
75 | } | ||
76 | |||
77 | /** | ||
78 | * @brief Set current time. | ||
79 | * @note Fractional part will be silently ignored. There is no possibility | ||
80 | * to set it on PLATFORM platform. | ||
81 | * @note The function can be called from any context. | ||
82 | * | ||
83 | * @param[in] rtcp pointer to RTC driver structure | ||
84 | * @param[in] timespec pointer to a @p RTCDateTime structure | ||
85 | * | ||
86 | * @notapi | ||
87 | */ | ||
88 | void rtc_lld_set_time(RTCDriver *rtcp, const RTCDateTime *timespec) { | ||
89 | |||
90 | (void)rtcp; | ||
91 | (void)timespec; | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * @brief Get current time. | ||
96 | * @note The function can be called from any context. | ||
97 | * | ||
98 | * @param[in] rtcp pointer to RTC driver structure | ||
99 | * @param[out] timespec pointer to a @p RTCDateTime structure | ||
100 | * | ||
101 | * @notapi | ||
102 | */ | ||
103 | void rtc_lld_get_time(RTCDriver *rtcp, RTCDateTime *timespec) { | ||
104 | |||
105 | (void)rtcp; | ||
106 | (void)timespec; | ||
107 | } | ||
108 | |||
109 | #if (RTC_ALARMS > 0) || defined(__DOXYGEN__) | ||
110 | /** | ||
111 | * @brief Set alarm time. | ||
112 | * @note Default value after BKP domain reset for both comparators is 0. | ||
113 | * @note Function does not performs any checks of alarm time validity. | ||
114 | * @note The function can be called from any context. | ||
115 | * | ||
116 | * @param[in] rtcp pointer to RTC driver structure. | ||
117 | * @param[in] alarm alarm identifier. Can be 1 or 2. | ||
118 | * @param[in] alarmspec pointer to a @p RTCAlarm structure. | ||
119 | * | ||
120 | * @notapi | ||
121 | */ | ||
122 | void rtc_lld_set_alarm(RTCDriver *rtcp, | ||
123 | rtcalarm_t alarm, | ||
124 | const RTCAlarm *alarmspec) { | ||
125 | |||
126 | (void)rtcp; | ||
127 | (void)alarm; | ||
128 | (void)alarmspec; | ||
129 | } | ||
130 | |||
131 | /** | ||
132 | * @brief Get alarm time. | ||
133 | * @note The function can be called from any context. | ||
134 | * | ||
135 | * @param[in] rtcp pointer to RTC driver structure | ||
136 | * @param[in] alarm alarm identifier | ||
137 | * @param[out] alarmspec pointer to a @p RTCAlarm structure | ||
138 | * | ||
139 | * @notapi | ||
140 | */ | ||
141 | void rtc_lld_get_alarm(RTCDriver *rtcp, | ||
142 | rtcalarm_t alarm, | ||
143 | RTCAlarm *alarmspec) { | ||
144 | |||
145 | (void)rtcp; | ||
146 | (void)alarm; | ||
147 | (void)alarmspec; | ||
148 | } | ||
149 | #endif /* RTC_ALARMS > 0 */ | ||
150 | |||
151 | #endif /* HAL_USE_RTC */ | ||
152 | |||
153 | /** @} */ | ||