update
This commit is contained in:
parent
48ddc0fcff
commit
77313cae4b
|
|
@ -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.1 2009/08/07 13:53:20 olivleh1 Exp $
|
||||
* $Id: gmtime.c,v 1.2 2009/08/07 20:02:59 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
#define dysize(A) (((A)%4)? 365: 366)
|
||||
|
|
@ -36,7 +36,7 @@ static int dmsize[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
|||
|
||||
struct tm *
|
||||
gmtime(tim)
|
||||
const long *tim;
|
||||
long *tim;
|
||||
{
|
||||
register int d0, d1;
|
||||
long hms, day;
|
||||
|
|
|
|||
|
|
@ -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.1 2009/08/07 13:53:20 olivleh1 Exp $
|
||||
* $Id: rtc72421.c,v 1.2 2009/08/07 20:02:59 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
|
@ -37,6 +37,7 @@ extern long timegm();
|
|||
extern struct tm *gmtime();
|
||||
|
||||
|
||||
#ifdef NOTYET
|
||||
int
|
||||
rtc72421_init()
|
||||
{
|
||||
|
|
@ -111,3 +112,4 @@ unsigned addr2;
|
|||
{
|
||||
return(rdnibble(addr1) + rdnibble(addr2)*10);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: rtc72421.h,v 1.1 2009/08/07 13:53:20 olivleh1 Exp $
|
||||
* $Id: rtc72421.h,v 1.2 2009/08/07 20:02:59 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
#ifndef R421_H
|
||||
#define R421_H 1
|
||||
|
||||
#define STR_R421 0xc0
|
||||
#define STR_R421 0xc
|
||||
#define MSK_R421 0xf0
|
||||
|
||||
#define R421BASE 0xfde1 /* base address */
|
||||
#define R421YYx1 0xfdf5 /* 1-year digit register */
|
||||
|
|
|
|||
|
|
@ -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.2 2009/08/07 13:55:55 olivleh1 Exp $
|
||||
* $Id: u130.c,v 1.3 2009/08/07 20:02:59 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
|
@ -115,8 +115,11 @@ u130_get()
|
|||
struct tm *clktime;
|
||||
outvalue(0x02); /* Umschalten auf Datum */
|
||||
clktime->tm_year = rdvalue(U130YYx1);
|
||||
if (clktime->tm_year < 70)
|
||||
clktime->tm_year+=100;
|
||||
clktime->tm_mday = rdvalue(U130DDx1);
|
||||
clktime->tm_mon = rdvalue(U130MMx1);
|
||||
clktime->tm_mon --;
|
||||
outvalue(0x00);
|
||||
clktime->tm_sec = inb(U130MM1x) & 0x28; /* Umschalten auf Zeit */
|
||||
if (clktime->tm_sec == 0x08 || clktime->tm_sec == 0x20) {
|
||||
|
|
@ -126,7 +129,15 @@ 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);
|
||||
|
||||
return(time);
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: u130.h,v 1.1 2009/08/07 13:53:20 olivleh1 Exp $
|
||||
* $Id: u130.h,v 1.2 2009/08/07 20:02:59 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
#ifndef U130_H
|
||||
#define U130_H 1
|
||||
|
||||
#define STR_U130 0xbf
|
||||
#define MSK_U130 0x00
|
||||
|
||||
#define U130BASE 0xfef1 /* base address */
|
||||
#define U130YYx1 0xfef5 /* 1-year digit register */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
OBJ= sa.timer.o u130.o rtc72421.o gmtime.o timegm.o libb.a
|
||||
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 $@
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
OBJ= sa.timer.o u130.o rtc72421.o gmtime.o timegm.o libb.a
|
||||
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 $@
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
OBJ= sa.timer.o u130.o rtc72421.o gmtime.o timegm.o libb.a
|
||||
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 $@
|
||||
|
|
@ -23,25 +23,36 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: sa.timer.c,v 1.1 2009/08/07 13:53:20 olivleh1 Exp $
|
||||
* $Id: sa.timer.c,v 1.2 2009/08/07 20:02:59 olivleh1 Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "u130.h"
|
||||
#include "rtc72421.h"
|
||||
#include "timer.h"
|
||||
|
||||
extern long timegm();
|
||||
extern struct tm *gmtime();
|
||||
|
||||
char estring[20];
|
||||
|
||||
main()
|
||||
{
|
||||
register long time;
|
||||
register i,timer_found;
|
||||
struct clock_type *t;
|
||||
int a;
|
||||
|
||||
if (inb(U130BASE) != STR_U130) { /* Uhrmodul vorhanden ? */
|
||||
t = clock_devs;
|
||||
|
||||
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);
|
||||
timer_found=1;
|
||||
/* function pointers here */
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (timer_found != 1) { /* Uhrmodul vorhanden ? */
|
||||
printf("Timer not available\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -77,9 +88,11 @@ long time;
|
|||
|
||||
clktime = gmtime(&time);
|
||||
|
||||
clktime->tm_year += 1900;
|
||||
#ifdef DEBUG
|
||||
print_tm("outtime",clktime);
|
||||
#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("Time is: %d:%d:%d GMT\n", clktime->tm_hour, clktime->tm_min, clktime->tm_sec);
|
||||
}
|
||||
|
|
@ -100,7 +113,7 @@ loop1:
|
|||
if (clktime->tm_year < 70 )
|
||||
clktime->tm_year += 100;
|
||||
|
||||
if (clktime->tm_mon<1 || clktime->tm_mon>12 || 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)
|
||||
goto loop1;
|
||||
|
||||
loop2:
|
||||
|
|
@ -121,3 +134,18 @@ loop2:
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue