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

Subversion Repositories s6soc

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

Show entire file | Details | Blame | View Log

Rev 21 Rev 45
Line 60... Line 60...
                                                now = 0;
                                                now = 0;
                                }
                                }
                        }
                        }
                }
                }
        }
        }
 
 
        return now;
        return now;
}
}
 
 
static const int days_per_month[] = {
static const char days_per_month[] = {
        31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
        31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
};
 
 
unsigned        rtcdatenext(unsigned today) {
unsigned        rtcdatenext(unsigned today) {
        int dy, mo;
        int dy, mo;
 
 
        dy = (today&0x0f)+((today>>4)&0x03)*10;
        dy = (today&0x0f)+((today>>4)&0x03)*10;
        mo = ((today>>8)&0x0f)+(today&0x0100)?10:0;
        mo = ((today>>8)&0x0f)+((today&0x0100)?10:0);
        dy = dy+1;
        dy = dy+1;
        if ((mo>12)||(dy > days_per_month[mo-1])) {
        if ((mo>12)||(dy > days_per_month[mo-1])) {
                if (mo == 2) {
                if (mo == 2) {
                        // If its a leap year
                        // If its a leap year
                        //      If it is divisible by four
                        //      If it is divisible by four
Line 120... Line 119...
        } else {
        } else {
                today += 1;
                today += 1;
                if ((today & 0x0f)>=0x0a)
                if ((today & 0x0f)>=0x0a)
                        today += 0x06;
                        today += 0x06;
        }
        }
 
 
        return today;
        return today;
}
}
 
 
#ifdef  ZIPOS
#ifdef  ZIPOS
#include "board.h"
#include "board.h"
#include "../zipos/ktraps.h"
#include "../zipos/ktraps.h"
#include "../zipos/swint.h"
#include "../zipos/swint.h"
 
 
void rtctask(void) {
void rtctask(void) {
        // IOSPACE *sys = (IOSPACE *)IOADDR;
        // IOSPACE *sys = (IOSPACE *)IOADDR;
        rtcdate = 0x20160504;
        rtcdate = 0x20170408;
        rtcclock = 0;
        rtcclock = 0;
        while(1) {
        while(1) {
                unsigned event = wait(SWINT_CLOCK,-1);
                unsigned event = wait(SWINT_CLOCK,-1);
                if (event&SWINT_CLOCK) {
                if (event&SWINT_CLOCK) {
                        unsigned v, nextevent = SWINT_PPS;
                        unsigned v, nextevent = SWINT_PPS;

powered by: WebSVN 2.1.0

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