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

Subversion Repositories s6soc

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

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 "board.h"
40
 
41
#include "samples.c"
42
 
43
const char      msg[] = "Doorbell!\r\n\r\n";
44
 
45
void entry(void) {
46 45 dgisselq
        register volatile IOSPACE *const sys = _sys;
47 12 dgisselq
 
48 45 dgisselq
        sys->io_watchdog = 0;
49 12 dgisselq
        sys->io_pic = 0x07fffffff; // Acknowledge and turn off all interrupts
50
 
51
        sys->io_spio = 0x0f4;
52
        sys->io_pwm_audio = 0x0110000;
53
        while(1) {
54
                int     seconds = 0, pic;
55 45 dgisselq
                const unsigned short    *ptr;
56 12 dgisselq
                const char      *mptr = msg;
57 45 dgisselq
                sys->io_timer = TM_ONE_SECOND | TM_REPEAT; // Ticks per second, 80M
58 12 dgisselq
 
59
                sys->io_spio = 0x0f0;
60 45 dgisselq
                ptr = (const unsigned short *)sound_data;
61 12 dgisselq
                sys->io_pwm_audio = 0x0310000;
62 45 dgisselq
                sys->io_spio = 0x0f1;
63
                while(ptr <(const unsigned short *)&sound_data[NSAMPLE_WORDS]) {
64
                        unsigned        this_sample;
65 12 dgisselq
                        sys->io_spio = 0x022;
66
                        do {
67
                                pic = sys->io_pic;
68 45 dgisselq
                                if (pic & INT_TIMER)
69 12 dgisselq
                                        seconds++;
70
                                if ((pic & INT_UARTTX)&&(*mptr))
71
                                        sys->io_uart = *mptr++;
72
                                sys->io_pic = (pic & 0x07fff);
73
                        } while((pic & INT_AUDIO)==0);
74 45 dgisselq
                        this_sample = (*ptr++); // & 0x0ffff;
75
                        sys->io_pwm_audio = this_sample;
76 12 dgisselq
                        // Now, turn off the audio interrupt since it doesn't
77
                        // reset itself ...
78
                        sys->io_pic = INT_AUDIO;
79 45 dgisselq
                } if (ptr >= (const unsigned short *)&sound_data[NSAMPLE_WORDS])
80 12 dgisselq
                        sys->io_spio = 0x044;
81
 
82
                sys->io_spio = 0x088;
83
                sys->io_pwm_audio = 0;
84
                while(seconds < 10) {
85
                        pic = sys->io_pic;
86 45 dgisselq
                        if (pic & INT_TIMER)
87 12 dgisselq
                                seconds++;
88
                        sys->io_pic = (pic & 0x07fff);
89
                }
90
                sys->io_spio = 0x0ff;
91
        }
92
}
93
 

powered by: WebSVN 2.1.0

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