A porting of a GPS decoding and presenting program within the mbos RTOS. It is not a definitive application but a study program to test NMEA full decoding library and a first approach to an RTOS. Many thanks to Andrew Levido for his support and his patience on teaching me the RTOS principles from the other side of the Earth. It uses NMEA library by Tim (xtimor@gmail.com) ported by Ken Todotani (http://mbed.org/users/todotani/) on public mbed library (http://mbed.org/users/todotani/programs/GPS_nmeaLib/5yo4h) also available, as original universal C library, on http://nmea.sourceforge.net

Dependencies:   mbos Watchdog TextLCD mbed ConfigFile

Committer:
guiott
Date:
Fri Feb 03 16:29:52 2012 +0000
Revision:
3:a2f9eb3b8a16
Parent:
2:8917036cbf69

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
guiott 0:d177c0087d1f 1 /* ////////////////////////////////////////////////////////////////////////////
guiott 0:d177c0087d1f 2 ** File: LeonardoMbos.cpp
guiott 0:d177c0087d1f 3 */
guiott 0:d177c0087d1f 4 /* 12345678901234567890 */
guiott 0:d177c0087d1f 5 char Ver1[] = "Leonardo's GPS 0.1.0";
guiott 0:d177c0087d1f 6 char Ver2[] = " by Guiott 01-12";
guiott 0:d177c0087d1f 7 /**
guiott 3:a2f9eb3b8a16 8 * @mainpage Leonardo.cpp
guiott 3:a2f9eb3b8a16 9 * @author Guido Ottaviani-->guido@guiott.com<--
guiott 3:a2f9eb3b8a16 10 * @version 0.1.0
guiott 3:a2f9eb3b8a16 11 * @date 01/2012
guiott 3:a2f9eb3b8a16 12 * @details This is a test program to study the capability of a GPS module to
guiott 0:d177c0087d1f 13 control navigation of a robot in an outdoor environment.
guiott 0:d177c0087d1f 14
guiott 0:d177c0087d1f 15 This version is developed within the mbos RTOS:
guiott 0:d177c0087d1f 16 http://mbed.org/users/AndrewL/libraries/mbos/lqn3ca
guiott 0:d177c0087d1f 17
guiott 0:d177c0087d1f 18 It uses NMEA library by Tim (xtimor@gmail.com)
guiott 0:d177c0087d1f 19 available on public mbed library or http://nmea.sourceforge.net
guiott 0:d177c0087d1f 20
guiott 0:d177c0087d1f 21 The original gmath.c has been modified to fix a bug in nmea_distance_ellipsoid() function
guiott 0:d177c0087d1f 22 according to bug report ID: 2945855
guiott 0:d177c0087d1f 23
guiott 0:d177c0087d1f 24 http://sourceforge.net/tracker/?func=detail&aid=2945855&group_id=192054&atid=939854
guiott 0:d177c0087d1f 25
guiott 0:d177c0087d1f 26 // while ((delta_lambda > 1e-12) && (remaining_steps > 0)) original by xtimor
guiott 0:d177c0087d1f 27 while (( remaining_steps == 20 ) || ((fabs(delta_lambda) > 1e-12) && (remaining_steps > 0)))
guiott 0:d177c0087d1f 28
guiott 0:d177c0087d1f 29 the original code always returns a zero distance if the arrival point longitude
guiott 0:d177c0087d1f 30 is equal or smaller than the starting point one.
guiott 0:d177c0087d1f 31
guiott 0:d177c0087d1f 32 The mbed module is interfaced with a Garmin GPS sensor (used in standard mode)
guiott 0:d177c0087d1f 33 with an external antenna, a 20x4 LCD text display and a 5 keys keypad.
guiott 0:d177c0087d1f 34 A curiosity:
guiott 0:d177c0087d1f 35 All the hardware components of the test set are mounted on the top of a wooden
guiott 0:d177c0087d1f 36 box, looking like a kind of a steampunk navigator. When my daughter looked at
guiott 0:d177c0087d1f 37 the box she said: "it looks alike the navigator of the da Vinci car".
guiott 0:d177c0087d1f 38 This is the reason why the name of this project is "Leonardo".
guiott 0:d177c0087d1f 39 **
guiott 0:d177c0087d1f 40 -------------------------------------------------------------------------------
guiott 3:a2f9eb3b8a16 41 * @copyright 2012 Guido Ottaviani
guiott 0:d177c0087d1f 42 guido@guiott.com
guiott 0:d177c0087d1f 43
guiott 0:d177c0087d1f 44 LeonardoMbos is free software: you can redistribute it and/or modify
guiott 0:d177c0087d1f 45 it under the terms of the GNU General Public License as published by
guiott 0:d177c0087d1f 46 the Free Software Foundation, either version 3 of the License, or
guiott 0:d177c0087d1f 47 (at your option) any later version.
guiott 0:d177c0087d1f 48
guiott 1:360c4a23cb1d 49 LeonardoMbos is distributed in the hope that it will be useful,
guiott 0:d177c0087d1f 50 but WITHOUT ANY WARRANTY; without even the implied warranty of
guiott 0:d177c0087d1f 51 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
guiott 0:d177c0087d1f 52 GNU General Public License for more details.
guiott 0:d177c0087d1f 53
guiott 0:d177c0087d1f 54 You should have received a copy of the GNU General Public License
guiott 0:d177c0087d1f 55 along with LeonardoMbos.cpp. If not, see <http://www.gnu.org/licenses/>.
guiott 0:d177c0087d1f 56
guiott 0:d177c0087d1f 57 -------------------------------------------------------------------------------
guiott 0:d177c0087d1f 58 */
guiott 0:d177c0087d1f 59 #include "Common.h"
guiott 0:d177c0087d1f 60 #include "mbed.h"
guiott 0:d177c0087d1f 61 #include <string>
guiott 0:d177c0087d1f 62 #include "TextLCD.h"
guiott 0:d177c0087d1f 63 #include "nmea/nmea.h"
guiott 2:8917036cbf69 64 #include <Watchdog.h>
guiott 3:a2f9eb3b8a16 65 #include "ConfigFile.h"
guiott 0:d177c0087d1f 66 #include "Init.h"
guiott 0:d177c0087d1f 67 #include "Prototype.h"
guiott 0:d177c0087d1f 68 #include "mbos.h"
guiott 0:d177c0087d1f 69 #include "Tasks.h"
guiott 0:d177c0087d1f 70
guiott 0:d177c0087d1f 71 // Set up RTOS;
guiott 0:d177c0087d1f 72 mbos os(NUM_TASKS, NUM_TIMERS, NUM_RESOURCES);
guiott 0:d177c0087d1f 73
guiott 0:d177c0087d1f 74 int main()
guiott 0:d177c0087d1f 75 {
guiott 0:d177c0087d1f 76 Initialize();
guiott 0:d177c0087d1f 77 if (wd.WatchdogCausedReset())
guiott 0:d177c0087d1f 78 {
guiott 0:d177c0087d1f 79 pc.printf("Watchdog caused reset**********************************\r\n");
guiott 0:d177c0087d1f 80 }
guiott 2:8917036cbf69 81 wd.Configure(WDT_TIMEOUT); // sets the timeout interval
guiott 0:d177c0087d1f 82
guiott 0:d177c0087d1f 83 os.Start(); // the RTOS starts now
guiott 0:d177c0087d1f 84 }
guiott 0:d177c0087d1f 85
guiott 0:d177c0087d1f 86 //functions =====================================================================
guiott 0:d177c0087d1f 87
guiott 2:8917036cbf69 88 void mbosIdleTask(void)
guiott 2:8917036cbf69 89 {/**
guiott 3:a2f9eb3b8a16 90 *@brief TASK 0 watchdog kick
guiott 2:8917036cbf69 91 */
guiott 2:8917036cbf69 92 while(1)
guiott 2:8917036cbf69 93 {
guiott 2:8917036cbf69 94
guiott 2:8917036cbf69 95 }
guiott 2:8917036cbf69 96 }
guiott 2:8917036cbf69 97
guiott 0:d177c0087d1f 98 int CmpRead(void)
guiott 0:d177c0087d1f 99 {/**
guiott 3:a2f9eb3b8a16 100 *@brief Magnetic Compass reading
guiott 0:d177c0087d1f 101 */
guiott 0:d177c0087d1f 102 int Cmp;
guiott 0:d177c0087d1f 103
guiott 0:d177c0087d1f 104 // To Be Done
guiott 0:d177c0087d1f 105 Cmp = 0; // ************debug
guiott 0:d177c0087d1f 106 return(Cmp);
guiott 0:d177c0087d1f 107 }
guiott 0:d177c0087d1f 108
guiott 3:a2f9eb3b8a16 109 void ReadCfg(char *Config[])
guiott 3:a2f9eb3b8a16 110 {/**
guiott 3:a2f9eb3b8a16 111 *@brief Read a configuration file from a mbed filesystem
guiott 3:a2f9eb3b8a16 112 */
guiott 3:a2f9eb3b8a16 113 char value[BUFSIZ];
guiott 3:a2f9eb3b8a16 114
guiott 3:a2f9eb3b8a16 115 if (!cfg.read("/local/input.cfg"))
guiott 3:a2f9eb3b8a16 116 {
guiott 3:a2f9eb3b8a16 117 pc.printf("Failure to read a configuration file.\n");
guiott 3:a2f9eb3b8a16 118 }
guiott 3:a2f9eb3b8a16 119
guiott 3:a2f9eb3b8a16 120 if (cfg.getValue(Config[0], &value[0], sizeof(value)))
guiott 3:a2f9eb3b8a16 121 {
guiott 3:a2f9eb3b8a16 122 pc.printf("'%s'='%s'\n", Config[0], value);
guiott 3:a2f9eb3b8a16 123 }
guiott 3:a2f9eb3b8a16 124
guiott 3:a2f9eb3b8a16 125 if (cfg.getValue(Config[1], &value[0], sizeof(value)))
guiott 3:a2f9eb3b8a16 126 {
guiott 3:a2f9eb3b8a16 127 pc.printf("'%s'='%s'\n", Config[1], value);
guiott 3:a2f9eb3b8a16 128 }
guiott 3:a2f9eb3b8a16 129 }
guiott 3:a2f9eb3b8a16 130
guiott 3:a2f9eb3b8a16 131 void WriteCfg()
guiott 3:a2f9eb3b8a16 132 {/**
guiott 3:a2f9eb3b8a16 133 *@brief Write configurations to mbed filesystem
guiott 3:a2f9eb3b8a16 134 */
guiott 3:a2f9eb3b8a16 135 cfg.setValue("LonStart", "lon");
guiott 3:a2f9eb3b8a16 136 cfg.setValue("LatStart", "lat");
guiott 3:a2f9eb3b8a16 137
guiott 3:a2f9eb3b8a16 138 cfg.write("/local/input.cfg", "# Configuration file for LeonardoGps.");
guiott 3:a2f9eb3b8a16 139 }