aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-01-14 08:45:34 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-01-14 08:45:34 +0000
commitd29e6e338ec4da796225af4dbc9ab001406a14a8 (patch)
treeeab6dd0eca5397faaee1c674b0a468cffbbac869 /os
parenta2672b8dbb01e460ed1a000143bd22add48fc2b7 (diff)
downloadChibiOS-d29e6e338ec4da796225af4dbc9ab001406a14a8.tar.gz
ChibiOS-d29e6e338ec4da796225af4dbc9ab001406a14a8.tar.bz2
ChibiOS-d29e6e338ec4da796225af4dbc9ab001406a14a8.zip
Added I-Class APIs to the RTC driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3807 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/include/rtc.h62
-rw-r--r--os/hal/src/rtc.c20
2 files changed, 77 insertions, 5 deletions
diff --git a/os/hal/include/rtc.h b/os/hal/include/rtc.h
index 7b4e46f1f..774d45851 100644
--- a/os/hal/include/rtc.h
+++ b/os/hal/include/rtc.h
@@ -79,6 +79,68 @@ typedef struct RTCTime RTCTime;
/* Driver macros. */
/*===========================================================================*/
+/**
+ * @brief Set current time.
+ *
+ * @param[in] rtcp pointer to RTC driver structure
+ * @param[in] timespec pointer to a @p RTCTime structure
+ *
+ * @iclass
+ */
+#define rtcSetTimeI(rtcp, timespec) rtc_lld_set_time(rtcp, timespec)
+
+/**
+ * @brief Get current time.
+ *
+ * @param[in] rtcp pointer to RTC driver structure
+ * @param[out] timespec pointer to a @p RTCTime structure
+ *
+ * @iclass
+ */
+#define rtcGetTimeI(rtcp, timespec) rtc_lld_get_time(rtcp, timespec)
+
+#if (RTC_ALARMS > 0) || defined(__DOXYGEN__)
+/**
+ * @brief Set alarm time.
+ *
+ * @param[in] rtcp pointer to RTC driver structure
+ * @param[in] alarm alarm identifier
+ * @param[in] alarmspec pointer to a @p RTCAlarm structure or @p NULL
+ *
+ * @iclass
+ */
+#define rtcSetAlarmI(rtcp, alarm, alarmspec) \
+ rtc_lld_set_alarm(rtcp, alarm, alarmspec)
+
+/**
+ * @brief Get current alarm.
+ * @note If an alarm has not been set then the returned alarm specification
+ * is not meaningful.
+ *
+ * @param[in] rtcp pointer to RTC driver structure
+ * @param[in] alarm alarm identifier
+ * @param[out] alarmspec pointer to a @p RTCAlarm structure
+ *
+ * @iclass
+ */
+#define rtcGetAlarmI(rtcp, alarm, alarmspec) \
+ rtc_lld_get_alarm(rtcp, alarm, alarmspec)
+#endif /* RTC_ALARMS > 0 */
+
+#if RTC_SUPPORTS_CALLBACKS || defined(__DOXYGEN__)
+/**
+ * @brief Enables or disables RTC callbacks.
+ * @details This function enables or disables the callback, use a @p NULL
+ * pointer in order to disable it.
+ *
+ * @param[in] rtcp pointer to RTC driver structure
+ * @param[in] callback callback function pointer or @p NULL
+ *
+ * @iclass
+ */
+#define rtcSetCallbackI(rtcp, callback) rtc_lld_set_callback(rtcp, callback)
+#endif /* RTC_SUPPORTS_CALLBACKS */
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
diff --git a/os/hal/src/rtc.c b/os/hal/src/rtc.c
index 1f463eb38..6cf254706 100644
--- a/os/hal/src/rtc.c
+++ b/os/hal/src/rtc.c
@@ -79,7 +79,9 @@ void rtcSetTime(RTCDriver *rtcp, const RTCTime *timespec) {
chDbgCheck((rtcp != NULL) && (timespec != NULL), "rtcSetTime");
- rtc_lld_set_time(rtcp, timespec);
+ chSysLock();
+ rtcSetTimeI(rtcp, timespec);
+ chSysUnlock();
}
/**
@@ -94,7 +96,9 @@ void rtcGetTime(RTCDriver *rtcp, RTCTime *timespec) {
chDbgCheck((rtcp != NULL) && (timespec != NULL), "rtcGetTime");
- rtc_lld_get_time(rtcp, timespec);
+ chSysLock();
+ rtcGetTimeI(rtcp, timespec);
+ chSysUnlock();
}
#if (RTC_ALARMS > 0) || defined(__DOXYGEN__)
@@ -113,7 +117,9 @@ void rtcSetAlarm(RTCDriver *rtcp,
chDbgCheck((rtcp != NULL) && (alarm < RTC_ALARMS), "rtcSetAlarm");
- rtc_lld_set_alarm(rtcp, alarm, alarmspec);
+ chSysLock();
+ rtcSetAlarmI(rtcp, alarm, alarmspec);
+ chSysUnlock();
}
/**
@@ -134,7 +140,9 @@ void rtcGetAlarm(RTCDriver *rtcp,
chDbgCheck((rtcp != NULL) && (alarm < RTC_ALARMS) && (alarmspec != NULL),
"rtcGetAlarm");
- rtc_lld_get_alarm(rtcp, alarm, alarmspec);
+ chSysLock();
+ rtcGetAlarmI(rtcp, alarm, alarmspec);
+ chSysUnlock();
}
#endif /* RTC_ALARMS > 0 */
@@ -153,7 +161,9 @@ void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback) {
chDbgCheck((rtcp != NULL), "rtcSetCallback");
- rtc_lld_set_callback(rtcp, callback);
+ chSysLock();
+ rtcSetCallbackI(rtcp, callback);
+ chSysUnlock();
}
#endif /* RTC_SUPPORTS_CALLBACKS */