better stuff - yeah!
This commit is contained in:
parent
19e6a9b716
commit
1f742c3b5c
|
|
@ -12,15 +12,15 @@ mv sa.timer /sa.timer
|
||||||
make clean
|
make clean
|
||||||
|
|
||||||
# Objekte bauen
|
# Objekte bauen
|
||||||
scc -c -O timer.c gmtime.c timegm.c u130.c rtc72421.c
|
scc -c -O timer.c gmtime.c timegm.c rtc72421.c u130.c
|
||||||
|
|
||||||
# LIB1 sichern
|
# LIB1 sichern
|
||||||
cp /usr/sys/sys/LIB1 /usr/sys/sys/LIB.orig
|
cp /usr/sys/sys/LIB1 /usr/sys/sys/LIB1.orig
|
||||||
|
|
||||||
# Objekte ins Kernel-Archiv legen
|
# Objekte ins Kernel-Archiv legen
|
||||||
|
# (Reihenfolge: lorder timer.o rtc72421.o u130.o gmtime.o timegm.o | tsort)
|
||||||
ar rv /usr/sys/sys/LIB1 timer.o rtc72421.o u130.o gmtime.o timegm.o
|
ar rv /usr/sys/sys/LIB1 timer.o rtc72421.o u130.o gmtime.o timegm.o
|
||||||
|
|
||||||
# Kernel generieren
|
# Kernel generieren
|
||||||
cd /usr/sys/conf ; make -f make.wega wega
|
cd /usr/sys/conf ; make -f make.wega wega
|
||||||
chmod 400 wega ; mv wega /wega.new
|
chmod 400 wega ; mv wega /wega.new
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.5 2009/08/16 11:11:00 olivleh1 Exp $
|
* $Id: rtc72421.c,v 1.6 2009/08/16 14:52:52 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
@ -75,20 +75,20 @@ long
|
||||||
r421get()
|
r421get()
|
||||||
{
|
{
|
||||||
long time = 0;
|
long time = 0;
|
||||||
struct tm *clktime;
|
int tm_year, tm_mday, tm_mon, tm_sec, tm_min, tm_hour;
|
||||||
|
|
||||||
clktime->tm_sec = rdbyte(R421SS1x,R421SSx1);
|
tm_sec = rdbyte(R421SS1x,R421SSx1);
|
||||||
clktime->tm_min = rdbyte(R421MI1x,R421MIx1);
|
tm_min = rdbyte(R421MI1x,R421MIx1);
|
||||||
clktime->tm_hour = rdbyte(R421HH1x,R421HHx1);
|
tm_hour = rdbyte(R421HH1x,R421HHx1);
|
||||||
clktime->tm_mday = rdbyte(R421DD1x,R421DDx1);
|
tm_mday = rdbyte(R421DD1x,R421DDx1);
|
||||||
clktime->tm_mon = rdbyte(R421MM1x,R421MMx1);
|
tm_mon = rdbyte(R421MM1x,R421MMx1);
|
||||||
clktime->tm_year = rdbyte(R421YY1x,R421YYx1);
|
tm_year = rdbyte(R421YY1x,R421YYx1);
|
||||||
|
|
||||||
if (clktime->tm_year < 70)
|
if (tm_year < 70)
|
||||||
clktime->tm_year+=100;
|
tm_year+=100;
|
||||||
clktime->tm_mon --;
|
tm_mon --;
|
||||||
|
|
||||||
time = timegm(clktime);
|
time = timegm(tm_year,tm_mon,tm_mday,tm_hour,tm_min,tm_sec);
|
||||||
|
|
||||||
return(time);
|
return(time);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,16 +23,19 @@
|
||||||
* 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.2 2009/08/12 19:27:31 olivleh1 Exp $
|
* $Id: timegm.c,v 1.3 2009/08/16 14:52:52 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
extern struct tm *gmtime();
|
|
||||||
|
|
||||||
long
|
long
|
||||||
timegm(clktime)
|
timegm(tm_year,tm_mon,tm_mday,tm_hour,tm_min,tm_sec)
|
||||||
struct tm *clktime;
|
register tm_year;
|
||||||
|
register tm_mon;
|
||||||
|
register tm_mday;
|
||||||
|
register tm_hour;
|
||||||
|
register tm_min;
|
||||||
|
register tm_sec;
|
||||||
{
|
{
|
||||||
register long time;
|
register long time;
|
||||||
register i;
|
register i;
|
||||||
|
|
@ -40,19 +43,19 @@ struct tm *clktime;
|
||||||
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
|
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
|
||||||
|
|
||||||
time = 0;
|
time = 0;
|
||||||
if (clktime->tm_mday > 31 || clktime->tm_mon > 12)
|
if (tm_mday > 31 || tm_mon > 12)
|
||||||
return(time);
|
return(time);
|
||||||
i = dmsize[clktime->tm_mon];
|
i = dmsize[tm_mon];
|
||||||
if (clktime->tm_year%4 == 0 && clktime->tm_mon > 2) i++;
|
if (tm_year%4 == 0 && tm_mon > 2) i++;
|
||||||
if (clktime->tm_year > 137) return(time);
|
if (tm_year > 137) return(time);
|
||||||
time = (clktime->tm_year-69)/4;
|
time = (tm_year-69)/4;
|
||||||
time += 365*(clktime->tm_year-70)+i;
|
time += 365*(tm_year-70)+i;
|
||||||
time += clktime->tm_mday - 1;
|
time += tm_mday - 1;
|
||||||
|
|
||||||
if (clktime->tm_sec > 59 || clktime->tm_min > 59 || clktime->tm_hour > 23)
|
if (tm_sec > 59 || tm_min > 59 || tm_hour > 23)
|
||||||
return(time);
|
return(time);
|
||||||
time = 24*time + clktime->tm_hour;
|
time = 24*time + tm_hour;
|
||||||
time = 60*time + clktime->tm_min;
|
time = 60*time + tm_min;
|
||||||
time = 60*time + clktime->tm_sec;
|
time = 60*time + tm_sec;
|
||||||
return(time);
|
return(time);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.4 2009/08/16 11:11:00 olivleh1 Exp $
|
* $Id: timer.h,v 1.5 2009/08/16 14:52:52 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TIMER_H
|
#ifndef TIMER_H
|
||||||
|
|
@ -42,8 +42,6 @@ struct clock_type {
|
||||||
void (*clock_fstart)();
|
void (*clock_fstart)();
|
||||||
};
|
};
|
||||||
|
|
||||||
char estring[20];
|
|
||||||
|
|
||||||
static struct clock_type clock_devs[] = {
|
static struct clock_type clock_devs[] = {
|
||||||
{ U130BASE, MSK_U130, STR_U130, 80, 119,
|
{ U130BASE, MSK_U130, STR_U130, 80, 119,
|
||||||
"RFT U130X RTC",
|
"RFT U130X RTC",
|
||||||
|
|
|
||||||
|
|
@ -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.10 2009/08/16 11:11:00 olivleh1 Exp $
|
* $Id: u130.c,v 1.11 2009/08/16 14:52:52 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
@ -32,8 +32,8 @@
|
||||||
int rdvalue();
|
int rdvalue();
|
||||||
int invalue();
|
int invalue();
|
||||||
void outvalue();
|
void outvalue();
|
||||||
long timegm();
|
extern long timegm();
|
||||||
struct tm *gmtime();
|
extern struct tm *gmtime();
|
||||||
|
|
||||||
int
|
int
|
||||||
u130init()
|
u130init()
|
||||||
|
|
@ -109,26 +109,26 @@ long
|
||||||
u130get()
|
u130get()
|
||||||
{
|
{
|
||||||
long time;
|
long time;
|
||||||
struct tm *clktime;
|
int tm_year, tm_mday, tm_mon, tm_sec, tm_min, tm_hour;
|
||||||
|
|
||||||
outvalue(0x02); /* Umschalten auf Datum */
|
outvalue(0x02); /* Umschalten auf Datum */
|
||||||
clktime->tm_year = rdvalue(U130YYx1);
|
tm_year = rdvalue(U130YYx1);
|
||||||
if (clktime->tm_year < 70)
|
if (tm_year < 70)
|
||||||
clktime->tm_year+=100;
|
tm_year+=100;
|
||||||
clktime->tm_mday = rdvalue(U130DDx1);
|
tm_mday = rdvalue(U130DDx1);
|
||||||
clktime->tm_mon = rdvalue(U130MMx1);
|
tm_mon = rdvalue(U130MMx1);
|
||||||
clktime->tm_mon --;
|
tm_mon --;
|
||||||
outvalue(0x00);
|
outvalue(0x00);
|
||||||
clktime->tm_sec = inb(U130MM1x) & 0x28; /* Umschalten auf Zeit */
|
tm_sec = inb(U130MM1x) & 0x28; /* Umschalten auf Zeit */
|
||||||
if (clktime->tm_sec == 0x08 || clktime->tm_sec == 0x20) {
|
if (tm_sec == 0x08 || tm_sec == 0x20) {
|
||||||
outvalue(0x02);
|
outvalue(0x02);
|
||||||
outvalue(0x00);
|
outvalue(0x00);
|
||||||
}
|
}
|
||||||
while ((clktime->tm_sec = rdvalue(U130SSx1)) == 59);
|
while ((tm_sec = rdvalue(U130SSx1)) == 59);
|
||||||
clktime->tm_min = rdvalue(U130MIx1);
|
tm_min = rdvalue(U130MIx1);
|
||||||
clktime->tm_hour = rdvalue(U130HHx1);
|
tm_hour = rdvalue(U130HHx1);
|
||||||
|
|
||||||
time = timegm(clktime);
|
time = timegm(tm_year,tm_mon,tm_mday,tm_hour,tm_min,tm_sec);
|
||||||
return(time);
|
return(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
OBJ= sa.timer.o libb.a u130.o rtc72421.o gmtime.o timegm.o
|
OBJ= sa.timer.o u130.o rtc72421.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: $(OBJ)
|
sa.timer: $(OBJ) libb.a
|
||||||
$(LD) -s -o $@ $(OBJ)
|
$(LD) -s -o $@ $(OBJ) libb.a
|
||||||
chmod 400 $@
|
chmod 400 $@
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJ) timer.o sa.timer
|
rm -f $(OBJ) timer.o sa.timer
|
||||||
|
|
|
||||||
|
|
@ -23,105 +23,19 @@
|
||||||
* 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.c,v 1.2 2009/08/16 11:49:51 olivleh1 Exp $
|
* $Id: timer.c,v 1.3 2009/08/16 14:52:52 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "rtc72421.h"
|
#include "rtc72421.h"
|
||||||
#include "u130.h"
|
#include "u130.h"
|
||||||
|
#include "timer.h"
|
||||||
void wrnibble();
|
|
||||||
void wrbyte();
|
|
||||||
int rdnibble();
|
|
||||||
int rdbyte();
|
|
||||||
int rdvalue();
|
|
||||||
int invalue();
|
|
||||||
void outvalue();
|
|
||||||
|
|
||||||
static int dmsize[] = /* Tage/Monat (kumulierend) */
|
|
||||||
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
|
|
||||||
|
|
||||||
long
|
|
||||||
r421time()
|
|
||||||
{
|
|
||||||
register long time;
|
|
||||||
register d1, d2, d3;
|
|
||||||
register i;
|
|
||||||
|
|
||||||
time = 0;
|
|
||||||
r421init();
|
|
||||||
|
|
||||||
d1 = rdbyte(R421YY1x,R421YYx1); /* Jahr */
|
|
||||||
d2 = rdbyte(R421DD1x,R421DDx1); /* Tag */
|
|
||||||
d3 = rdbyte(R421MM1x,R421MMx1); /* Monat */
|
|
||||||
if (d1 > 100 || d2 > 31 || d3 > 12)
|
|
||||||
return(time);
|
|
||||||
i = dmsize[d3-1];
|
|
||||||
if (d1%4 == 0 && d3 > 2) i++;
|
|
||||||
if (d1 < 70) d1 += 100;
|
|
||||||
if (d1 > 137) return(time);
|
|
||||||
time = (d1-69)/4;
|
|
||||||
time += 365*(d1-70)+i;
|
|
||||||
time += d2 - 1;
|
|
||||||
|
|
||||||
while ((d1 = rdbyte(R421SS1x,R421SSx1)) == 59)
|
|
||||||
; /* Sekunden */
|
|
||||||
d2 = rdbyte(R421MI1x,R421MIx1); /* Minuten */
|
|
||||||
d3 = rdbyte(R421HH1x,R421HHx1); /* Stunden */
|
|
||||||
if (d1 > 59 || d2 > 59 || d3 > 23)
|
|
||||||
return(time);
|
|
||||||
time = 24*time + d3;
|
|
||||||
time = 60*time + d2;
|
|
||||||
time = 60*time + d1;
|
|
||||||
return(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
long
|
|
||||||
u130time()
|
|
||||||
{
|
|
||||||
register long time;
|
|
||||||
register d1, d2, d3;
|
|
||||||
register i;
|
|
||||||
|
|
||||||
time = 0;
|
|
||||||
if (inb(0xfef1) != 0xbf) /* Uhrmodul vorhanden ? */
|
|
||||||
return(time);
|
|
||||||
outvalue(0x02); /* Umschalten auf Datum */
|
|
||||||
d1 = rdvalue(0xfef5); /* Jahr */
|
|
||||||
d2 = rdvalue(0xfef9); /* Tag */
|
|
||||||
d3 = rdvalue(0xfefd); /* Monat */
|
|
||||||
outvalue(0x00);
|
|
||||||
if (d1 > 100 || d2 > 31 || d3 > 12)
|
|
||||||
return(time);
|
|
||||||
i = dmsize[d3-1];
|
|
||||||
if (d1%4 == 0 && d3 > 2) i++;
|
|
||||||
if (d1 < 70) d1 += 100;
|
|
||||||
if (d1 > 137) return(time);
|
|
||||||
time = (d1-69)/4;
|
|
||||||
time += 365*(d1-70)+i;
|
|
||||||
time += d2 - 1;
|
|
||||||
|
|
||||||
d1 = inb(0xfeff) & 0x28; /* Umschalten auf Zeit */
|
|
||||||
if (d1 == 0x08 || d1 == 0x20) {
|
|
||||||
outvalue(0x02);
|
|
||||||
outvalue(0x00);
|
|
||||||
}
|
|
||||||
while ((d1 = rdvalue(0xfef5)) == 59)
|
|
||||||
; /* Sekunden */
|
|
||||||
d2 = rdvalue(0xfef9); /* Minuten */
|
|
||||||
d3 = rdvalue(0xfefd); /* Stunden */
|
|
||||||
if (d1 > 59 || d2 > 59 || d3 > 23)
|
|
||||||
return(time);
|
|
||||||
time = 24*time + d3;
|
|
||||||
time = 60*time + d2;
|
|
||||||
time = 60*time + d1;
|
|
||||||
return(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
long
|
long
|
||||||
gettime()
|
gettime()
|
||||||
{
|
{
|
||||||
|
#ifdef foo
|
||||||
register long time;
|
register long time;
|
||||||
int a,b;
|
int a,b;
|
||||||
|
|
||||||
|
|
@ -130,138 +44,34 @@ gettime()
|
||||||
b = STR_U130;
|
b = STR_U130;
|
||||||
if( a == b) {
|
if( a == b) {
|
||||||
printf("RFT U130X RTC found\n");
|
printf("RFT U130X RTC found\n");
|
||||||
time = u130time();
|
time = u130get();
|
||||||
} else {
|
} else {
|
||||||
a = inb(R421BASE)&~MSK_R421;
|
a = inb(R421BASE)&~MSK_R421;
|
||||||
b = STR_R421;
|
b = STR_R421;
|
||||||
if( a == b) {
|
if( a == b) {
|
||||||
printf("Seiko Epson RTC-72421\n");
|
printf("Seiko Epson RTC-72421\n");
|
||||||
time = r421time();
|
time = r421get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
register long time;
|
||||||
|
register i;
|
||||||
|
struct clock_type *t;
|
||||||
|
int a,b;
|
||||||
|
|
||||||
|
t = clock_devs;
|
||||||
|
|
||||||
|
for( i = 0 ; i < sizeof(clock_devs) / sizeof(clock_devs[0]); i++, t++) {
|
||||||
|
a = inb(t->clock_addr)&~t->clock_det_msk;
|
||||||
|
b = t->clock_det_str;
|
||||||
|
if(a == b) {
|
||||||
|
printf("%s found\n",t->clock_name);
|
||||||
|
t->clock_finit();
|
||||||
|
time = t->clock_fget();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(time);
|
return(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
r421init()
|
|
||||||
{
|
|
||||||
outb(R421REGD,R421IRQF);
|
|
||||||
outb(R421REGE,R421CLR);
|
|
||||||
outb(R421REGF,R4212412);
|
|
||||||
}
|
|
||||||
|
|
||||||
r421bsy()
|
|
||||||
{
|
|
||||||
busy:
|
|
||||||
outb(R421REGD,R421HOLD);
|
|
||||||
if( rdnibble(R421REGD) & R421BUSY ) {
|
|
||||||
outb(R421REGD,R421CLR);
|
|
||||||
goto busy;
|
|
||||||
}
|
|
||||||
outb(R421REGD,R421CLR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
wrnibble(addr,nibble)
|
|
||||||
unsigned addr;
|
|
||||||
int nibble;
|
|
||||||
{
|
|
||||||
outb(addr, nibble);
|
|
||||||
}
|
|
||||||
int
|
|
||||||
rdnibble(addr)
|
|
||||||
unsigned addr;
|
|
||||||
{
|
|
||||||
return (inb(addr)&~0xf0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
wrbyte(addr1,addr2,byte)
|
|
||||||
unsigned addr1;
|
|
||||||
unsigned addr2;
|
|
||||||
int byte;
|
|
||||||
{
|
|
||||||
r421bsy();
|
|
||||||
wrnibble(addr1,byte/10);
|
|
||||||
r421bsy();
|
|
||||||
wrnibble(addr2,byte%10);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
rdbyte(addr1,addr2)
|
|
||||||
unsigned addr1;
|
|
||||||
unsigned addr2;
|
|
||||||
{
|
|
||||||
register a,b;
|
|
||||||
|
|
||||||
r421bsy();
|
|
||||||
a=rdnibble(addr2);
|
|
||||||
r421bsy();
|
|
||||||
b=rdnibble(addr1);
|
|
||||||
return(a + b*10);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
outvalue(t)
|
|
||||||
register t;
|
|
||||||
{
|
|
||||||
outb(U130BASE, t);
|
|
||||||
t = 10000;
|
|
||||||
while (t--)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
invalue(addr, flag)
|
|
||||||
register addr;
|
|
||||||
register flag;
|
|
||||||
{
|
|
||||||
register seg7, takt;
|
|
||||||
|
|
||||||
seg7 = inb(addr);
|
|
||||||
if (seg7 != inb(addr))
|
|
||||||
seg7 = inb(addr);
|
|
||||||
takt = seg7 & 0x80; /* nur gueltig bei 6. Stelle */
|
|
||||||
if (seg7 & 0x20)
|
|
||||||
seg7 = ~seg7;
|
|
||||||
if (addr == U130MM1x) /* 6.Stelle */
|
|
||||||
seg7 &= 0x07;
|
|
||||||
seg7 &= 0x1f;
|
|
||||||
if (seg7 == 0x0f)
|
|
||||||
return(0);
|
|
||||||
if (seg7 == 0x00) {
|
|
||||||
if (flag == 0)
|
|
||||||
return(0);
|
|
||||||
if (addr == U130MM1x && takt)
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
if (seg7 == 0x02)
|
|
||||||
return(1);
|
|
||||||
if (seg7 == 0x17 || seg7 == 0x05)
|
|
||||||
return(2);
|
|
||||||
if (seg7 == 0x13)
|
|
||||||
return(3);
|
|
||||||
if (seg7 == 0x1a)
|
|
||||||
return(4);
|
|
||||||
if (seg7 == 0x19)
|
|
||||||
return(5);
|
|
||||||
if (seg7 == 0x1d)
|
|
||||||
return(6);
|
|
||||||
if (seg7 == 0x03)
|
|
||||||
return(7);
|
|
||||||
if (seg7 == 0x1f)
|
|
||||||
return(8);
|
|
||||||
if (seg7 == 0x1b)
|
|
||||||
return(9);
|
|
||||||
return(0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
rdvalue(addr)
|
|
||||||
unsigned addr;
|
|
||||||
{
|
|
||||||
return(invalue(addr,0) + invalue(addr+2,0)*10);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
OBJ= sa.timer.o libb.a u130.o rtc72421.o gmtime.o timegm.o
|
OBJ= sa.timer.o u130.o rtc72421.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: $(OBJ)
|
sa.timer: $(OBJ) libb.a
|
||||||
$(LD) -s -o $@ $(OBJ)
|
$(LD) -s -o $@ $(OBJ) libb.a
|
||||||
chmod 400 $@
|
chmod 400 $@
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJ) timer.o sa.timer
|
rm -f $(OBJ) timer.o sa.timer
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
OBJ= sa.timer.o libb.a u130.o rtc72421.o gmtime.o timegm.o
|
OBJ= sa.timer.o u130.o rtc72421.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: $(OBJ)
|
sa.timer: $(OBJ) libb.a
|
||||||
$(LD) -s -o $@ $(OBJ)
|
$(LD) -s -o $@ $(OBJ) libb.a
|
||||||
chmod 400 $@
|
chmod 400 $@
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJ) timer.o sa.timer
|
rm -f $(OBJ) timer.o sa.timer
|
||||||
|
|
|
||||||
|
|
@ -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.11 2009/08/16 11:11:00 olivleh1 Exp $
|
* $Id: sa.timer.c,v 1.12 2009/08/16 14:52:52 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -32,8 +32,10 @@
|
||||||
#include "rtc72421.h"
|
#include "rtc72421.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
long timegm();
|
extern long timegm();
|
||||||
struct tm *gmtime();
|
extern struct tm *gmtime();
|
||||||
|
char estring[20];
|
||||||
|
|
||||||
|
|
||||||
int clock_min_year;
|
int clock_min_year;
|
||||||
int clock_max_year;
|
int clock_max_year;
|
||||||
|
|
@ -127,20 +129,25 @@ long time;
|
||||||
{
|
{
|
||||||
struct tm *clktime;
|
struct tm *clktime;
|
||||||
long time2;
|
long time2;
|
||||||
|
int tm_year, tm_mday, tm_mon, tm_sec, tm_min, tm_hour;
|
||||||
|
|
||||||
clktime = gmtime(&time);
|
clktime = gmtime(&time);
|
||||||
loop1:
|
loop1:
|
||||||
printf("Enter new Date (MM/DD/YY) : ");
|
printf("Enter new Date (MM/DD/YY) : ");
|
||||||
gets(estring, sizeof estring);
|
gets(estring, sizeof estring);
|
||||||
if (estring[0] == 0)
|
if (estring[0] == 0) {
|
||||||
|
tm_mon = clktime->tm_mon;
|
||||||
|
tm_mday = clktime->tm_mday;
|
||||||
|
tm_year = clktime->tm_year;
|
||||||
goto loop2;
|
goto loop2;
|
||||||
clktime->tm_mon = getdat(1)-1;
|
}
|
||||||
clktime->tm_mday = getdat(2);
|
tm_mon = getdat(1)-1;
|
||||||
clktime->tm_year = getdat(3);
|
tm_mday = getdat(2);
|
||||||
if (clktime->tm_year < 70 )
|
tm_year = getdat(3);
|
||||||
clktime->tm_year += 100;
|
if (tm_year < 70 )
|
||||||
|
tm_year += 100;
|
||||||
|
|
||||||
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)
|
if (tm_mon<0 || tm_mon>11 || tm_mday<1 || tm_mday>31 || tm_year<clock_min_year || tm_year>clock_max_year)
|
||||||
goto loop1;
|
goto loop1;
|
||||||
|
|
||||||
loop2:
|
loop2:
|
||||||
|
|
@ -148,14 +155,14 @@ loop2:
|
||||||
gets(estring, sizeof estring);
|
gets(estring, sizeof estring);
|
||||||
if (estring[0] == 0)
|
if (estring[0] == 0)
|
||||||
return;
|
return;
|
||||||
clktime->tm_hour = getdat(1);
|
tm_hour = getdat(1);
|
||||||
clktime->tm_min = getdat(2);
|
tm_min = getdat(2);
|
||||||
clktime->tm_sec = 0;
|
tm_sec = 0;
|
||||||
if (clktime->tm_min<0 || clktime->tm_min>59 || clktime->tm_hour<0 || clktime->tm_hour>23)
|
if (tm_min<0 || tm_min>59 || tm_hour<0 || tm_hour>23)
|
||||||
goto loop2;
|
goto loop2;
|
||||||
|
|
||||||
|
|
||||||
time2 = timegm(clktime);
|
time2 = timegm(tm_year,tm_mon,tm_mday,tm_hour,tm_min,tm_sec);
|
||||||
clock_fset(time2);
|
clock_fset(time2);
|
||||||
printf("Enter Return to start time : ");
|
printf("Enter Return to start time : ");
|
||||||
gets(estring, 1);
|
gets(estring, 1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue