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

Subversion Repositories s6soc

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

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 15 Rev 45
Line 10... Line 10...
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015-2016, 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.
Line 42... Line 42...
#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 IOSPACE        *sys = (IOSPACE *)0x0100;
        register volatile IOSPACE *const sys = _sys;
 
 
        sys->io_timb = 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 int       *ptr;
                const unsigned short    *ptr;
                const char      *mptr = msg;
                const char      *mptr = msg;
                sys->io_tima = 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 = sound_data;
                ptr = (const unsigned short *)sound_data;
                sys->io_pwm_audio = 0x0310000;
                sys->io_pwm_audio = 0x0310000;
                if (ptr == sound_data)
 
                        sys->io_spio = 0x0f1;
                        sys->io_spio = 0x0f1;
                while(ptr < &sound_data[NSAMPLE_WORDS]) {
                while(ptr <(const unsigned short *)&sound_data[NSAMPLE_WORDS]) {
 
                        unsigned        this_sample;
                        sys->io_spio = 0x022;
                        sys->io_spio = 0x022;
                        do {
                        do {
                                pic = sys->io_pic;
                                pic = sys->io_pic;
                                if (pic & INT_TIMA)
                                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);
                        sys->io_pwm_audio = (*ptr >> 16)&0x0ffff;
                        this_sample = (*ptr++); // & 0x0ffff;
 
                        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])
                        do {
 
                                pic = sys->io_pic;
 
                                if (pic & INT_TIMA)
 
                                        seconds++;
 
                                if ((pic & INT_UARTTX)&&(*mptr))
 
                                        sys->io_uart = *mptr++;
 
                                sys->io_pic = (pic & 0x07fff);
 
                        } while((pic & INT_AUDIO)==0);
 
                        sys->io_pwm_audio = (*ptr++) & 0x0ffff;
 
 
 
                        // and turn off the audio interrupt again ...
 
                        sys->io_pic = INT_AUDIO;
 
                } if (ptr >= &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_TIMA)
                        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.