From dc462533f902eae2041f101898eefec9e215fdb3 Mon Sep 17 00:00:00 2001 From: Oliver Lehmann Date: Wed, 12 Aug 2009 19:27:31 +0000 Subject: [PATCH] add the ability to specify the min and may years a clock supports fix the copyright comment to not being reformated with indent(1) --- .../cmd/standalone/sa.timer/common/gmtime.c | 4 +- .../cmd/standalone/sa.timer/common/rtc72421.c | 4 +- .../cmd/standalone/sa.timer/common/rtc72421.h | 4 +- .../cmd/standalone/sa.timer/common/timegm.c | 4 +- .../cmd/standalone/sa.timer/common/timer.h | 26 ++++++----- .../src/cmd/standalone/sa.timer/common/u130.c | 4 +- .../src/cmd/standalone/sa.timer/common/u130.h | 4 +- .../cmd/standalone/sa.timer/kernel/makefile | 2 + WEGA/src/cmd/standalone/sa.timer/makefile | 2 + .../standalone/sa.timer/standalone/makefile | 2 + .../standalone/sa.timer/standalone/sa.timer.c | 46 ++++++++++--------- 11 files changed, 57 insertions(+), 45 deletions(-) diff --git a/WEGA/src/cmd/standalone/sa.timer/common/gmtime.c b/WEGA/src/cmd/standalone/sa.timer/common/gmtime.c index 10c9aeb..5788b0f 100644 --- a/WEGA/src/cmd/standalone/sa.timer/common/gmtime.c +++ b/WEGA/src/cmd/standalone/sa.timer/common/gmtime.c @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 2009 Oliver Lehmann * All rights reserved. * @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: gmtime.c,v 1.3 2009/08/10 20:18:59 olivleh1 Exp $ + * $Id: gmtime.c,v 1.4 2009/08/12 19:27:31 olivleh1 Exp $ */ #define dysize(A) (((A)%4)? 365: 366) diff --git a/WEGA/src/cmd/standalone/sa.timer/common/rtc72421.c b/WEGA/src/cmd/standalone/sa.timer/common/rtc72421.c index cc32a9c..24502d3 100644 --- a/WEGA/src/cmd/standalone/sa.timer/common/rtc72421.c +++ b/WEGA/src/cmd/standalone/sa.timer/common/rtc72421.c @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 2009 Oliver Lehmann * All rights reserved. * @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: rtc72421.c,v 1.3 2009/08/11 19:18:03 olivleh1 Exp $ + * $Id: rtc72421.c,v 1.4 2009/08/12 19:27:31 olivleh1 Exp $ */ #include diff --git a/WEGA/src/cmd/standalone/sa.timer/common/rtc72421.h b/WEGA/src/cmd/standalone/sa.timer/common/rtc72421.h index 144ef38..b5864b8 100644 --- a/WEGA/src/cmd/standalone/sa.timer/common/rtc72421.h +++ b/WEGA/src/cmd/standalone/sa.timer/common/rtc72421.h @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 2009 Oliver Lehmann * All rights reserved. * @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: rtc72421.h,v 1.3 2009/08/11 19:18:03 olivleh1 Exp $ + * $Id: rtc72421.h,v 1.4 2009/08/12 19:27:31 olivleh1 Exp $ */ #ifndef R421_H diff --git a/WEGA/src/cmd/standalone/sa.timer/common/timegm.c b/WEGA/src/cmd/standalone/sa.timer/common/timegm.c index c09828f..9bd3802 100644 --- a/WEGA/src/cmd/standalone/sa.timer/common/timegm.c +++ b/WEGA/src/cmd/standalone/sa.timer/common/timegm.c @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 2009 Oliver Lehmann * All rights reserved. * @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: timegm.c,v 1.1 2009/08/07 13:53:20 olivleh1 Exp $ + * $Id: timegm.c,v 1.2 2009/08/12 19:27:31 olivleh1 Exp $ */ #include diff --git a/WEGA/src/cmd/standalone/sa.timer/common/timer.h b/WEGA/src/cmd/standalone/sa.timer/common/timer.h index 37ce8bd..4077487 100644 --- a/WEGA/src/cmd/standalone/sa.timer/common/timer.h +++ b/WEGA/src/cmd/standalone/sa.timer/common/timer.h @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 2009 Oliver Lehmann * All rights reserved. * @@ -23,31 +23,33 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: timer.h,v 1.2 2009/08/11 19:18:03 olivleh1 Exp $ + * $Id: timer.h,v 1.3 2009/08/12 19:27:31 olivleh1 Exp $ */ #ifndef TIMER_H #define TIMER_H 1 struct clock_type { - int clock_addr; - int clock_det_msk; - int clock_det_str; - char *clock_name; - int (*time_init)(); - long (*time_get)(); - void (*time_set)(); - void (*time_start)(); + int clock_addr; + int clock_det_msk; + int clock_det_str; + int clock_min_year; + int clock_max_year; + char *clock_name; + int (*clock_finit)(); + long (*clock_fget)(); + void (*clock_fset)(); + void (*clock_fstart)(); }; char estring[20]; static struct clock_type clock_devs[] = { - { U130BASE, MSK_U130, STR_U130, + { U130BASE, MSK_U130, STR_U130, 80, 119, "RFT U130X RTC", u130_init, u130_get, u130_set, u130_start }, - { R421BASE, MSK_R421, STR_R421, + { R421BASE, MSK_R421, STR_R421, 70, 137, "Seiko Epson RTC-72421", rtc72421_init, rtc72421_get, rtc72421_set, rtc72421_start }, diff --git a/WEGA/src/cmd/standalone/sa.timer/common/u130.c b/WEGA/src/cmd/standalone/sa.timer/common/u130.c index 4e13ed5..7d4504c 100644 --- a/WEGA/src/cmd/standalone/sa.timer/common/u130.c +++ b/WEGA/src/cmd/standalone/sa.timer/common/u130.c @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 2009 Oliver Lehmann * All rights reserved. * @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: u130.c,v 1.8 2009/08/12 16:23:35 olivleh1 Exp $ + * $Id: u130.c,v 1.9 2009/08/12 19:27:31 olivleh1 Exp $ */ #include diff --git a/WEGA/src/cmd/standalone/sa.timer/common/u130.h b/WEGA/src/cmd/standalone/sa.timer/common/u130.h index c529b47..8171697 100644 --- a/WEGA/src/cmd/standalone/sa.timer/common/u130.h +++ b/WEGA/src/cmd/standalone/sa.timer/common/u130.h @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 2009 Oliver Lehmann * All rights reserved. * @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: u130.h,v 1.3 2009/08/10 20:18:59 olivleh1 Exp $ + * $Id: u130.h,v 1.4 2009/08/12 19:27:31 olivleh1 Exp $ */ #ifndef U130_H diff --git a/WEGA/src/cmd/standalone/sa.timer/kernel/makefile b/WEGA/src/cmd/standalone/sa.timer/kernel/makefile index bfedfdf..8a246cc 100644 --- a/WEGA/src/cmd/standalone/sa.timer/kernel/makefile +++ b/WEGA/src/cmd/standalone/sa.timer/kernel/makefile @@ -8,3 +8,5 @@ all: sa.timer sa.timer: $(OBJ) $(LD) -s -o $@ $(OBJ) chmod 400 $@ +clean: + rm -f $(OBJ) sa.timer diff --git a/WEGA/src/cmd/standalone/sa.timer/makefile b/WEGA/src/cmd/standalone/sa.timer/makefile index bfedfdf..8a246cc 100644 --- a/WEGA/src/cmd/standalone/sa.timer/makefile +++ b/WEGA/src/cmd/standalone/sa.timer/makefile @@ -8,3 +8,5 @@ all: sa.timer sa.timer: $(OBJ) $(LD) -s -o $@ $(OBJ) chmod 400 $@ +clean: + rm -f $(OBJ) sa.timer diff --git a/WEGA/src/cmd/standalone/sa.timer/standalone/makefile b/WEGA/src/cmd/standalone/sa.timer/standalone/makefile index bfedfdf..8a246cc 100644 --- a/WEGA/src/cmd/standalone/sa.timer/standalone/makefile +++ b/WEGA/src/cmd/standalone/sa.timer/standalone/makefile @@ -8,3 +8,5 @@ all: sa.timer sa.timer: $(OBJ) $(LD) -s -o $@ $(OBJ) chmod 400 $@ +clean: + rm -f $(OBJ) sa.timer diff --git a/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c b/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c index 5f8dafb..7a97bc7 100644 --- a/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c +++ b/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 2009 Oliver Lehmann * All rights reserved. * @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: sa.timer.c,v 1.9 2009/08/12 16:29:42 olivleh1 Exp $ + * $Id: sa.timer.c,v 1.10 2009/08/12 19:27:31 olivleh1 Exp $ */ @@ -36,10 +36,12 @@ long timegm(); struct tm *gmtime(); long u130_get(); -int (*time_init)(); -long (*time_get)(); -void (*time_set)(); -void (*time_start)(); +int clock_min_year; +int clock_max_year; +int (*clock_finit)(); +long (*clock_fget)(); +void (*clock_fset)(); +void (*clock_fstart)(); main() { @@ -55,21 +57,24 @@ main() b = t->clock_det_str; if(a == b) { printf("%s found\n",t->clock_name); - time_init = t->time_init; - time_get = t->time_get; - time_set = t->time_set; - time_start = t->time_start; + clock_finit = t->clock_finit; + clock_fget = t->clock_fget; + clock_fset = t->clock_fset; + clock_fstart = t->clock_fstart; + clock_min_year = t->clock_min_year; + clock_max_year = t->clock_max_year; break; } } - if (time_init > 0) { /* function pointer assigned? */ - time_init(); /* init RTC */ - time = time_get(); /* Uhrenmodul lesen */ - outtime(time); /* Datum/Zeit ausgeben */ - settimer(time); /* Uhrenmodul neu programmieren */ - time = time_get(); /* Uhrenmodul lesen */ - outtime(time); /* Datum/Zeit ausgeben */ + /* function pointer assigned? => RTC found?*/ + if (clock_finit > 0) { + clock_finit(); + time = clock_fget(); + outtime(time); + settimer(time); + time = clock_fget(); + outtime(time); exit(0); } else { printf("Timer not available\n"); @@ -123,7 +128,6 @@ long time; { struct tm *clktime; long time2; - register i; clktime = gmtime(&time); loop1: @@ -137,7 +141,7 @@ loop1: if (clktime->tm_year < 70 ) clktime->tm_year += 100; - if (clktime->tm_mon<0 || clktime->tm_mon>11 || clktime->tm_mday<1 || clktime->tm_mday>31) + if (clktime->tm_mon<0 || clktime->tm_mon>11 || clktime->tm_mday<1 || clktime->tm_mday>31 || clktime->tm_yeartm_year>clock_max_year) goto loop1; loop2: @@ -153,8 +157,8 @@ loop2: time2 = timegm(clktime); - time_set(time2); + clock_fset(time2); printf("Enter Return to start time : "); gets(estring, 1); - time_start(); + clock_fstart(); }