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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [sw/] [dev/] [doorbell.c] - Diff between revs 45 and 53

Only display areas with differences | Details | Blame | View Log

Rev 45 Rev 53
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Filename:    doorbell.c
// Filename:    doorbell.c
//
//
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
//
//
// Purpose:     To test the PWM device by playing a doorbell sound every ten
// Purpose:     To test the PWM device by playing a doorbell sound every ten
//              seconds.
//              seconds.
//
//
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
//
//
// This program is free software (firmware): you can redistribute it and/or
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of  the GNU General Public License as published
// modify it under the terms of  the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// your option) any later version.
//
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// for more details.
//
//
// You should have received a copy of the GNU General Public License along
// You should have received a copy of the GNU General Public License along
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
// target there if the PDF file isn't present.)  If not, see
// target there if the PDF file isn't present.)  If not, see
// <http://www.gnu.org/licenses/> for a copy.
// <http://www.gnu.org/licenses/> for a copy.
//
//
// License:     GPL, v3, as defined and found on www.gnu.org,
// License:     GPL, v3, as defined and found on www.gnu.org,
//              http://www.gnu.org/licenses/gpl.html
//              http://www.gnu.org/licenses/gpl.html
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
#include "asmstartup.h"
 
#include "board.h"
#include "board.h"
 
 
#include "samples.c"
#include "samples.c"
 
 
const char      msg[] = "Doorbell!\r\n\r\n";
const char      msg[] = "Doorbell!\r\n\r\n";
 
 
void entry(void) {
void entry(void) {
        register volatile IOSPACE *const sys = _sys;
        register volatile IOSPACE *const sys = _sys;
 
 
        sys->io_watchdog = 0;
        sys->io_watchdog = 0;
        sys->io_pic = 0x07fffffff; // Acknowledge and turn off all interrupts
        sys->io_pic = 0x07fffffff; // Acknowledge and turn off all interrupts
 
 
        sys->io_spio = 0x0f4;
        sys->io_spio = 0x0f4;
        sys->io_pwm_audio = 0x0110000;
        sys->io_pwm_audio = 0x0110000;
        while(1) {
        while(1) {
                int     seconds = 0, pic;
                int     seconds = 0, pic;
                const unsigned short    *ptr;
                const unsigned short    *ptr;
                const char      *mptr = msg;
                const char      *mptr = msg;
                sys->io_timer = TM_ONE_SECOND | TM_REPEAT; // Ticks per second, 80M
                sys->io_timer = TM_ONE_SECOND | TM_REPEAT; // Ticks per second, 80M
 
 
                sys->io_spio = 0x0f0;
                sys->io_spio = 0x0f0;
                ptr = (const unsigned short *)sound_data;
                ptr = (const unsigned short *)sound_data;
                sys->io_pwm_audio = 0x0310000;
                sys->io_pwm_audio = 0x0310000;
                sys->io_spio = 0x0f1;
                sys->io_spio = 0x0f1;
                while(ptr <(const unsigned short *)&sound_data[NSAMPLE_WORDS]) {
                while(ptr <(const unsigned short *)&sound_data[NSAMPLE_WORDS]) {
                        unsigned        this_sample;
                        unsigned        this_sample;
                        sys->io_spio = 0x022;
                        sys->io_spio = 0x022;
                        do {
                        do {
                                pic = sys->io_pic;
                                pic = sys->io_pic;
                                if (pic & INT_TIMER)
                                if (pic & INT_TIMER)
                                        seconds++;
                                        seconds++;
                                if ((pic & INT_UARTTX)&&(*mptr))
                                if ((pic & INT_UARTTX)&&(*mptr))
                                        sys->io_uart = *mptr++;
                                        sys->io_uart = *mptr++;
                                sys->io_pic = (pic & 0x07fff);
                                sys->io_pic = (pic & 0x07fff);
                        } while((pic & INT_AUDIO)==0);
                        } while((pic & INT_AUDIO)==0);
                        this_sample = (*ptr++); // & 0x0ffff;
                        this_sample = (*ptr++); // & 0x0ffff;
                        sys->io_pwm_audio = this_sample;
                        sys->io_pwm_audio = this_sample;
                        // Now, turn off the audio interrupt since it doesn't
                        // Now, turn off the audio interrupt since it doesn't
                        // reset itself ...
                        // reset itself ...
                        sys->io_pic = INT_AUDIO;
                        sys->io_pic = INT_AUDIO;
                } if (ptr >= (const unsigned short *)&sound_data[NSAMPLE_WORDS])
                } if (ptr >= (const unsigned short *)&sound_data[NSAMPLE_WORDS])
                        sys->io_spio = 0x044;
                        sys->io_spio = 0x044;
 
 
                sys->io_spio = 0x088;
                sys->io_spio = 0x088;
                sys->io_pwm_audio = 0;
                sys->io_pwm_audio = 0;
                while(seconds < 10) {
                while(seconds < 10) {
                        pic = sys->io_pic;
                        pic = sys->io_pic;
                        if (pic & INT_TIMER)
                        if (pic & INT_TIMER)
                                seconds++;
                                seconds++;
                        sys->io_pic = (pic & 0x07fff);
                        sys->io_pic = (pic & 0x07fff);
                }
                }
                sys->io_spio = 0x0ff;
                sys->io_spio = 0x0ff;
        }
        }
}
}
 
 
 
 

powered by: WebSVN 2.1.0

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