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
* 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)
#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 *
gmtime(tim)
long *tim;
@ -41,6 +36,7 @@ long *tim;
register int d0, d1;
long hms, day;
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

View File

@ -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.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>
@ -32,9 +32,8 @@
int rdvalue();
int invalue();
void outvalue();
extern long timegm();
extern struct tm *gmtime();
long timegm();
struct tm *gmtime();
int
u130_init()
@ -42,8 +41,7 @@ u130_init()
return(0);
}
int
void
u130_set(time)
long time;
{
@ -98,7 +96,6 @@ long time;
;
outvalue(0x01); /* Korrektur Stop */
outvalue(0x00);
return(0);
}
void
@ -129,21 +126,11 @@ u130_get()
while ((clktime->tm_sec = rdvalue(U130SSx1)) == 59);
clktime->tm_min = rdvalue(U130MIx1);
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);
}
void
outvalue(t)
register t;

View File

@ -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.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
@ -48,7 +48,7 @@
int u130_init();
long u130_get();
int u130_set();
void u130_set();
void u130_start();
#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
LD= ld
DEBUG=
CFLAGS= -O $(DEBUG)
all: sa.timer
sa.timer.o:
$(CC) -c $(DEBUG) sa.timer.c
sa.timer: $(OBJ)
$(LD) -s -o $@ $(OBJ)
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
LD= ld
DEBUG=
CFLAGS= -O $(DEBUG)
all: sa.timer
sa.timer.o:
$(CC) -c $(DEBUG) sa.timer.c
sa.timer: $(OBJ)
$(LD) -s -o $@ $(OBJ)
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
LD= ld
DEBUG=
CFLAGS= -O $(DEBUG)
all: sa.timer
sa.timer.o:
$(CC) -c $(DEBUG) sa.timer.c
sa.timer: $(OBJ)
$(LD) -s -o $@ $(OBJ)
chmod 400 $@

View File

@ -23,27 +23,29 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* 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 "rtc72421.h"
#include "timer.h"
extern long timegm();
extern struct tm *gmtime();
long timegm();
struct tm *gmtime();
main()
{
register long time;
register i,timer_found;
struct clock_type *t;
int a;
t = clock_devs;
#ifdef foo
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) {
printf("%s found\n",t->clock_name);
@ -52,6 +54,9 @@ main()
break;
}
}
#else
timer_found=1;
#endif
if (timer_found != 1) { /* Uhrmodul vorhanden ? */
printf("Timer not available\n");
exit(1);
@ -88,11 +93,8 @@ long time;
clktime = gmtime(&time);
#ifdef DEBUG
print_tm("outtime",clktime);
#endif
(clktime->tm_year) += 1900;
clktime->tm_mon++;
clktime->tm_year += 1900;
clktime->tm_mon ++;
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);
}
@ -101,7 +103,7 @@ settimer()
{
struct tm *clktime;
long time;
int i;
register i;
loop1:
printf("Enter new Date (MM/DD/YY) : ");
gets(estring, sizeof estring);
@ -132,20 +134,4 @@ loop2:
printf("Enter Return to start time : ");
gets(estring, 1);
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