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

Subversion Repositories s6soc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /s6soc/trunk
    from Rev 38 to Rev 39
    Reverse comparison

Rev 38 → Rev 39

/sw/zipos/doorbell.c
339,7 → 339,7
int seconds = 0;
 
// Check time: should we turn our light on or not?
belllight(rtcclock);
belllight((volatile unsigned)rtcclock);
const int *sptr = sound_data;
// uartchr('N');
while(sptr < &sound_data[NSAMPLE_WORDS]) {
368,7 → 368,7
}
} else if (event&SWINT_PPS) {
seconds++;
belllight(rtcclock);
belllight((volatile unsigned)rtcclock);
#ifndef MENU_TASK
showbell(when);
#endif
381,7 → 381,7
while((seconds < HALF_HOUR_S)&&
(((event=wait(INT_BUTTON|SWINT_PPS,-1))&INT_BUTTON)==0)) {
seconds++;
belllight(rtcclock);
belllight((volatile unsigned)rtcclock);
#ifndef MENU_TASK
showbell(when);
#endif
519,6 → 519,21
} while(0==(event&INT_KEYPAD));
}
 
// Here's the trick here: without semaphores, we can't prevent a
// race condition on the clock. It may be that the clock simulator
// has read the clock value and is in the process of updating it, only
// to have our task swapped in. The risk here is that the RTC simulator
// will write the updated value after we update our value here. If it
// does that, it will then set the SWINT_PPS interrupt. So let's clear
// this interrupt and then set our clock. If the interrupt then
// takes place in short order, we'll set the clock again. That way,
// if the RTC device was in the process of setting the clock, and then
// sets it, we can adjust it again.
//
// Of course ... this won't work if it takes the clock longer than
// a millisecond to finish setting the clock ... but this is such a
// rare race condition, and the consequences so minor, that this will
// probably continue to work for now.
clear(SWINT_PPS);
rtcclock = newclock;
if (wait(SWINT_PPS, 1))
616,16 → 631,15
// write(KFD_STDOUT, disp_build_gtlogo, sizeof(disp_build_gtlogo));
// write(KFD_STDOUT, disp_reset_data, sizeof(disp_reset_data));
// write(KFD_STDOUT, disp_gtech_data, sizeof(disp_gtech_data));
IOSPACE *sys = (IOSPACE *)IOADDR;
// IOSPACE *sys = (IOSPACE *)IOADDR;
unsigned belltime = 0, when;
 
 
when = rtcclock;
when = (volatile unsigned)rtcclock;
while(1) {
int event;
// Initial state: doorbell is not ringing. In this state, we
// can wait forever for an event
sys->io_spio = 0x080; // Turn our light off
event = wait(SWINT_DOORBELL|SWINT_PPS|INT_KEYPAD,-1);
if (event & SWINT_DOORBELL) {
showbell(when);
635,7 → 649,7
if ((now-belltime)<HALF_HOUR_S)
showbell(when);
else {
when = rtcclock;
when = (volatile unsigned)rtcclock;
shownow(when);
}
}
645,7 → 659,7
key = menu_readkey();
switch(key) {
case 10: time_menu();
when = rtcclock;
when = (volatile unsigned)rtcclock;
break;
case 11: dawn_menu(); break;
case 12: dusk_menu(); break;

powered by: WebSVN 2.1.0

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