Project

General

Profile

Revision 891

Moved comments to headers. That was painful.

View differences:

buzzer.c
39 39
#include <buzzer.h>
40 40
#include <time.h>
41 41

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

  
50
/**
51
 * Initializes the buzzer. Must be called before any other buzzer
52
 * function may be used.
53
 **/
54 42
void buzzer_init( void )
55 43
{
56 44
	//NOTE: This is mostly handled by buzzer_Set_val for now
......
60 48
	//TCCR2 = _BV(COM20) | _BV(WGM21)  | _BV(CS22);
61 49
}
62 50

  
63
/**
64
 * Sets the value of the buzzer's pitch.
65
 * Higher values are lower frequencies.
66
 *
67
 * @param buzz_value the value to set the buzzer's frequency too,
68
 * in the range 0-255
69
 *
70
 * @see buzzer_init, buzzer_set_freq, buzzer_off
71
 **/
72 51
void buzzer_set_val(unsigned int buzz_value)
73 52
{ 
74 53
	TCCR2 = _BV(COM20) | _BV(WGM21)  | _BV(CS22);
......
76 55
	OCR2 = buzz_value;
77 56
}
78 57

  
79
/**
80
 * Sets the buzzer frequency. Usage of constants such as C4
81
 * is highly recommended as input to this function.
82
 * buzzer_init must be called before this function may
83
 * be used.
84
 *
85
 * @param buzz_freq the frequency to set the buzzer to
86
 *
87
 * @see buzzer_init, buzzer_set_val, buzzer_off
88
 **/
89 58
void buzzer_set_freq(unsigned int buzz_freq)
90 59
{
91 60
  int buzz_value;
......
101 70
  buzzer_set_val(buzz_value);
102 71
}
103 72

  
104
/**
105
 * Plays the specified frequency for the specified
106
 * amount of time. This function blocks execution
107
 * until the time is completed. buzzer_init must be
108
 * called before this function can be used.
109
 *
110
 * @param ms the time in milliseconds to play the frequency
111
 * @param buzz_freq the frequency to play
112
 *
113
 * @see buzzer_init, buzzer_set_freq
114
 **/
115 73
void buzzer_chirp(unsigned int ms, unsigned int buzz_freq) 
116 74
{ 
117 75
  buzzer_set_freq(buzz_freq);
......
119 77
  buzzer_off();
120 78
}
121 79

  
122
/**
123
 * Turns off the buzzer by disabling the timer0 clock.
124
 *
125
 * @see buzzer_init
126
 **/
127 80
void buzzer_off()
128 81
{
129 82
  // Disable clock, to halt counter
......
133 86
  PORTB &= 0xBF;//0b10111111;
134 87
}
135 88

  
136
/** @} **/ // end buzzer group
137

  

Also available in: Unified diff