OpenCores
URL https://opencores.org/ocsvn/s6soc/s6soc/trunk

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [sw/] [dev/] [rtcsim.c] - Diff between revs 15 and 21

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 15 Rev 21
Line 39... Line 39...
//
//
#include "rtcsim.h"
#include "rtcsim.h"
 
 
unsigned        rtcclock, rtcalarm, rtcdate;
unsigned        rtcclock, rtcalarm, rtcdate;
#ifdef  ZIPOS
#ifdef  ZIPOS
SEMAPHORE       SEMDATE, SEMCLOCK;
// SEMAPHORE    SEMDATE, SEMCLOCK;
#endif
#endif
 
 
unsigned        rtcnext(unsigned now) {
unsigned        rtcnext(unsigned now) {
        now = now+1;
        now = now+1;
        if ((now & 0x0f)>=0x0a) {
        if ((now & 0x0f)>=0x0a) {
Line 125... Line 125...
 
 
        return today;
        return today;
}
}
 
 
#ifdef  ZIPOS
#ifdef  ZIPOS
 
#include "board.h"
 
#include "../zipos/ktraps.h"
 
#include "../zipos/swint.h"
 
 
void rtctask(void) {
void rtctask(void) {
        rtcdate = 0x20160430;
        // IOSPACE *sys = (IOSPACE *)IOADDR;
        rtctime = 0;
        rtcdate = 0x20160504;
 
        rtcclock = 0;
        while(1) {
        while(1) {
                unsigned event = wait(SWINT_RTCPPS);
                unsigned event = wait(SWINT_CLOCK,-1);
                if (event&INT_TIMA) {
                if (event&SWINT_CLOCK) {
                        unsigned v, nextevent = SWINT_PPS;
                        unsigned v, nextevent = SWINT_PPS;
                        semget(SEMCLOCK);
                        semget(SEMCLOCK);
                        rtctime = v = rtcnext(rtctime);
                        rtcclock = v = rtcnext(rtcclock);
                        semput(SEMCLOCK);
                        semput(SEMCLOCK);
 
#ifdef  SWINT_ALARM
                        if (v == rtcalarm)
                        if (v == rtcalarm)
                                nextevent |= SWINT_ALARM;
                                nextevent |= SWINT_ALARM;
 
#endif
                        if (v == 0) {
                        if (v == 0) {
                                semget(SEMDATE);
                                semget(SEMDATE);
                                rtcdate = rtcdatenext(rtcdate);
                                rtcdate = rtcdatenext(rtcdate);
                                semput(SEMDATE);
                                semput(SEMDATE);
 
 
 
#ifdef  SWINT_PPD
                                nextevent |= SWINT_PPD;
                                nextevent |= SWINT_PPD;
                        } swthrow(nextevent);
#endif
 
                        } post(nextevent);
                }
                }
        }
        }
}
}
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2023 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.