This little program demonstrates how to use the SignalGenerator library.

Dependencies:   mbed

Revision:
1:719b21661920
Parent:
0:481720b53aed
--- a/main.cpp	Tue Nov 16 10:30:20 2010 +0000
+++ b/main.cpp	Tue Nov 16 10:37:46 2010 +0000
@@ -1,23 +1,24 @@
-#include "SignalGenerator.h"
+#include "SignalGenerator.h" // It includes 'mbed.h' header
 
-Serial g_debug(USBTX, USBRX); // tx, rx
-
-/** CPU Available indicator
+/* CPU Available indicator
  */
-DigitalOut g_availableLed(LED1);
+DigitalOut g_availableLed(LED1); //<! Led used to indicate the program is alive
+void AvailableLedIndicator(); //<! Ticker callback
 Ticker g_available;
-void AvailableLedIndicator();
 
-/** Static instance of SignalGenerator
+/* SignalGenerator usage
  */
 SignalGenerator g_signal(p18);
+void SynchronousUserInput(); //<! Ticker callback
 Ticker g_synchronousUserInput;
-void SynchronousUserInput();
-SignalGenerator::SignalGeneratorType DisplaySignalGeneratorTestMenuAndGetChoice();
+Serial g_debug(USBTX, USBRX); //<! Needed to detect that the user pressed a key
+SignalGenerator::SignalGeneratorType DisplaySignalGeneratorTestMenuAndGetChoice(); //<! User menu to select a signal type
 
+/* Program Entry Point
+ */
 int main() {
-    volatile SignalGenerator::SignalGeneratorType _choice; // User selects the desired signal type
-    volatile int frequency; // Signal frequency
+    volatile SignalGenerator::SignalGeneratorType _choice; //<! User selects the desired signal type
+    volatile int frequency; //<! Signal frequency
  
     wait(1); // Needed after startup
    
@@ -52,10 +53,14 @@
     } // End of 'while' statement
 } // End of main program
 
+/** Callbak used by CPU availabe ticker to indicate the program is alive
+ */
 void AvailableLedIndicator() {
     g_availableLed != g_availableLed;
 } // End of function AvailableLedIndicator
 
+/** Callbak used when SignalLibrary is used in synchronous mode (Run() method)
+ */
 void SynchronousUserInput() {
     if (g_debug.readable()) {
         g_signal.Stop();
@@ -63,6 +68,8 @@
     }
 } // End of function SynchronousUserInput
 
+/** Display the user menu
+ */
 SignalGenerator::SignalGeneratorType DisplaySignalGeneratorTestMenuAndGetChoice()
 {
     do {