Generates RTTY from a GPS receiver

Dependencies:   mbed-dsp mbed-rtos mbed

Revision:
4:ed77fd381cc5
Parent:
3:33d80761aa06
Child:
5:dcf952c7e6b3
--- a/main.cpp	Sat Jan 11 18:48:08 2014 +0000
+++ b/main.cpp	Sat Jan 11 19:08:40 2014 +0000
@@ -1,3 +1,19 @@
+// Author:  Andrew Wiens (adwiens.com)
+// Date:    11 Jan 2014
+//
+// =====================================
+// 
+// GPS2RTTY
+//
+// Using the mbed RTOS and DSP libraries, GPS2RTTY generates RTTY messages
+// containing raw NMEA sentences from a GPS receiver.
+//
+// No extra hardware is needed! Audio is generated with the mbed's built-in DAC.
+//
+// GPS ---> mbed ---> Radio
+//
+// =====================================
+
 #include "mbed.h"
 #include "rtos.h" // mbed real time os library
 #include "dsp.h" // mbed digital signal processing library
@@ -25,22 +41,25 @@
 
 using namespace std;
 
+// mbed ports:
 Serial pc(USBTX, USBRX); // pc serial port (via usb)
+Serial gps(p9, p10); // gps serial port (uart3)
+AnalogOut dac(p18); // mbed built-in digital to analog converter
+DigitalOut ptt(p17); // radio push to talk button
+
+// Status leds:
+DigitalOut gps_led(LED1); // gps status led
+DigitalOut rtty_led(LED2); // tx status led
 
 // GPS variables:
 char cb[GPS_CB_SIZE]; // c-string circular buffer for gps rx isr
 int cb_isr_i = 0; // gps isr index
 int cb_thr_i = 0; // gps thread index
-DigitalOut gps_led(LED1); // gps status led
-Serial gps(p9, p10); // gps serial port (uart3)
 stringstream rxbuf; // gps receive buffer
 map<string,string> nmea_data; // most recent nmea sentences
 Mutex nmea_data_mutex; // nmea data lock
 
 // RTTY variables:
-AnalogOut dac(p18); // mbed built-in digital to analog converter
-DigitalOut ptt(p17); // radio push to talk button
-DigitalOut rtty_led(LED2); // tx status led
 char r_cb[RTTY_CB_SIZE]; // c-string circular buffer for rtty tx isr
 int r_cb_isr_i = 0; // rtty isr index
 int r_cb_thr_i = 0; // rtty thread index
@@ -49,7 +68,7 @@
 int bitn = -1; // current bit number
 bool txen = false; // tx enable flag
 
-// Interrupt service routine for the gps.
+// Interrupt service routine for the GPS.
 // It is called when the serial port receives a character,
 // and it puts the character into a circular buffer for the gps thread.
 void gps_rx_isr()
@@ -58,7 +77,7 @@
     if(++cb_isr_i >= GPS_CB_SIZE) cb_isr_i = 0; // loop circular buffer index
 }
 
-// Reads new characters from the gps circular
+// Reads new characters from the GPS circular
 // buffer when the circular buffer is about 25 percent full
 // and adds the new characters to a string containing the current
 // nmea sentence. Each time a complete NMEA sentence is received
@@ -172,7 +191,7 @@
     }
 }
 
-// Writes debug messages periodically to the console. Useful for debug.
+// Writes NMEA sentences to the console. Useful for debug.
 void print_nmea_thread(void const *argument)
 {
     while(1) {