add the ability to specify the min and may years a clock supports

fix the copyright comment to not being reformated with indent(1)
This commit is contained in:
Oliver Lehmann 2009-08-12 19:27:31 +00:00
parent cecbfd2607
commit dc462533f9
11 changed files with 57 additions and 45 deletions

View File

@ -1,4 +1,4 @@
/* /*-
* Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org> * Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org>
* All rights reserved. * All rights reserved.
* *
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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) #define dysize(A) (((A)%4)? 365: 366)

View File

@ -1,4 +1,4 @@
/* /*-
* Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org> * Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org>
* All rights reserved. * All rights reserved.
* *
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 <time.h> #include <time.h>

View File

@ -1,4 +1,4 @@
/* /*-
* Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org> * Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org>
* All rights reserved. * All rights reserved.
* *
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 #ifndef R421_H

View File

@ -1,4 +1,4 @@
/* /*-
* Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org> * Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org>
* All rights reserved. * All rights reserved.
* *
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 <time.h> #include <time.h>

View File

@ -1,4 +1,4 @@
/* /*-
* Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org> * Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org>
* All rights reserved. * All rights reserved.
* *
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 #ifndef TIMER_H
@ -33,21 +33,23 @@ struct clock_type {
int clock_addr; int clock_addr;
int clock_det_msk; int clock_det_msk;
int clock_det_str; int clock_det_str;
int clock_min_year;
int clock_max_year;
char *clock_name; char *clock_name;
int (*time_init)(); int (*clock_finit)();
long (*time_get)(); long (*clock_fget)();
void (*time_set)(); void (*clock_fset)();
void (*time_start)(); void (*clock_fstart)();
}; };
char estring[20]; char estring[20];
static struct clock_type clock_devs[] = { static struct clock_type clock_devs[] = {
{ U130BASE, MSK_U130, STR_U130, { U130BASE, MSK_U130, STR_U130, 80, 119,
"RFT U130X RTC", "RFT U130X RTC",
u130_init, u130_get, u130_set, u130_start u130_init, u130_get, u130_set, u130_start
}, },
{ R421BASE, MSK_R421, STR_R421, { R421BASE, MSK_R421, STR_R421, 70, 137,
"Seiko Epson RTC-72421", "Seiko Epson RTC-72421",
rtc72421_init, rtc72421_get, rtc72421_set, rtc72421_start rtc72421_init, rtc72421_get, rtc72421_set, rtc72421_start
}, },

View File

@ -1,4 +1,4 @@
/* /*-
* Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org> * Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org>
* All rights reserved. * All rights reserved.
* *
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 <time.h> #include <time.h>

View File

@ -1,4 +1,4 @@
/* /*-
* Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org> * Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org>
* All rights reserved. * All rights reserved.
* *
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 #ifndef U130_H

View File

@ -8,3 +8,5 @@ all: sa.timer
sa.timer: $(OBJ) sa.timer: $(OBJ)
$(LD) -s -o $@ $(OBJ) $(LD) -s -o $@ $(OBJ)
chmod 400 $@ chmod 400 $@
clean:
rm -f $(OBJ) sa.timer

View File

@ -8,3 +8,5 @@ all: sa.timer
sa.timer: $(OBJ) sa.timer: $(OBJ)
$(LD) -s -o $@ $(OBJ) $(LD) -s -o $@ $(OBJ)
chmod 400 $@ chmod 400 $@
clean:
rm -f $(OBJ) sa.timer

View File

@ -8,3 +8,5 @@ all: sa.timer
sa.timer: $(OBJ) sa.timer: $(OBJ)
$(LD) -s -o $@ $(OBJ) $(LD) -s -o $@ $(OBJ)
chmod 400 $@ chmod 400 $@
clean:
rm -f $(OBJ) sa.timer

View File

@ -1,4 +1,4 @@
/* /*-
* Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org> * Copyright (c) 2009 Oliver Lehmann <oliver@FreeBSD.org>
* All rights reserved. * All rights reserved.
* *
@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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(); struct tm *gmtime();
long u130_get(); long u130_get();
int (*time_init)(); int clock_min_year;
long (*time_get)(); int clock_max_year;
void (*time_set)(); int (*clock_finit)();
void (*time_start)(); long (*clock_fget)();
void (*clock_fset)();
void (*clock_fstart)();
main() main()
{ {
@ -55,21 +57,24 @@ main()
b = t->clock_det_str; b = t->clock_det_str;
if(a == b) { if(a == b) {
printf("%s found\n",t->clock_name); printf("%s found\n",t->clock_name);
time_init = t->time_init; clock_finit = t->clock_finit;
time_get = t->time_get; clock_fget = t->clock_fget;
time_set = t->time_set; clock_fset = t->clock_fset;
time_start = t->time_start; clock_fstart = t->clock_fstart;
clock_min_year = t->clock_min_year;
clock_max_year = t->clock_max_year;
break; break;
} }
} }
if (time_init > 0) { /* function pointer assigned? */ /* function pointer assigned? => RTC found?*/
time_init(); /* init RTC */ if (clock_finit > 0) {
time = time_get(); /* Uhrenmodul lesen */ clock_finit();
outtime(time); /* Datum/Zeit ausgeben */ time = clock_fget();
settimer(time); /* Uhrenmodul neu programmieren */ outtime(time);
time = time_get(); /* Uhrenmodul lesen */ settimer(time);
outtime(time); /* Datum/Zeit ausgeben */ time = clock_fget();
outtime(time);
exit(0); exit(0);
} else { } else {
printf("Timer not available\n"); printf("Timer not available\n");
@ -123,7 +128,6 @@ long time;
{ {
struct tm *clktime; struct tm *clktime;
long time2; long time2;
register i;
clktime = gmtime(&time); clktime = gmtime(&time);
loop1: loop1:
@ -137,7 +141,7 @@ loop1:
if (clktime->tm_year < 70 ) if (clktime->tm_year < 70 )
clktime->tm_year += 100; 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_year<clock_min_year || clktime->tm_year>clock_max_year)
goto loop1; goto loop1;
loop2: loop2:
@ -153,8 +157,8 @@ loop2:
time2 = timegm(clktime); time2 = timegm(clktime);
time_set(time2); clock_fset(time2);
printf("Enter Return to start time : "); printf("Enter Return to start time : ");
gets(estring, 1); gets(estring, 1);
time_start(); clock_fstart();
} }