summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/shared
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-07-30 21:27:51 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-07-30 21:27:51 +0000
commit509dc7c18d61e3994e47d87f4d4011aff0766559 (patch)
tree025ebadef26d5df9cdf69bb480462d0a5c23ff31 /c/src/lib/libbsp/shared
parentChanged clock rate from 32 Khz to 1 Mhz. (diff)
downloadrtems-509dc7c18d61e3994e47d87f4d4011aff0766559.tar.bz2
Added getRealTime() and setRealTime().
Reimplemented checkRealTime() to use RTEMS internal routine.
Diffstat (limited to 'c/src/lib/libbsp/shared')
-rw-r--r--c/src/lib/libbsp/shared/tod.c78
-rw-r--r--c/src/lib/libbsp/shared/tod.h39
2 files changed, 99 insertions, 18 deletions
diff --git a/c/src/lib/libbsp/shared/tod.c b/c/src/lib/libbsp/shared/tod.c
index c414e9e47b..b43c7c1c04 100644
--- a/c/src/lib/libbsp/shared/tod.c
+++ b/c/src/lib/libbsp/shared/tod.c
@@ -150,6 +150,62 @@ void setRealTimeFromRTEMS()
/*PAGE
*
+ * getRealTime
+ *
+ * This routine reads the current time from the RTC.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values: NONE
+ */
+
+void getRealTime(
+ rtems_time_of_day *tod
+)
+{
+
+ if (!RTC_Present)
+ return;
+
+ RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, tod);
+}
+
+/*PAGE
+ *
+ * setRealTime
+ *
+ * This routine sets the RTC.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * Return values: NONE
+ */
+
+/* XXX this routine should be part of the public RTEMS interface */
+rtems_boolean _TOD_Validate( rtems_time_of_day *tod );
+
+int setRealTime(
+ rtems_time_of_day *tod
+)
+{
+
+ if (!RTC_Present)
+ return -1;
+
+ if ( !_TOD_Validate(tod) )
+ return -1;
+
+ RTC_Table[RTC_Minor].pDeviceFns->deviceSetTime(RTC_Minor, tod);
+ return 0;
+}
+
+
+/*PAGE
+ *
* checkRealTime
*
* This routine reads the returns the variance betweent the real time and
@@ -160,28 +216,28 @@ void setRealTimeFromRTEMS()
* Output parameters: NONE
*
* Return values:
- * int The differance between the real time clock and rtems time or
- * 9999 in the event of an error.
+ * int The differance between the real time clock and rtems time.
*/
+/* XXX this routine should be part of the public RTEMS interface */
+unsigned32 _TOD_To_seconds( rtems_time_of_day *tod );
+
int checkRealTime()
{
rtems_time_of_day rtems_tod;
rtems_time_of_day rtc_tod;
+ unsigned32 rtems_time;
+ unsigned32 rtc_time;
if (!RTC_Present)
- return 0;
+ return -1;
rtems_clock_get( RTEMS_CLOCK_GET_TOD, &rtems_tod );
RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, &rtc_tod);
- if( rtems_tod.year == rtc_tod.year &&
- rtems_tod.month == rtc_tod.month &&
- rtems_tod.day == rtc_tod.day ) {
- return ((rtems_tod.hour - rtc_tod.hour) * 3600) +
- ((rtems_tod.minute - rtc_tod.minute) * 60) +
- (rtems_tod.second - rtc_tod.second);
- }
- return 9999;
+ rtems_time = _TOD_To_seconds( &rtems_tod );
+ rtc_time = _TOD_To_seconds( &rtc_tod );
+
+ return rtems_time - rtc_time;
}
diff --git a/c/src/lib/libbsp/shared/tod.h b/c/src/lib/libbsp/shared/tod.h
index d51ceb23b9..725211e082 100644
--- a/c/src/lib/libbsp/shared/tod.h
+++ b/c/src/lib/libbsp/shared/tod.h
@@ -21,15 +21,40 @@
extern "C" {
#endif
-extern void setRealTimeToRTEMS();
-/* Read real time from RTC and set it to RTEMS' clock manager */
+/*
+ * Set the RTC.
+ */
+
+int setRealTime(
+ rtems_time_of_day *tod
+);
-extern void setRealTimeFromRTEMS();
-/* Read time from RTEMS' clock manager and set it to RTC */
+/*
+ * Get the time from the RTC.
+ */
+
+void getRealTime(
+ rtems_time_of_day *tod
+);
+
+/*
+ * Read real time from RTC and set it to RTEMS' clock manager
+ */
+
+void setRealTimeToRTEMS();
+
+/*
+ * Read time from RTEMS' clock manager and set it to RTC
+ */
+
+void setRealTimeFromRTEMS();
+
+/*
+ * Return the difference between RTC and RTEMS' clock manager time in minutes.
+ * If the difference is greater than 1 day, this returns 9999.
+ */
-extern int checkRealTime();
-/* Return the difference between RTC and RTEMS' clock manager time in minutes.
- If the difference is greater than 1 day, this returns 9999. */
+int checkRealTime();
#ifdef __cplusplus
}