Drive a speaker using PWM

Dependencies:   mbed

Dependents:   PwmSpeaker-Example

Revision:
1:10005e388826
Parent:
0:b7dd35e61bb1
--- a/Speaker.cpp	Thu Nov 12 21:04:11 2015 +0000
+++ b/Speaker.cpp	Thu Nov 12 21:20:23 2015 +0000
@@ -7,14 +7,29 @@
         NOTE_C7, NOTE_CS7, NOTE_D7, NOTE_DS7, NOTE_E7, NOTE_F7, NOTE_FS7, NOTE_G7, NOTE_GS7, NOTE_A7, NOTE_AS7, NOTE_B7
 };
 
+/**
+ * Set output frequency of the speaker.
+ *
+ * \param frequency The frequency to set
+ */
 void Speaker::set_frequency(uint32_t frequency) {
     _pwm.period(1.0/frequency);
 }
 
+/**
+ * Enable or disable speaker output.
+ *
+ * \param enable Whether to enable or disable the speaker
+ */
 void Speaker::enable(bool enable) {
     *this = enable;
 }
 
+/**
+ * Enable or disable the speaker output.
+ *
+ * \param setting 0 to disable speaker, other values to enable speaker.
+ */
 Speaker& Speaker::operator=(int setting) {
     if (setting) {
         _pwm = 0.5;
@@ -24,8 +39,10 @@
     return *this;    
 }
 
-/*
- * Plays an old-school ringtone in RTTTL language.
+/**
+ * Play an old-school ringtone in RTTTL language.
+ *
+ * \param p Char array in RTTTL format
  */
 void Speaker::play_rtttl(char * p) {
   // Absolutely no error checking in here