This little program demonstrates how to use the SignalGenerator library.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Yann
Date:
Tue Nov 16 10:37:46 2010 +0000
Parent:
0:481720b53aed
Commit message:
V0.0.0.2

Changed in this revision

SignalGenerator.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/SignalGenerator.lib	Tue Nov 16 10:30:20 2010 +0000
+++ b/SignalGenerator.lib	Tue Nov 16 10:37:46 2010 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Yann/code/SignalGenerator/#d6cbee8595e0
+http://mbed.org/users/Yann/code/SignalGenerator/#40051400cafe
--- 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 {