forked from Imagelibrary/rtems
Added TOD driver from Katsutoshi Shibuya.
This commit is contained in:
@@ -22,4 +22,4 @@ SRCS=README
|
||||
# from the individual .rel files built in other directories
|
||||
#
|
||||
# XXXX add tools
|
||||
SUB_DIRS=include startup clock console consolex timer wrapup
|
||||
SUB_DIRS=include startup clock console consolex timer tod wrapup
|
||||
|
||||
@@ -7,7 +7,8 @@ srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH=@srcdir@
|
||||
|
||||
H_FILES = $(srcdir)/bsp.h $(srcdir)/coverhd.h $(srcdir)/page_table.h
|
||||
H_FILES = $(srcdir)/bsp.h $(srcdir)/coverhd.h $(srcdir)/page_table.h \
|
||||
$(srcdir)/tod.h
|
||||
|
||||
#
|
||||
# Equate files are for including from assembly preprocessed by
|
||||
|
||||
42
c/src/lib/libbsp/m68k/mvme162/include/tod.h
Normal file
42
c/src/lib/libbsp/m68k/mvme162/include/tod.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Real Time Clock (MK48T08) for RTEMS on MVME162
|
||||
*
|
||||
* Author:
|
||||
* COPYRIGHT (C) 1997
|
||||
* by Katsutoshi Shibuya - BU Denken Co.,Ltd. - Sapporo - JAPAN
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* This material is a part of the MVME162 Board Support Package
|
||||
* for the RTEMS executive. Its licensing policies are those of the
|
||||
* RTEMS above.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TOD_H
|
||||
#define TOD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void setRealTimeToRTEMS();
|
||||
/* Read real time from RTC and set it to RTEMS' clock manager */
|
||||
|
||||
extern void setRealTimeFromRTEMS();
|
||||
/* Read time from RTEMS' clock manager and set it to RTC */
|
||||
|
||||
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. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
54
c/src/lib/libbsp/m68k/mvme162/tod/Makefile.in
Normal file
54
c/src/lib/libbsp/m68k/mvme162/tod/Makefile.in
Normal file
@@ -0,0 +1,54 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
@SET_MAKE@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH=@srcdir@
|
||||
|
||||
PGM=${ARCH}/tod.rel
|
||||
|
||||
# C source names, if any, go here -- minus the .c
|
||||
C_PIECES=tod
|
||||
C_FILES=$(C_PIECES:%=%.c)
|
||||
C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
|
||||
|
||||
H_FILES=
|
||||
|
||||
SRCS=$(C_FILES) $(H_FILES)
|
||||
OBJS=$(C_O_FILES)
|
||||
|
||||
include $(RTEMS_CUSTOM)
|
||||
include $(PROJECT_ROOT)/make/leaf.cfg
|
||||
|
||||
|
||||
#
|
||||
# (OPTIONAL) Add local stuff here using +=
|
||||
#
|
||||
|
||||
DEFINES +=
|
||||
CPPFLAGS +=
|
||||
CFLAGS +=
|
||||
|
||||
LD_PATHS +=
|
||||
LD_LIBS +=
|
||||
LDFLAGS +=
|
||||
|
||||
#
|
||||
# Add your list of files to delete here. The config files
|
||||
# already know how to delete some stuff, so you may want
|
||||
# to just run 'make clean' first to see what gets missed.
|
||||
# 'make clobber' already includes 'make clean'
|
||||
#
|
||||
|
||||
CLEAN_ADDITIONS +=
|
||||
CLOBBER_ADDITIONS +=
|
||||
|
||||
${PGM}: ${SRCS} ${OBJS}
|
||||
$(make-rel)
|
||||
|
||||
all: ${ARCH} $(SRCS) $(PGM)
|
||||
|
||||
# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
|
||||
install: all
|
||||
90
c/src/lib/libbsp/m68k/mvme162/tod/tod.c
Normal file
90
c/src/lib/libbsp/m68k/mvme162/tod/tod.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Real Time Clock (MK48T08) for RTEMS on MVME162
|
||||
*
|
||||
* Author:
|
||||
* COPYRIGHT (C) 1997
|
||||
* by Katsutoshi Shibuya - BU Denken Co.,Ltd. - Sapporo - JAPAN
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.OARcorp.com/rtems/license.html.
|
||||
*
|
||||
* This material is a part of the MVME162 Board Support Package
|
||||
* for the RTEMS executive. Its licensing policies are those of the
|
||||
* RTEMS above.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <tod.h>
|
||||
|
||||
#define tod ((volatile unsigned char *)0xfffc1ff8)
|
||||
|
||||
static int getTod(int n, unsigned char mask)
|
||||
{
|
||||
unsigned char x;
|
||||
|
||||
x = tod[n]&mask;
|
||||
return (x>>4)*10+(x&0x0f);
|
||||
}
|
||||
|
||||
static void setTod(int n, unsigned char d)
|
||||
{
|
||||
tod[n] = ((d/10)<<4)+(d%10);
|
||||
}
|
||||
|
||||
void setRealTimeToRTEMS()
|
||||
{
|
||||
rtems_time_of_day t;
|
||||
|
||||
tod[0] |= 0x40; /* Stop read register */
|
||||
t.year = 1900+getTod(7,0xff);
|
||||
t.month = getTod(6,0x1f);
|
||||
t.day = getTod(5,0x3f);
|
||||
t.hour = getTod(3,0x3f);
|
||||
t.minute = getTod(2,0x7f);
|
||||
t.second = getTod(1,0x7f);
|
||||
t.ticks = 0;
|
||||
tod[0] &= 0x3f; /* Release read register */
|
||||
|
||||
rtems_clock_set(&t);
|
||||
}
|
||||
|
||||
void setRealTimeFromRTEMS()
|
||||
{
|
||||
rtems_time_of_day t;
|
||||
|
||||
rtems_clock_get(RTEMS_CLOCK_GET_TOD,&t);
|
||||
t.year -= 1900;
|
||||
|
||||
tod[0] |= 0x80; /* Stop write register */
|
||||
setTod(7,t.year);
|
||||
setTod(6,t.month);
|
||||
setTod(5,t.day);
|
||||
setTod(4,1); /* I don't know which day of week is */
|
||||
setTod(3,t.hour);
|
||||
setTod(2,t.minute);
|
||||
setTod(1,t.second);
|
||||
tod[0] &= 0x3f; /* Write these parameters */
|
||||
}
|
||||
|
||||
int checkRealTime()
|
||||
{
|
||||
rtems_time_of_day t;
|
||||
int d;
|
||||
|
||||
tod[0] |= 0x40; /* Stop read register */
|
||||
rtems_clock_get(RTEMS_CLOCK_GET_TOD,&t);
|
||||
if((t.year != 1900+getTod(7,0xff))
|
||||
|| (t.month != getTod(6,0x1f))
|
||||
|| (t.day != getTod(5,0x3f)))
|
||||
d = 9999;
|
||||
else
|
||||
d = (t.hour-getTod(3,0x3f))*3600
|
||||
+ (t.minute-getTod(3,0x7f))*60
|
||||
+ (t.second - getTod(1,0x7f));
|
||||
tod[1] &= 0x3f;
|
||||
return d;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH=@srcdir@
|
||||
|
||||
BSP_PIECES=startup clock console timer
|
||||
BSP_PIECES=startup clock console timer tod
|
||||
CPU_PIECES=
|
||||
GENERIC_PIECES=
|
||||
|
||||
|
||||
Reference in New Issue
Block a user