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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [sw/] [dev/] [doorbell.c] - Blame information for rev 48

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    doorbell.c
4
//
5
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
6
//
7 15 dgisselq
// Purpose:     To test the PWM device by playing a doorbell sound every ten
8 12 dgisselq
//              seconds.
9
//
10
// Creator:     Dan Gisselquist, Ph.D.
11
//              Gisselquist Technology, LLC
12
//
13
////////////////////////////////////////////////////////////////////////////////
14
//
15 45 dgisselq
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
16 12 dgisselq
//
17
// This program is free software (firmware): you can redistribute it and/or
18
// modify it under the terms of  the GNU General Public License as published
19
// by the Free Software Foundation, either version 3 of the License, or (at
20
// your option) any later version.
21
//
22
// This program is distributed in the hope that it will be useful, but WITHOUT
23
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
24
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25
// for more details.
26
//
27
// You should have received a copy of the GNU General Public License along
28
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
29
// target there if the PDF file isn't present.)  If not, see
30
// <http://www.gnu.org/licenses/> for a copy.
31
//
32
// License:     GPL, v3, as defined and found on www.gnu.org,
33
//              http://www.gnu.org/licenses/gpl.html
34
//
35
//
36
////////////////////////////////////////////////////////////////////////////////
37
//
38
//
39
#include "asmstartup.h"
40
#include "board.h"
41
 
42
#include "samples.c"
43
 
44
const char      msg[] = "Doorbell!\r\n\r\n";
45
 
46
void entry(void) {
47 45 dgisselq
        register volatile IOSPACE *const sys = _sys;
48 12 dgisselq
 
49 45 dgisselq
        sys->io_watchdog = 0;
50 12 dgisselq
        sys->io_pic = 0x07fffffff; // Acknowledge and turn off all interrupts
51
 
52
        sys->io_spio = 0x0f4;
53
        sys->io_pwm_audio = 0x0110000;
54
        while(1) {
55
                int     seconds = 0, pic;
56 45 dgisselq
                const unsigned short    *ptr;
57 12 dgisselq
                const char      *mptr = msg;
58 45 dgisselq
                sys->io_timer = TM_ONE_SECOND | TM_REPEAT; // Ticks per second, 80M
59 12 dgisselq
 
60
                sys->io_spio = 0x0f0;
61 45 dgisselq
                ptr = (const unsigned short *)sound_data;
62 12 dgisselq
                sys->io_pwm_audio = 0x0310000;
63 45 dgisselq
                sys->io_spio = 0x0f1;
64
                while(ptr <(const unsigned short *)&sound_data[NSAMPLE_WORDS]) {
65
                        unsigned        this_sample;
66 12 dgisselq
                        sys->io_spio = 0x022;
67
                        do {
68
                                pic = sys->io_pic;
69 45 dgisselq
                                if (pic & INT_TIMER)
70 12 dgisselq
                                        seconds++;
71
                                if ((pic & INT_UARTTX)&&(*mptr))
72
                                        sys->io_uart = *mptr++;
73
                                sys->io_pic = (pic & 0x07fff);
74
                        } while((pic & INT_AUDIO)==0);
75 45 dgisselq
                        this_sample = (*ptr++); // & 0x0ffff;
76
                        sys->io_pwm_audio = this_sample;
77 12 dgisselq
                        // Now, turn off the audio interrupt since it doesn't
78
                        // reset itself ...
79
                        sys->io_pic = INT_AUDIO;
80 45 dgisselq
                } if (ptr >= (const unsigned short *)&sound_data[NSAMPLE_WORDS])
81 12 dgisselq
                        sys->io_spio = 0x044;
82
 
83
                sys->io_spio = 0x088;
84
                sys->io_pwm_audio = 0;
85
                while(seconds < 10) {
86
                        pic = sys->io_pic;
87 45 dgisselq
                        if (pic & INT_TIMER)
88 12 dgisselq
                                seconds++;
89
                        sys->io_pic = (pic & 0x07fff);
90
                }
91
                sys->io_spio = 0x0ff;
92
        }
93
}
94
 

powered by: WebSVN 2.1.0

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