works - pressign enter to re-take the old date in settimer() does not work
yet
This commit is contained in:
parent
d2f60698cf
commit
c1badf86ea
|
|
@ -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.2 2009/08/07 20:02:59 olivleh1 Exp $
|
* $Id: rtc72421.c,v 1.3 2009/08/11 19:18:03 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
@ -37,7 +37,6 @@ extern long timegm();
|
||||||
extern struct tm *gmtime();
|
extern struct tm *gmtime();
|
||||||
|
|
||||||
|
|
||||||
#ifdef NOTYET
|
|
||||||
int
|
int
|
||||||
rtc72421_init()
|
rtc72421_init()
|
||||||
{
|
{
|
||||||
|
|
@ -45,7 +44,7 @@ rtc72421_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
void
|
||||||
rtc72421_set(time)
|
rtc72421_set(time)
|
||||||
long time;
|
long time;
|
||||||
{
|
{
|
||||||
|
|
@ -55,8 +54,6 @@ long time;
|
||||||
if(clktime->tm_year > 100)
|
if(clktime->tm_year > 100)
|
||||||
clktime->tm_year -= 100;
|
clktime->tm_year -= 100;
|
||||||
clktime->tm_mon++;
|
clktime->tm_mon++;
|
||||||
|
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -112,4 +109,3 @@ unsigned addr2;
|
||||||
{
|
{
|
||||||
return(rdnibble(addr1) + rdnibble(addr2)*10);
|
return(rdnibble(addr1) + rdnibble(addr2)*10);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -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.2 2009/08/07 20:02:59 olivleh1 Exp $
|
* $Id: rtc72421.h,v 1.3 2009/08/11 19:18:03 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef R421_H
|
#ifndef R421_H
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
int rtc72421_init();
|
int rtc72421_init();
|
||||||
long rtc72421_get();
|
long rtc72421_get();
|
||||||
int rtc72421_set();
|
void rtc72421_set();
|
||||||
void rtc72421_start();
|
void rtc72421_start();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -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.1 2009/08/07 20:08:59 olivleh1 Exp $
|
* $Id: timer.h,v 1.2 2009/08/11 19:18:03 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TIMER_H
|
#ifndef TIMER_H
|
||||||
|
|
@ -34,15 +34,23 @@ struct clock_type {
|
||||||
int clock_det_msk;
|
int clock_det_msk;
|
||||||
int clock_det_str;
|
int clock_det_str;
|
||||||
char *clock_name;
|
char *clock_name;
|
||||||
|
int (*time_init)();
|
||||||
|
long (*time_get)();
|
||||||
|
void (*time_set)();
|
||||||
|
void (*time_start)();
|
||||||
};
|
};
|
||||||
|
|
||||||
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,
|
||||||
"RFT U130X RTC" },
|
"RFT U130X RTC",
|
||||||
{ R421BASE, MSK_R421, STR_R421,
|
u130_init, u130_get, u130_set, u130_start
|
||||||
"Seiko Epson RTC-72421" },
|
},
|
||||||
|
{ R421BASE, MSK_R421, STR_R421,
|
||||||
|
"Seiko Epson RTC-72421",
|
||||||
|
rtc72421_init, rtc72421_get, rtc72421_set, rtc72421_start
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -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.5 2009/08/11 05:14:26 olivleh1 Exp $
|
* $Id: u130.c,v 1.6 2009/08/11 19:18:03 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
@ -113,6 +113,8 @@ u130_get()
|
||||||
{
|
{
|
||||||
long time;
|
long time;
|
||||||
struct tm *clktime;
|
struct tm *clktime;
|
||||||
|
long time1,time2;
|
||||||
|
|
||||||
outvalue(0x02); /* Umschalten auf Datum */
|
outvalue(0x02); /* Umschalten auf Datum */
|
||||||
clktime->tm_year = rdvalue(U130YYx1);
|
clktime->tm_year = rdvalue(U130YYx1);
|
||||||
if (clktime->tm_year < 70)
|
if (clktime->tm_year < 70)
|
||||||
|
|
@ -131,6 +133,9 @@ u130_get()
|
||||||
clktime->tm_hour = rdvalue(U130HHx1);
|
clktime->tm_hour = rdvalue(U130HHx1);
|
||||||
|
|
||||||
time = timegm(clktime);
|
time = timegm(clktime);
|
||||||
|
time1 = time/100000L;
|
||||||
|
time2 = time%100000L;
|
||||||
|
printf("time: %d-%d-%d-%d\n",(int)(time1/100L),(int)(time1%100L),(int)(time2/100L),(int)(time2%100L));
|
||||||
return(time);
|
return(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
OBJ= sa.timer.o libb.a u130.o gmtime.o timegm.o
|
OBJ= sa.timer.o libb.a u130.o rtc72421.o gmtime.o timegm.o
|
||||||
CC= cc
|
CC= cc
|
||||||
LD= ld
|
LD= ld
|
||||||
DEBUG=
|
DEBUG=
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
OBJ= sa.timer.o libb.a u130.o gmtime.o timegm.o
|
OBJ= sa.timer.o libb.a u130.o rtc72421.o gmtime.o timegm.o
|
||||||
CC= cc
|
CC= cc
|
||||||
LD= ld
|
LD= ld
|
||||||
DEBUG=
|
DEBUG=
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
OBJ= sa.timer.o libb.a u130.o gmtime.o timegm.o
|
OBJ= sa.timer.o libb.a u130.o rtc72421.o gmtime.o timegm.o
|
||||||
CC= cc
|
CC= cc
|
||||||
LD= ld
|
LD= ld
|
||||||
DEBUG=
|
DEBUG=
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,10 @@
|
||||||
* 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.4 2009/08/11 05:14:26 olivleh1 Exp $
|
* $Id: sa.timer.c,v 1.5 2009/08/11 19:18:03 olivleh1 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
char estring[20];
|
|
||||||
long u130_get();
|
|
||||||
|
|
||||||
#define dysize(A) (((A)%4)? 365: 366)
|
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include "u130.h"
|
#include "u130.h"
|
||||||
#include "rtc72421.h"
|
#include "rtc72421.h"
|
||||||
|
|
@ -38,35 +34,55 @@ long u130_get();
|
||||||
|
|
||||||
long timegm();
|
long timegm();
|
||||||
struct tm *gmtime();
|
struct tm *gmtime();
|
||||||
|
long u130_get();
|
||||||
|
|
||||||
|
int (*time_init)();
|
||||||
|
long (*time_get)();
|
||||||
|
void (*time_set)();
|
||||||
|
void (*time_start)();
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
long time;
|
register long time;
|
||||||
register i,timer_found;
|
register i;
|
||||||
struct clock_type *t;
|
struct clock_type *t;
|
||||||
|
int a,b;
|
||||||
|
long time1,time2;
|
||||||
|
|
||||||
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) {
|
a = inb(t->clock_addr)&~t->clock_det_msk;
|
||||||
|
b = t->clock_det_str;
|
||||||
|
if(a == b) {
|
||||||
printf("%s found\n",t->clock_name);
|
printf("%s found\n",t->clock_name);
|
||||||
timer_found=1;
|
time_init = t->time_init;
|
||||||
/* function pointers here */
|
time_get = t->time_get;
|
||||||
|
time_set = t->time_set;
|
||||||
|
time_start = t->time_start;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
timer_found=1;
|
if (time_init > 0) { /* function pointer assigned? */
|
||||||
#endif
|
time_init(); /* init RTC */
|
||||||
if (timer_found != 1) { /* Uhrmodul vorhanden ? */
|
time = time_get(); /* Uhrenmodul lesen */
|
||||||
|
time1 = time/100000L;
|
||||||
|
time2 = time%100000L;
|
||||||
|
printf("time: %d-%d-%d-%d\n",(int)(time1/100L),(int)(time1%100L),(int)(time2/100L),(int)(time2%100L));
|
||||||
|
outtime(time); /* Datum/Zeit ausgeben */
|
||||||
|
time1 = time/100000L;
|
||||||
|
time2 = time%100000L;
|
||||||
|
printf("time: %d-%d-%d-%d\n",(int)(time1/100L),(int)(time1%100L),(int)(time2/100L),(int)(time2%100L));
|
||||||
|
settimer(time); /* Uhrenmodul neu programmieren */
|
||||||
|
time = time_get(); /* Uhrenmodul lesen */
|
||||||
|
outtime(time); /* Datum/Zeit ausgeben */
|
||||||
|
exit(0);
|
||||||
|
} else {
|
||||||
printf("Timer not available\n");
|
printf("Timer not available\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
time = u130_get(); /* Uhrenmodul lesen */
|
|
||||||
outtime(time); /* Datum/Zeit ausgeben */
|
|
||||||
settimer(); /* Uhrenmodul neu programmieren */
|
|
||||||
time = u130_get(); /* Uhrenmodul lesen */
|
|
||||||
outtime(time); /* Datum/Zeit ausgeben */
|
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getdat(k)
|
getdat(k)
|
||||||
|
|
@ -102,11 +118,19 @@ long time;
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
settimer()
|
settimer(time)
|
||||||
|
long time;
|
||||||
{
|
{
|
||||||
struct tm *clktime;
|
struct tm *clktime;
|
||||||
long time;
|
long time,time2;
|
||||||
register i;
|
register i;
|
||||||
|
|
||||||
|
time2=time;
|
||||||
|
|
||||||
|
clktime = gmtime(&time2);
|
||||||
|
if(clktime->tm_year > 100)
|
||||||
|
clktime->tm_year -= 100;
|
||||||
|
clktime->tm_mon ++;
|
||||||
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,9 +156,17 @@ loop2:
|
||||||
if (clktime->tm_min<0 || clktime->tm_min>59 || clktime->tm_hour<0 || clktime->tm_hour>23)
|
if (clktime->tm_min<0 || clktime->tm_min>59 || clktime->tm_hour<0 || clktime->tm_hour>23)
|
||||||
goto loop2;
|
goto loop2;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
time = 0;
|
||||||
time = timegm(clktime);
|
time = timegm(clktime);
|
||||||
u130_set(time);
|
time_set(time);
|
||||||
printf("Enter Return to start time : ");
|
printf("Enter Return to start time : ");
|
||||||
gets(estring, 1);
|
gets(estring, 1);
|
||||||
u130_start();
|
time_start();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue