working version!

This commit is contained in:
Oliver Lehmann 2009-08-10 20:18:59 +00:00
parent 4e10f7aa7c
commit 27722c2705
7 changed files with 32 additions and 69 deletions

View File

@ -23,17 +23,12 @@
* 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.2 2009/08/07 20:02:59 olivleh1 Exp $ * $Id: gmtime.c,v 1.3 2009/08/10 20:18:59 olivleh1 Exp $
*/ */
#define dysize(A) (((A)%4)? 365: 366) #define dysize(A) (((A)%4)? 365: 366)
#include <time.h> #include <time.h>
struct tm *gmtime();
static char cbuf[26];
static int dmsize[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
struct tm * struct tm *
gmtime(tim) gmtime(tim)
long *tim; long *tim;
@ -41,6 +36,7 @@ long *tim;
register int d0, d1; register int d0, d1;
long hms, day; long hms, day;
static struct tm xtime; static struct tm xtime;
static int dmsize[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
/* /*
* break initial number into days * break initial number into days

View File

@ -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.3 2009/08/07 20:02:59 olivleh1 Exp $ * $Id: u130.c,v 1.4 2009/08/10 20:18:59 olivleh1 Exp $
*/ */
#include <time.h> #include <time.h>
@ -32,9 +32,8 @@
int rdvalue(); int rdvalue();
int invalue(); int invalue();
void outvalue(); void outvalue();
extern long timegm(); long timegm();
extern struct tm *gmtime(); struct tm *gmtime();
int int
u130_init() u130_init()
@ -42,8 +41,7 @@ u130_init()
return(0); return(0);
} }
void
int
u130_set(time) u130_set(time)
long time; long time;
{ {
@ -98,7 +96,6 @@ long time;
; ;
outvalue(0x01); /* Korrektur Stop */ outvalue(0x01); /* Korrektur Stop */
outvalue(0x00); outvalue(0x00);
return(0);
} }
void void
@ -129,21 +126,11 @@ u130_get()
while ((clktime->tm_sec = rdvalue(U130SSx1)) == 59); while ((clktime->tm_sec = rdvalue(U130SSx1)) == 59);
clktime->tm_min = rdvalue(U130MIx1); clktime->tm_min = rdvalue(U130MIx1);
clktime->tm_hour = rdvalue(U130HHx1); clktime->tm_hour = rdvalue(U130HHx1);
#ifdef DEBUG
printf("u130_get\n");
printf("year %d\n",clktime->tm_year);
printf("month %d\n",clktime->tm_mon);
printf("day %d\n",clktime->tm_mday);
printf("hour %d\n",clktime->tm_hour);
printf("min %d\n",clktime->tm_min);
printf("sec %d\n",clktime->tm_sec);
#endif
time = timegm(clktime);
time = timegm(clktime);
return(time); return(time);
} }
void void
outvalue(t) outvalue(t)
register t; register t;
@ -203,5 +190,5 @@ int
rdvalue(addr) rdvalue(addr)
unsigned addr; unsigned addr;
{ {
return(invalue(addr,0) + invalue(addr+2,0)*10); return(invalue(addr,0) + invalue(addr+2,0)*10);
} }

View File

@ -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.2 2009/08/07 20:02:59 olivleh1 Exp $ * $Id: u130.h,v 1.3 2009/08/10 20:18:59 olivleh1 Exp $
*/ */
#ifndef U130_H #ifndef U130_H
@ -48,7 +48,7 @@
int u130_init(); int u130_init();
long u130_get(); long u130_get();
int u130_set(); void u130_set();
void u130_start(); void u130_start();
#endif #endif

View File

@ -1,12 +1,10 @@
OBJ= sa.timer.o u130.o rtc72421.o gmtime.o timegm.o libb.a OBJ= sa.timer.o libb.a u130.o gmtime.o timegm.o
CC= cc CC= cc
LD= ld LD= ld
DEBUG= DEBUG=
CFLAGS= -O $(DEBUG) CFLAGS= -O $(DEBUG)
all: sa.timer all: sa.timer
sa.timer.o:
$(CC) -c $(DEBUG) sa.timer.c
sa.timer: $(OBJ) sa.timer: $(OBJ)
$(LD) -s -o $@ $(OBJ) $(LD) -s -o $@ $(OBJ)
chmod 400 $@ chmod 400 $@

View File

