Subversion Repositories NaviCtrl

Rev

Rev 1 | Rev 27 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 24
Line 56... Line 56...
56
// +  POSSIBILITY OF SUCH DAMAGE. 
56
// +  POSSIBILITY OF SUCH DAMAGE. 
57
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
57
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
58
const unsigned long _Main_Crystal = 25000;
58
const unsigned long _Main_Crystal = 25000;
Line 59... Line 59...
59
 
59
 
-
 
60
#include "main.h"
Line 60... Line 61...
60
#include "main.h"
61
#include "kml.h"
61
 
62
 
62
u32 TimerCompassUpdate;
63
u32 TimerCompassUpdate;
-
 
64
u32 TimerI2CReadDelay;
Line 63... Line 65...
63
u32 TimerI2CReadDelay;
65
u32 TimerDebugDataDelay;
64
u32 TimerDebugDataDelay;
66
u32 KmlAddPointDelay;
65
 
67
 
66
u8 BeepTime;
68
u8 BeepTime;
Line 97... Line 99...
97
    GPIO_InitStructure.GPIO_Pin =               GPIO_Pin_6 | GPIO_Pin_7;
99
    GPIO_InitStructure.GPIO_Pin =               GPIO_Pin_6 | GPIO_Pin_7;
98
    GPIO_InitStructure.GPIO_Type =              GPIO_Type_PushPull ;
100
    GPIO_InitStructure.GPIO_Type =              GPIO_Type_PushPull ;
99
    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1  ;
101
    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1  ;
100
    GPIO_Init(GPIO5, &GPIO_InitStructure);
102
    GPIO_Init(GPIO5, &GPIO_InitStructure);
Line -... Line 103...
-
 
103
 
101
 
104
        //SD_SWITCH
102
    GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
105
    GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
103
    GPIO_InitStructure.GPIO_Pin =               GPIO_Pin_3;
106
    GPIO_InitStructure.GPIO_Pin =               GPIO_Pin_3;
104
    GPIO_InitStructure.GPIO_Type =              GPIO_Type_PushPull;
107
    GPIO_InitStructure.GPIO_Type =              GPIO_Type_PushPull;
105
    GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
108
    GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1;
Line 106... Line -...
106
    GPIO_Init(GPIO5, &GPIO_InitStructure);
-
 
107
 
109
    GPIO_Init(GPIO5, &GPIO_InitStructure);
108
                                                                 
110
 
109
}
111
}
110
  //
112
  //
Line 111... Line 113...
111
void OutputStartupData(void)
113
void OutputStartupData(void)
112
{
114
{
Line 113... Line 115...
113
   
115
   
Line 122... Line 124...
122
//----------------------------------------------------------------------------------------------------
124
//----------------------------------------------------------------------------------------------------
123
int main(void)
125
int main(void)
124
{
126
{
125
   static u8 oldCompassCalState = 0;
127
   static u8 oldCompassCalState = 0;
Line -... Line 128...
-
 
128
 
-
 
129
 
-
 
130
   static u8 kml_state = 0;
-
 
131
   u8 kml_cnt = 0;
-
 
132
   KML_Document_t       mydocument;
-
 
133
   File *file1;
-
 
134
 
-
 
135
   
-
 
136
   u8 str[80];
-
 
137
 
-
 
138
 
-
 
139
   KML_DocumentInit(&mydocument);                                       // Initialise the new kml-document for further use.     
-
 
140
 
126
 
141
 
127
  // SCU_MCLKSourceConfig(SCU_MCLK_OSC);
142
  // SCU_MCLKSourceConfig(SCU_MCLK_OSC);
128
  // SCU_PCLKDivisorConfig(SCU_PCLK_Div2);
143
  // SCU_PCLKDivisorConfig(SCU_PCLK_Div2);
Line 176... Line 191...
176
   while (!CheckDelay(TimerCompassUpdate));
191
   while (!CheckDelay(TimerCompassUpdate));
Line 177... Line 192...
177
   
192
   
178
   TimerCompassUpdate = SetDelay(5);
193
   TimerCompassUpdate = SetDelay(5);
Line -... Line 194...
-
 
194
   TimerI2CReadDelay = SetDelay(5);
-
 
195
 
179
   TimerI2CReadDelay = SetDelay(5);
196
   KmlAddPointDelay = SetDelay(250);
180
 
197
 
-
 
198
 
Line 181... Line 199...
181
/*  
199
   SerialPutString("\r\n---------------------------------------------");
182
   InitFat16();
-
 
183
 
-
 
184
   ReadSetting(1);
200
 
Line -... Line 201...
-
 
201
 
-
 
202
//   ReadSetting(1); 
-
 
203
   SerialPutString("\r\n---------------------------------------------\r\n\r\n");
185
 */  
204
   
186
   SerialPutString("Init done\n\r.");
205
   InitFat16();
187
   SerialPutString("--------------\n\n\r");
206
   
188
   
207
 
189
   for (;;)
208
   for (;;)
Line 236... Line 255...
236
          {  SendGPSPosAnforderung = 1;
255
          {  SendGPSPosAnforderung = 1;
237
         DatenUebertragung();
256
         DatenUebertragung();
Line 238... Line 257...
238
 
257
 
239
             TimerDebugDataDelay = SetDelay(500);
258
             TimerDebugDataDelay = SetDelay(500);
-
 
259
          }
-
 
260
 
240
          }
261
 
-
 
262
   // ----------- KML Timing -------------------------
-
 
263
          if(CheckDelay(KmlAddPointDelay))
-
 
264
          {
-
 
265
                KmlAddPointDelay = SetDelay(500);
-
 
266
 
-
 
267
                switch(kml_state)
-
 
268
                {
-
 
269
                        case 0:
-
 
270
                                if((GPS_Data.Flags & GPS_FIX) && (GPS_Data.Used_Sat >= GPS_SAT_MIN))
-
 
271
                                {
-
 
272
                                        if(str_Volume.state == INITIALIZED)                                                                                     // has the volume and filesystem been initialized?
-
 
273
                                        {
-
 
274
                                                if(KML_DocumentOpen("flight01.kml",&mydocument))                                                // create a new kml-document on the memorycard.
-
 
275
                                                {
-
 
276
                                                        SerialPutString("\r\nopening kml-file\r\nadding data");
-
 
277
                                                        kml_state = 1;
-
 
278
                                                }
-
 
279
                                        }
-
 
280
                                        else
-
 
281
                                        {
-
 
282
                                                InitFat16();
-
 
283
                                        }
-
 
284
                                }
-
 
285
                        break;                                                                                                                                                          // document.state will be changed to DOC_OPENED automatic.
-
 
286
       
-
 
287
                        case 1:                                                                                                                                                         // linestring opened, so datapoint (gps_coordinates) can be added to the document.
-
 
288
                                if(kml_cnt++ < 20)                                                                                                                              // add 10 datapoints to the document.
-
 
289
                                {
-
 
290
                                        KML_LoggGPSCoordinates(GPS_Data,&mydocument);
-
 
291
                                }
-
 
292
                                else                                                                                                                                                    // after the datapoints have been written to the document close the document.
-
 
293
                                {
-
 
294
                                        KML_DocumentClose(&mydocument);                                                
-
 
295
                                        SerialPutString("\r\nfile closed");
-
 
296
                                        kml_state = 2;
-
 
297
                                }
-
 
298
                        break;
-
 
299
 
241
  // ----------------------------------------------------
300
                        default:                                                                                                                                                        // all data has been written to card. open new document to add new data.
-
 
301
                }
-
 
302
          }
242
   }
303
        }
Line -... Line 304...
-
 
304
}
-
 
305