Line 168... |
Line 168... |
tasklist[RTCCLOCK_TASK] = new_task(16, rtctask);
|
tasklist[RTCCLOCK_TASK] = new_task(16, rtctask);
|
#endif
|
#endif
|
|
|
#ifdef DOORBELL_TASK
|
#ifdef DOORBELL_TASK
|
#ifdef DISPLAY_TASK
|
#ifdef DISPLAY_TASK
|
//
|
// 13 + 10 +9(uwrite)+4(uarthex)+2(uartstr)+2(uartchr)
|
tasklist[DOORBELL_TASK] = new_task(64, doorbell_task);
|
tasklist[DOORBELL_TASK] = new_task(64, doorbell_task);
|
tasklist[DOORBELL_TASK]->fd[FILENO_STDOUT] = sys_malloc(sizeof(KFILDES));
|
tasklist[DOORBELL_TASK]->fd[FILENO_STDOUT] = sys_malloc(sizeof(KFILDES));
|
tasklist[DOORBELL_TASK]->fd[FILENO_STDOUT]->id = (int)lcdpipe;
|
tasklist[DOORBELL_TASK]->fd[FILENO_STDOUT]->id = (int)lcdpipe;
|
tasklist[DOORBELL_TASK]->fd[FILENO_STDOUT]->dev= pipedev;
|
tasklist[DOORBELL_TASK]->fd[FILENO_STDOUT]->dev= pipedev;
|
|
tasklist[DOORBELL_TASK]->fd[FILENO_STDERR] = sys_malloc(sizeof(KFILDES));
|
|
tasklist[DOORBELL_TASK]->fd[FILENO_STDERR]->id = (int)txpipe;
|
|
tasklist[DOORBELL_TASK]->fd[FILENO_STDERR]->dev= pipedev;
|
tasklist[DOORBELL_TASK]->fd[FILENO_AUX] = sys_malloc(sizeof(KFILDES));
|
tasklist[DOORBELL_TASK]->fd[FILENO_AUX] = sys_malloc(sizeof(KFILDES));
|
tasklist[DOORBELL_TASK]->fd[FILENO_AUX]->id = (int)pwmpipe;
|
tasklist[DOORBELL_TASK]->fd[FILENO_AUX]->id = (int)pwmpipe;
|
tasklist[DOORBELL_TASK]->fd[FILENO_AUX]->dev= pipedev;
|
tasklist[DOORBELL_TASK]->fd[FILENO_AUX]->dev= pipedev;
|
|
|
//
|
//
|
Line 202... |
Line 205... |
#define HALF_HOUR_S 30 // 3 Mins is to long, here's 3 seconds
|
#define HALF_HOUR_S 30 // 3 Mins is to long, here's 3 seconds
|
|
|
#include "../dev/samples.c"
|
#include "../dev/samples.c"
|
|
|
const unsigned dawn = 0x060000, dusk = 0x180000;
|
const unsigned dawn = 0x060000, dusk = 0x180000;
|
|
int nwritten = 0, nread = 0, nstarts = 0;
|
|
|
void shownow(unsigned now) { // Uses 10 stack slots + 8 for write()
|
void shownow(unsigned now) { // Uses 10 stack slots + 8 for write()
|
char dmsg[9];
|
char dmsg[9];
|
dmsg[0] = PACK(0x1b,'[','j','T');
|
dmsg[0] = PACK(0x1b,'[','j','T');
|
dmsg[1] = PACK('i','m','e',':');
|
dmsg[1] = PACK('i','m','e',':');
|
Line 254... |
Line 258... |
sys->io_spio = 0x088; // Turn our light on
|
sys->io_spio = 0x088; // Turn our light on
|
else
|
else
|
sys->io_spio = 0x80; // Turn light off
|
sys->io_spio = 0x80; // Turn light off
|
}
|
}
|
|
|
|
void uartchr(char v) {
|
|
if (write(FILENO_STDERR, &v, 1) != 1)
|
|
write(FILENO_STDERR, "APPLE-PANIC", 11);
|
|
}
|
|
|
|
void uartstr(const char *str) {
|
|
int cnt=0;
|
|
while(str[cnt])
|
|
cnt++;
|
|
if (cnt != write(FILENO_STDERR, str, cnt))
|
|
write(FILENO_STDERR, "PIPE-PANIC", 10);
|
|
}
|
|
|
|
void uarthex(int num) {
|
|
for(int ds=28; ds>=0; ds-=4) {
|
|
int ch;
|
|
ch = (num>>ds)&0x0f;
|
|
if (ch >= 10)
|
|
ch = 'A'+ch-10;
|
|
else
|
|
ch += '0';
|
|
uartchr(ch);
|
|
} uartstr("\r\n\0");
|
|
}
|
|
|
void doorbell_task(void) {
|
void doorbell_task(void) {
|
// Controls LED 0x08
|
// Controls LED 0x08
|
|
|
// Start by initializing the display to GT Gisselquist\nTechnology
|
// Start by initializing the display to GT Gisselquist\nTechnology
|
// write(KFD_STDOUT, disp_build_backslash,sizeof(disp_build_backslash));
|
// write(KFD_STDOUT, disp_build_backslash,sizeof(disp_build_backslash));
|
Line 266... |
Line 295... |
// write(KFD_STDOUT, disp_gtech_data, sizeof(disp_gtech_data));
|
// write(KFD_STDOUT, disp_gtech_data, sizeof(disp_gtech_data));
|
|
|
IOSPACE *sys = (IOSPACE *)IOADDR;
|
IOSPACE *sys = (IOSPACE *)IOADDR;
|
|
|
while(1) {
|
while(1) {
|
|
nread = nwritten = 0;
|
int event;
|
int event;
|
// Initial state: doorbell is not ringing. In this state, we
|
// Initial state: doorbell is not ringing. In this state, we
|
// can wait forever for an event
|
// can wait forever for an event
|
sys->io_spio = 0x080; // Turn our light off
|
sys->io_spio = 0x080; // Turn our light off
|
event = wait(INT_BUTTON|SWINT_PPS,-1);
|
event = wait(INT_BUTTON|SWINT_PPS,-1);
|
Line 288... |
Line 318... |
int seconds = 0;
|
int seconds = 0;
|
|
|
// Check time: should we turn our light on or not?
|
// Check time: should we turn our light on or not?
|
belllight(rtcclock);
|
belllight(rtcclock);
|
const int *sptr = sound_data;
|
const int *sptr = sound_data;
|
sys->io_uart = 'N';
|
// uartchr('N');
|
while(sptr < &sound_data[NSAMPLE_WORDS]) {
|
while(sptr < &sound_data[NSAMPLE_WORDS]) {
|
int len = &sound_data[NSAMPLE_WORDS]-sptr;
|
int len = &sound_data[NSAMPLE_WORDS]-sptr;
|
if (len > 256)
|
if (len > 256)
|
len = 256;
|
len = 256;
|
|
|
// We stall here, if the audio FIFO is full
|
/*
|
|
while(len > 64) {
|
|
write(FILENO_AUX, sptr, 64);
|
|
sptr += 64;
|
|
len -= 64;
|
|
}*/
|
|
|
|
// We will stall here, if the audio FIFO is full
|
write(FILENO_AUX, sptr, len);
|
write(FILENO_AUX, sptr, len);
|
sptr += len;
|
sptr += len;
|
|
nwritten += len;
|
|
|
// If the user presses the button more than
|
// If the user presses the button more than
|
// once, we start the sound over as well as
|
// once, we start the sound over as well as
|
// our light counter.
|
// our light counter.
|
event = wait(INT_BUTTON|SWINT_PPS, 0);
|
event = wait(INT_BUTTON|SWINT_PPS, 0);
|
if (event&INT_BUTTON) {
|
if (event&INT_BUTTON) {
|
Line 315... |
Line 354... |
belllight(rtcclock);
|
belllight(rtcclock);
|
showbell(when);
|
showbell(when);
|
}
|
}
|
}
|
}
|
|
|
sys->io_uart = 'D';
|
uartchr('D');
|
|
|
// Next state: the doorbell is no longer ringing, but
|
// Next state: the doorbell is no longer ringing, but
|
// we have yet to return to normal--the light is still
|
// we have yet to return to normal--the light is still
|
// on.
|
// on.
|
while((seconds < HALF_HOUR_S)&&
|
while((seconds < HALF_HOUR_S)&&
|
Line 329... |
Line 368... |
showbell(when);
|
showbell(when);
|
}
|
}
|
if (event&INT_BUTTON) {
|
if (event&INT_BUTTON) {
|
when = (volatile unsigned)rtcclock;
|
when = (volatile unsigned)rtcclock;
|
showbell(when);
|
showbell(when);
|
sys->io_uart = 'S';
|
uartchr('B');
|
}
|
}
|
}
|
}
|
|
|
|
// uartstr("\r\n");
|
|
uartstr("\r\nNWritten: "); uarthex(nwritten);
|
|
uartstr("NRead : "); uarthex(nread);
|
|
uartstr("NStarts : "); uarthex(nstarts);
|
|
nwritten = nread = nstarts = 0;
|
}
|
}
|
}
|
}
|
#endif
|
#endif
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|
|
|
|
/*
|
|
|
|
|
|
NWritten: 000018E7
|
|
NRead : 000018E7
|
|
NStarts : 00000001
|
|
|
|
|
|
*/
|
|
|
No newline at end of file
|
No newline at end of file
|