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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [sw/] [wbsettime.cpp] - Diff between revs 5 and 7

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

Rev 5 Rev 7
Line 3... Line 3...
// Filename:    wbsettime.cpp
// Filename:    wbsettime.cpp
//
//
// Project:     XuLA2 board
// Project:     XuLA2 board
//
//
// Purpose:     To give a user access, via a command line program, to set the
// Purpose:     To give a user access, via a command line program, to set the
//              real time clock within the FPGA.  
//              real time clock within the FPGA.  Note, however, that the RTC
 
//      clock device only sets the subseconds field when you program it at the
 
//      top of a minute.  This program, therefore, will wait 'til the top of a 
 
//      minute to set the clock.  It can be annoying, but ... it works.
//
//
//
//
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
Line 52... Line 55...
        m_fpga->kill();
        m_fpga->kill();
        exit(0);
        exit(0);
}
}
 
 
int main(int argc, char **argv) {
int main(int argc, char **argv) {
        DEVBUS::BUSW    v;
        bool    set_time = true;
 
 
        bool    set_time = true, read_hack = false;
 
 
 
        FPGAOPEN(m_fpga);
        FPGAOPEN(m_fpga);
 
 
        signal(SIGSTOP, closeup);
        signal(SIGSTOP, closeup);
        signal(SIGHUP, closeup);
        signal(SIGHUP, closeup);
Line 89... Line 90...
                                // tmp->tm_sec, 60-tmp->tm_sec);
                                // tmp->tm_sec, 60-tmp->tm_sec);
                        if (tmp->tm_sec < 58)
                        if (tmp->tm_sec < 58)
                                sleepv = 59 - tmp->tm_sec;
                                sleepv = 59 - tmp->tm_sec;
                        then += 60 - tmp->tm_sec;
                        then += 60 - tmp->tm_sec;
                        tmp = localtime(&then);
                        tmp = localtime(&then);
                        // printf("Sleeping %d seconds (THEN->SEC = %d)\n", sleepv, tmp->tm_sec);
                        printf("Sleeping for %d seconds, so as to set time at the top of the minute\n", sleepv);
                }
                }
 
 
                // printf("ORIGINAL : %02d:%02d:%02d\n", tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
                // printf("ORIGINAL : %02d:%02d:%02d\n", tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
                // Seconds
                // Seconds
                clockword |= (((tmp->tm_sec)%10)&0x0f);
                clockword |= (((tmp->tm_sec)%10)&0x0f);
Line 128... Line 129...
                printf("Date set to %08x\n", dateword);
                printf("Date set to %08x\n", dateword);
                printf("(Now reads %08x)\n", m_fpga->readio(R_DATE));
                printf("(Now reads %08x)\n", m_fpga->readio(R_DATE));
#endif // R_DATE
#endif // R_DATE
 
 
                now = then;
                now = then;
        } if (read_hack) {
 
                then = time(NULL) + 5;
 
                while(time(NULL) < then)
 
                        ;
 
                clockword = m_fpga->readio(R_CLOCK);
 
                printf("Hack : %08x\n", m_fpga->readio(R_TIMEHACK));
 
                printf(" SUBS: %08x:%08x\n", m_fpga->readio(R_HACKHI), m_fpga->readio(R_HACKLO));
 
 
 
        }
        }
 
 
        if (m_fpga->poll())
 
                printf("FPGA was interrupted\n");
 
        delete  m_fpga;
        delete  m_fpga;
}
}
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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