Changeset 509dc7c1 in rtems for c/src/lib/libbsp/shared/tod.c


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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.