Page MenuHomec4science

speaker.h
No OneTemporary

File Metadata

Created
Sun, Oct 6, 23:58

speaker.h

/*
speaker.h
Copyright (C) 2011 Michiel D'Haene <michiel.dhaene at gmail dot com>
UGent Reservoir lab (http://reslab.elis.ugent.be/michiel)
Ghent University (http://www.ugent.be)
This program is free software: you can redistribute it and/or 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 your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \addtogroup speaker */
/*@{*/
/** \file speaker.h
\brief Speaker driver.
This file contains the declarations of the speaker driver functions and
the frequency definitions of music notes from E2 to E9. The speaker library
currently supports 4 music volumes.
\author Michiel D'Haene
\version 2.0
\date 2011-08-15
*/
#ifndef __SPEAKER_H__
#define __SPEAKER_H__
#include "misc.h"
#include "timer.h"
enum {MAX_SPEAKER_FREQ = 15000,};
enum {MAX_PWM_ON_PERIOD = (FCY/8)/(MAX_SPEAKER_FREQ*2)};
typedef enum {
VOLUME_OFF = 0,
VOLUME_1 = (MAX_PWM_ON_PERIOD/8),
VOLUME_2 = (MAX_PWM_ON_PERIOD/4),
VOLUME_3 = (MAX_PWM_ON_PERIOD/2),
VOLUME_4 = (MAX_PWM_ON_PERIOD),
} Volume;
typedef enum {
NOTE_E2 = 82,
NOTE_F2 = 87,
NOTE_Gb2 = 93,
NOTE_G2 = 98,
NOTE_Ab2 = 104,
NOTE_A2 = 110,
NOTE_Bb2 = 117,
NOTE_B2 = 123,
NOTE_C3 = 131,
NOTE_Db3 = 139,
NOTE_D3 = 147,
NOTE_Eb3 = 156,
NOTE_E3 = 165,
NOTE_F3 = 175,
NOTE_Gb3 = 185,
NOTE_G3 = 196,
NOTE_Ab3 = 208,
NOTE_A3 = 220,
NOTE_Bb3 = 233,
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OTE_E8*2,
} Note;
/*************************************************************************
*
* PUBLIC FUNCTIONS
*
*************************************************************************/
void init_speaker(void);
void set_speaker_freq(int freq);
void set_speaker_volume(int volume);
void beep(int time);
void beep_hello();
void beep_goodbye();
void beep_error();
void beep_mario();
void beep_imperial();
#endif /* __SPEAKER_H__ */
/*@}*/

Event Timeline