RTEMS Logo

RTEMS 4.6.99.3 On-Line Library


Real-Time Clock Driver Introduction

PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

11.1: Introduction

The Real-Time Clock (RTC) driver is responsible for providing an interface to an RTC device. [NOTE: In this chapter, the abbreviation TOD is used for Time of Day.] The capabilities provided by this driver are:

The reference implementation for a real-time clock driver can be found in c/src/lib/libbsp/shared/tod.c. This driver is based on the libchip concept and can be easily configured to work with any of the RTC chips supported by the RTC chip drivers in the directory c/src/lib/lib/libchip/rtc. There is a README file in this directory for each supported RTC chip. Each of these README explains how to configure the shared libchip implementation of the RTC driver for that particular RTC chip.

The DY-4 DMV177 BSP used the shared libchip implementation of the RTC driver. There were no DMV177 specific configuration routines. A BSP could use configuration routines to dynamically determine what type of real-time clock is on a particular board. This would be useful for a BSP supporting multiple board models. The relevant ports of the DMV177's RTC_Table configuration table is below:


#include <bsp.h>
#include <libchip/rtc.h>
#include <libchip/icm7170.h>

boolean dmv177_icm7170_probe(int minor);

rtc_tbl	RTC_Table[] = {
  { "/dev/rtc0",                /* sDeviceName */
    RTC_ICM7170,                /* deviceType */
    &icm7170_fns,               /* pDeviceFns */
    dmv177_icm7170_probe,       /* deviceProbe */
    (void *) ICM7170_AT_1_MHZ,  /* pDeviceParams */
    DMV170_RTC_ADDRESS,         /* ulCtrlPort1 */
    0,                          /* ulDataPort */
    icm7170_get_register_8,     /* getRegister */
    icm7170_set_register_8,     /* setRegister */
  }
};

unsigned long  RTC_Count = (sizeof(RTC_Table)/sizeof(rtc_tbl));
rtems_device_minor_number  RTC_Minor;

boolean dmv177_icm7170_probe(int minor)
{
  volatile unsigned16 *card_resource_reg;

  card_resource_reg = (volatile unsigned16 *) DMV170_CARD_RESORCE_REG;

  if ( (*card_resource_reg & DMV170_RTC_INST_MASK) == DMV170_RTC_INSTALLED )
    return TRUE;
  return FALSE;
}


PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

Copyright © 1988-2004 OAR Corporation