Project

General

Profile

Statistics
| Revision:

root / branches / simulator / projects / libdragonfly / include / buzzer.h @ 891

History | View | Annotate | Download (3.54 KB)

1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

    
26

    
27
/**
28
 * @file buzzer.h
29
 * @brief Contains definitions for using the buzzer.
30
 *
31
 * Contains definitions for using the buzzer built into
32
 * the colony robots.
33
 *
34
 * @author Colony Project, CMU Robotics Club
35
 **/
36

    
37
#ifndef _BUZZER_H_
38
#define _BUZZER_H_
39

    
40
/**
41
 * @defgroup buzzer Buzzer
42
 * @brief Functions for controlling the buzzer.
43
 * Functions for controlling the buzzer. Include
44
 * buzzer.h to access these functions.
45
 * @{
46
 **/
47

    
48
//Musical note definitions
49
//Source: http://www.answers.com/topic/piano-key-frequencies
50
/** @brief Middle C **/
51
#define        C4        260 //Middle C
52
/** @brief C# **/
53
#define        C4s        277 //C sharp
54
/** @brief D **/
55
#define        D4        294
56
/** @brief D# **/
57
#define        D4s        311
58
/** @brief E **/
59
#define        E4        330
60
/** @brief F **/
61
#define        F4        349
62
/** @brief F# **/
63
#define        F4s        370
64
/** @brief G **/
65
#define        G4        392
66
/** @brief G# **/
67
#define        G4s        415
68
/** @brief A **/
69
#define        A4        440
70
/** @brief A# **/
71
#define        A4s        466
72
/** @brief B **/
73
#define        B4        494
74
/** @brief C **/
75
#define        C5        523
76

    
77
/**
78
 * @brief Initialize the buzzer.
79
 *
80
 * Initializes the buzzer. Must be called before any other buzzer
81
 * function may be used.
82
 **/
83
void buzzer_init(void);
84
/**
85
 * @brief Set the value the buzzer plays.
86
 *
87
 * Sets the value of the buzzer's pitch.
88
 * Higher values are lower frequencies.
89
 *
90
 * @param buzz_value the value to set the buzzer's frequency too,
91
 * in the range 0-255
92
 *
93
 * @see buzzer_init, buzzer_set_freq, buzzer_off
94
 **/
95
void buzzer_set_val(unsigned int buzz_value);
96
/**
97
 * @brief Set the frequency the buzzer plays.
98
 *
99
 * Sets the buzzer frequency. Usage of constants such as C4
100
 * is highly recommended as input to this function.
101
 * buzzer_init must be called before this function may
102
 * be used.
103
 *
104
 * @param buzz_freq the frequency to set the buzzer to
105
 *
106
 * @see buzzer_init, buzzer_set_val, buzzer_off
107
 **/
108
void buzzer_set_freq(unsigned int buzz_freq);
109
/**
110
 * @brief Play a frequency for a specified time.
111
 *
112
 * Plays the specified frequency for the specified
113
 * amount of time. This function blocks execution
114
 * until the time is completed. buzzer_init must be
115
 * called before this function can be used.
116
 *
117
 * @param ms the time in milliseconds to play the frequency
118
 * @param buzz_freq the frequency to play
119
 *
120
 * @see buzzer_init, buzzer_set_freq
121
 **/
122
void buzzer_chirp(unsigned int ms, unsigned int buzz_freq);
123
/** @brief Turn the buzzer off.
124
 *
125
 * Turns off the buzzer by disabling the timer0 clock.
126
 *
127
 * @see buzzer_init
128
 **/
129
void buzzer_off(void); 
130

    
131
/** @} **/ //end addtogroup
132

    
133
#endif
134