@ -1,12 +1,10 @@
OBJ= sa.timer.o u130.o rtc72421.o gmtime.o timegm.o libb.a OBJ= sa.timer.o libb.a u130.o gmtime.o timegm.o
CC= cc CC= cc
LD= ld LD= ld
DEBUG= DEBUG=
CFLAGS= -O $(DEBUG) CFLAGS= -O $(DEBUG)
all: sa.timer all: sa.timer
sa.timer.o:
$(CC) -c $(DEBUG) sa.timer.c
sa.timer: $(OBJ) sa.timer: $(OBJ)
$(LD) -s -o $@ $(OBJ) $(LD) -s -o $@ $(OBJ)
chmod 400 $@ chmod 400 $@

View File

@ -1,12 +1,10 @@
OBJ= sa.timer.o u130.o rtc72421.o gmtime.o timegm.o libb.a OBJ= sa.timer.o libb.a u130.o gmtime.o timegm.o
CC= cc CC= cc
LD= ld LD= ld
DEBUG= DEBUG=
CFLAGS= -O $(DEBUG) CFLAGS= -O $(DEBUG)
all: sa.timer all: sa.timer
sa.timer.o:
$(CC) -c $(DEBUG) sa.timer.c
sa.timer: $(OBJ) sa.timer: $(OBJ)
$(LD) -s -o $@ $(OBJ) $(LD) -s -o $@ $(OBJ)
chmod 400 $@ chmod 400 $@

View File

@ -23,27 +23,29 @@
* 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.2 2009/08/07 20:02:59 olivleh1 Exp $ * $Id: sa.timer.c,v 1.3 2009/08/10 20:18:59 olivleh1 Exp $
*/ */
#include <stdio.h>
#include <time.h> char estring[20];
long u130_get();
#define dysize(A) (((A)%4)? 365: 366)
#include "time.h"
#include "u130.h" #include "u130.h"
#include "rtc72421.h" #include "rtc72421.h"
#include "timer.h" #include "timer.h"
extern long timegm(); long timegm();
extern struct tm *gmtime(); struct tm *gmtime();
main() main()
{ {
register long time; register long time;
register i,timer_found; register i,timer_found;
struct clock_type *t; struct clock_type *t;
int a;
t = clock_devs; t = clock_devs;
#ifdef foo
for( i = 0 ; i < sizeof(clock_devs) / sizeof(clock_devs[0]); i++, t++) { for( i = 0 ; i < sizeof(clock_devs) / sizeof(clock_devs[0]); i++, t++) {
if((inb(t->clock_addr)&~t->clock_det_msk) == t->clock_det_str) { if((inb(t->clock_addr)&~t->clock_det_msk) == t->clock_det_str) {
printf("%s found\n",t->clock_name); printf("%s found\n",t->clock_name);
@ -52,6 +54,9 @@ main()
break; break;
} }
} }
#else
timer_found=1;
#endif
if (timer_found != 1) { /* Uhrmodul vorhanden ? */ if (timer_found != 1) { /* Uhrmodul vorhanden ? */
printf("Timer not available\n"); printf("Timer not available\n");
exit(1); exit(1);
@ -88,11 +93,8 @@ long time;
clktime = gmtime(&time); clktime = gmtime(&time);
#ifdef DEBUG clktime->tm_year += 1900;
print_tm("outtime",clktime); clktime->tm_mon ++;
#endif
(clktime->tm_year) += 1900;
clktime->tm_mon++;
printf("Date is: %d/%d/%d\n", clktime->tm_mon, clktime->tm_mday, clktime->tm_year); printf("Date is: %d/%d/%d\n", clktime->tm_mon, clktime->tm_mday, clktime->tm_year);
printf("Time is: %d:%d:%d GMT\n", clktime->tm_hour, clktime->tm_min, clktime->tm_sec); printf("Time is: %d:%d:%d GMT\n", clktime->tm_hour, clktime->tm_min, clktime->tm_sec);
} }
@ -101,7 +103,7 @@ settimer()
{ {
struct tm *clktime; struct tm *clktime;
long time; long time;
int i; register i;
loop1: loop1:
printf("Enter new Date (MM/DD/YY) : "); printf("Enter new Date (MM/DD/YY) : ");
gets(estring, sizeof estring); gets(estring, sizeof estring);
@ -132,20 +134,4 @@ loop2:
printf("Enter Return to start time : "); printf("Enter Return to start time : ");
gets(estring, 1); gets(estring, 1);
u130_start(); u130_start();
} }
#ifdef DEBUG
print_tm(func,clktime)
char *func;
struct tm *clktime;
{
printf("%s\n", func);
printf("year %d\n",clktime->tm_year);
printf("month %d\n",clktime->tm_mon);
printf("day %d\n",clktime->tm_mday);
printf("hour %d\n",clktime->tm_hour);
printf("min %d\n",clktime->tm_min);
printf("sec %d\n",clktime->tm_sec);
}
#endif