Changeset 509dc7c1 in rtems


Ignore:
Timestamp:
Jul 30, 1998, 9:27:51 PM (23 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
d9bc023a
Parents:
91af3e4
Message:

Added getRealTime() and setRealTime().

Reimplemented checkRealTime() to use RTEMS internal routine.

Location:
c/src/lib/libbsp/shared
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/shared/tod.c

    r91af3e4 r509dc7c1  
    151151/*PAGE
    152152 *
     153 *  getRealTime
     154 *
     155 *  This routine reads the current time from the RTC.
     156 *
     157 *  Input parameters:  NONE
     158 *
     159 *  Output parameters:  NONE
     160 *
     161 *  Return values: NONE
     162 */
     163
     164void getRealTime(
     165  rtems_time_of_day *tod
     166)
     167{
     168
     169  if (!RTC_Present)
     170    return;
     171
     172  RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, tod);
     173}
     174
     175/*PAGE
     176 *
     177 *  setRealTime
     178 * 
     179 *  This routine sets the RTC.
     180 * 
     181 *  Input parameters:  NONE
     182 *
     183 *  Output parameters:  NONE
     184 *
     185 *  Return values: NONE
     186 */
     187
     188/* XXX this routine should be part of the public RTEMS interface */
     189rtems_boolean _TOD_Validate( rtems_time_of_day *tod );
     190
     191int setRealTime(
     192  rtems_time_of_day *tod
     193)
     194{
     195 
     196  if (!RTC_Present)
     197    return -1;
     198 
     199  if ( !_TOD_Validate(tod) )
     200    return -1;
     201
     202  RTC_Table[RTC_Minor].pDeviceFns->deviceSetTime(RTC_Minor, tod);
     203  return 0;
     204}
     205
     206
     207/*PAGE
     208 *
    153209 *  checkRealTime
    154210 *
     
    161217 *
    162218 *  Return values:
    163  *    int   The differance between the real time clock and rtems time or
    164  *          9999 in the event of an error.
    165  */
     219 *    int   The differance between the real time clock and rtems time.
     220 */
     221
     222/* XXX this routine should be part of the public RTEMS interface */
     223unsigned32 _TOD_To_seconds( rtems_time_of_day *tod );
    166224
    167225int checkRealTime()
     
    169227  rtems_time_of_day rtems_tod;
    170228  rtems_time_of_day rtc_tod;
    171 
    172   if (!RTC_Present)
    173     return 0;
     229  unsigned32 rtems_time;
     230  unsigned32 rtc_time;
     231
     232  if (!RTC_Present)
     233    return -1;
    174234
    175235  rtems_clock_get( RTEMS_CLOCK_GET_TOD, &rtems_tod );
    176236  RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, &rtc_tod);
    177237
    178   if( rtems_tod.year == rtc_tod.year &&
    179       rtems_tod.month == rtc_tod.month &&
    180       rtems_tod.day == rtc_tod.day ) {
    181      return ((rtems_tod.hour   - rtc_tod.hour) * 3600) +
    182             ((rtems_tod.minute - rtc_tod.minute) * 60) +
    183              (rtems_tod.second - rtc_tod.second);
    184   }
    185   return 9999;
    186 }
    187 
     238  rtems_time = _TOD_To_seconds( &rtems_tod );
     239  rtc_time = _TOD_To_seconds( &rtc_tod );
     240
     241  return rtems_time - rtc_time;
     242}
     243
  • c/src/lib/libbsp/shared/tod.h

    r91af3e4 r509dc7c1  
    2222#endif
    2323
    24 extern void setRealTimeToRTEMS();
    25 /* Read real time from RTC and set it to RTEMS' clock manager */
     24/*
     25 *  Set the RTC.
     26 */
    2627
    27 extern void setRealTimeFromRTEMS();
    28 /* Read time from RTEMS' clock manager and set it to RTC */
     28int setRealTime(
     29  rtems_time_of_day *tod
     30);
    2931
    30 extern int checkRealTime();
    31 /* Return the difference between RTC and RTEMS' clock manager time in minutes.
    32    If the difference is greater than 1 day, this returns 9999. */
     32/*
     33 *  Get the time from the RTC.
     34 */
     35
     36void getRealTime(
     37  rtems_time_of_day *tod
     38);
     39
     40/*
     41 *  Read real time from RTC and set it to RTEMS' clock manager
     42 */
     43
     44void setRealTimeToRTEMS();
     45
     46/*
     47 *  Read time from RTEMS' clock manager and set it to RTC
     48 */
     49
     50void setRealTimeFromRTEMS();
     51
     52/*
     53 *  Return the difference between RTC and RTEMS' clock manager time in minutes.
     54 *  If the difference is greater than 1 day, this returns 9999.
     55 */
     56
     57int checkRealTime();
    3358
    3459#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.