Subversion Repositories NaviCtrl

Rev

Rev 580 | Rev 881 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
41 ingob 1
/*#######################################################################################*/
2
/* !!! THIS IS NOT FREE SOFTWARE !!!                                                     */
3
/*#######################################################################################*/
4
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5
// + www.MikroKopter.com
6
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
360 holgerb 7
// + Software Nutzungsbedingungen (english version: see below)
8
// + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt -
9
// + Der Lizenzgeber räumt dem Kunden ein nicht-ausschließliches, zeitlich und räumlich* unbeschränktes Recht ein, die im den
10
// + Mikrocontroller verwendete Firmware für die Hardware Flight-Ctrl, Navi-Ctrl, BL-Ctrl, MK3Mag & PC-Programm MikroKopter-Tool 
11
// + - nachfolgend Software genannt - nur für private Zwecke zu nutzen.
12
// + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig.
41 ingob 13
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
360 holgerb 14
// + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im
15
// + Rahmen der Vertragsanbahnung und Vertragsdurchführung überlassenen Unterlagen stehen im Verhältnis der Vertragspartner ausschließlich dem Lizenzgeber zu.
16
// + Die in der Software enthaltenen Copyright-Vermerke, Markenzeichen, andere Rechtsvorbehalte, Seriennummern sowie
17
// + sonstige der Programmidentifikation dienenden Merkmale dürfen vom Kunden nicht verändert oder unkenntlich gemacht werden.
18
// + Der Kunde trifft angemessene Vorkehrungen für den sicheren Einsatz der Software. Er wird die Software gründlich auf deren
19
// + Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt.
20
// + Die Haftung des Lizenzgebers wird - soweit gesetzlich zulässig - begrenzt in Höhe des typischen und vorhersehbaren
21
// + Schadens. Die gesetzliche Haftung bei Personenschäden und nach dem Produkthaftungsgesetz bleibt unberührt. Dem Lizenzgeber steht jedoch der Einwand 
22
// + des Mitverschuldens offen.
23
// + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet.
24
// + Er wird die Software gründlich auf deren Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt.
25
// + Der Kunde wird er seine Daten vor Einsatz der Software nach dem Stand der Technik sichern.
26
// + Der Kunde ist darüber unterrichtet, dass der Lizenzgeber seine Daten im zur Vertragsdurchführung erforderlichen Umfang
27
// + und auf Grundlage der Datenschutzvorschriften erhebt, speichert, verarbeitet und, sofern notwendig, an Dritte übermittelt.
28
// + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software.
29
// + #### ENDE DER NUTZUNGSBEDINGUNGEN ####'
30
// +  Hinweis: Informationen über erweiterte Nutzungsrechte (wie z.B. Nutzung für nicht-private Zwecke) sind auf Anfrage per Email an info(@)hisystems.de verfügbar.
41 ingob 31
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
360 holgerb 32
// + Software LICENSING TERMS
41 ingob 33
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
360 holgerb 34
// + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor -
35
// + The Licensor grants the customer a non-exclusive license to use the microcontroller firmware of the Flight-Ctrl, Navi-Ctrl, BL-Ctrl, and MK3Mag hardware 
36
// + (the Software) exclusively for private purposes. The License is unrestricted with respect to time and territory*.
37
// + The Software may only be used with the Licensor's products.
38
// + The Software provided by the Licensor is protected by copyright. With respect to the relationship between the parties to this
39
// + agreement, all rights pertaining to the Software and other documents provided during the preparation and execution of this
40
// + agreement shall be the property of the Licensor.
41
// + The information contained in the Software copyright notices, trademarks, other legal reservations, serial numbers and other
42
// + features that can be used to identify the program may not be altered or defaced by the customer.
43
// + The customer shall be responsible for taking reasonable precautions
44
// + for the safe use of the Software. The customer shall test the Software thoroughly regarding its suitability for the
45
// + intended purpose before implementing it for actual operation. The Licensor's liability shall be limited to the extent of typical and
46
// + foreseeable damage to the extent permitted by law, notwithstanding statutory liability for bodily injury and product
47
// + liability. However, the Licensor shall be entitled to the defense of contributory negligence.
48
// + The customer will take adequate precautions in the case, that the software is not working properly. The customer will test
49
// + the software for his purpose before any operational usage. The customer will backup his data before using the software.
50
// + The customer understands that the Licensor collects, stores and processes, and, where required, forwards, customer data
51
// + to third parties to the extent necessary for executing the agreement, subject to applicable data protection and privacy regulations.
52
// + *) The territory aspect only refers to the place where the Software is used, not its programmed range.
53
// + #### END OF LICENSING TERMS ####
54
// + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de.
41 ingob 55
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56
//#include <stdio.h>
57
#include "91x_lib.h"
136 killagreg 58
#include "config.h"
41 ingob 59
#include "uart1.h"
190 killagreg 60
#include "mkprotocol.h"
41 ingob 61
 
190 killagreg 62
// the tx buffer
63
#define UART2_TX_BUFFER_LEN  150
64
u8 UART2_tbuffer[UART2_TX_BUFFER_LEN];
65
Buffer_t UART2_tx_buffer;
66
 
880 holgerb 67
unsigned char NMEA_In_Lat_Txt[16];
68
unsigned char NMEA_In_Lon_Txt[16];
69
unsigned char NMEA_In_Alt_Txt[10];
70
unsigned char NMEA_In_Fix_Txt[10];
71
u16 NMEA_cnt,NMEA_cnt_gga;
72
 
73
 
41 ingob 74
/********************************************************/
75
/*                  Initialize UART2                    */
76
/********************************************************/
77
void UART2_Init(void)
78
{
79
    UART_InitTypeDef UART_InitStructure;
80
        GPIO_InitTypeDef GPIO_InitStructure;
81
 
580 holgerb 82
//      UART1_PutString("\r\n UART2 init...");
41 ingob 83
 
190 killagreg 84
        // initialize txd buffer
85
        Buffer_Init(&UART2_tx_buffer, UART2_tbuffer, UART2_TX_BUFFER_LEN);
86
 
41 ingob 87
        SCU_APBPeriphClockConfig(__UART2, ENABLE);  // Enable the UART2 Clock
88
 
89
        SCU_APBPeriphClockConfig(__GPIO5, ENABLE);  // Enable the GPIO5 Clock
90
    /*Configure UART2_Rx pin GPIO5.2*/
91
        GPIO_StructInit(&GPIO_InitStructure);
92
        GPIO_InitStructure.GPIO_Direction =     GPIO_PinInput;
93
    GPIO_InitStructure.GPIO_Pin =                       GPIO_Pin_2;
94
    GPIO_InitStructure.GPIO_Type =                      GPIO_Type_PushPull;
196 killagreg 95
    GPIO_InitStructure.GPIO_IPInputConnected =  GPIO_IPInputConnected_Enable;
41 ingob 96
    GPIO_InitStructure.GPIO_Alternate =         GPIO_InputAlt1; // UART2_RxD
97
    GPIO_Init(GPIO5, &GPIO_InitStructure);
98
 
99
        SCU_APBPeriphClockConfig(__GPIO3, ENABLE);  // Enable the GPIO3 Clock
100
    /*Configure UART2_Tx pin GPIO3.0*/
101
        GPIO_StructInit(&GPIO_InitStructure);
102
        GPIO_InitStructure.GPIO_Direction =     GPIO_PinOutput;
103
    GPIO_InitStructure.GPIO_Pin =                       GPIO_Pin_0;
104
    GPIO_InitStructure.GPIO_Type =                      GPIO_Type_PushPull;
105
    GPIO_InitStructure.GPIO_Alternate =         GPIO_OutputAlt2; // UART2_TX
106
    GPIO_Init(GPIO3, &GPIO_InitStructure);
107
 
108
 
109
        /* UART2 configured as follow:
110
          - Word Length = 8 Bits
111
          - One Stop Bit
112
          - No parity
113
          - BaudRate = 57600 baud
114
          - Hardware flow control Disabled
115
          - Receive and transmit enabled
116
          - Receive and transmit FIFOs are Disabled
117
    */
118
        UART_StructInit(&UART_InitStructure);
119
    UART_InitStructure.UART_WordLength =                        UART_WordLength_8D;
120
    UART_InitStructure.UART_StopBits =                          UART_StopBits_1;
121
    UART_InitStructure.UART_Parity =                            UART_Parity_No ;
110 killagreg 122
    UART_InitStructure.UART_BaudRate =                          UART2_BAUD_RATE;
41 ingob 123
    UART_InitStructure.UART_HardwareFlowControl =       UART_HardwareFlowControl_None;
124
    UART_InitStructure.UART_Mode =                                      UART_Mode_Tx_Rx;
125
    UART_InitStructure.UART_FIFO =                                      UART_FIFO_Enable;
126
    UART_InitStructure.UART_TxFIFOLevel =                       UART_FIFOLevel_1_2;
139 killagreg 127
    UART_InitStructure.UART_RxFIFOLevel =                       UART_FIFOLevel_1_2;
41 ingob 128
 
129
        UART_DeInit(UART2);     // reset uart 2 to default
130
    UART_Init(UART2, &UART_InitStructure);  // initialize uart 2
131
 
132
        // enable uart 2 interrupts selective
133
    UART_ITConfig(UART2, UART_IT_Receive | UART_IT_ReceiveTimeOut, ENABLE);
134
        UART_Cmd(UART2, ENABLE); // enable uart 2
136 killagreg 135
        // configure the uart 2 interupt line
136
        VIC_Config(UART2_ITLine, VIC_IRQ, PRIORITY_UART2);
41 ingob 137
        // enable the uart 2 IRQ
138
        VIC_ITCmd(UART2_ITLine, ENABLE);
139
 
580 holgerb 140
//      UART1_PutString("ok");
41 ingob 141
}
142
 
143
 
144
void UART2_Deinit(void)
145
{
146
        GPIO_InitTypeDef GPIO_InitStructure;
147
 
110 killagreg 148
        UART1_PutString("\r\n UART2 deinit...");
41 ingob 149
        VIC_ITCmd(UART2_ITLine, DISABLE); // disable the uart 2 IRQ
150
        UART_Cmd(UART2, DISABLE); // disable uart 2
151
        UART_DeInit(UART2);     // reset uart 0 to default
152
 
153
        SCU_APBPeriphClockConfig(__UART2, DISABLE);  // disable the UART2 Clock
154
 
155
        SCU_APBPeriphClockConfig(__GPIO5, ENABLE);
156
        // unmap UART2 from FC
157
        // set port pin 5.2 (serial data from FC) to input and disconnect from IP
158
        GPIO_StructInit(&GPIO_InitStructure);
159
        GPIO_InitStructure.GPIO_Direction =     GPIO_PinInput;
160
    GPIO_InitStructure.GPIO_Pin =                       GPIO_Pin_2;
161
    GPIO_InitStructure.GPIO_Type =                      GPIO_Type_PushPull;
196 killagreg 162
    GPIO_InitStructure.GPIO_IPInputConnected =  GPIO_IPInputConnected_Disable;
41 ingob 163
    GPIO_InitStructure.GPIO_Alternate =         GPIO_InputAlt1;
164
    GPIO_Init(GPIO5, &GPIO_InitStructure);
165
 
166
        SCU_APBPeriphClockConfig(__GPIO3, ENABLE);
167
        // set port pin 3.0 (serial data to FC) to input and disconnect from IP
168
        GPIO_StructInit(&GPIO_InitStructure);
169
        GPIO_InitStructure.GPIO_Direction =     GPIO_PinInput;
170
    GPIO_InitStructure.GPIO_Pin =                       GPIO_Pin_0;
171
    GPIO_InitStructure.GPIO_Type =                      GPIO_Type_PushPull;
196 killagreg 172
        GPIO_InitStructure.GPIO_IPInputConnected =      GPIO_IPInputConnected_Disable;
41 ingob 173
    GPIO_InitStructure.GPIO_Alternate =         GPIO_InputAlt1;
174
    GPIO_Init(GPIO3, &GPIO_InitStructure);
175
 
110 killagreg 176
        UART1_PutString("ok");
41 ingob 177
}
178
 
880 holgerb 179
 
180
void NEMA_Parser(unsigned char data)
181
{
182
static u16 state = 0, fx,la,lo,i,a;
183
if(data  == '$') state = 0;
184
static u32 latitude;
185
static unsigned char lat_txt[16], lon_txt[16],fix_txt[10],alt_txt[10];
186
 
187
//$GPGGA,HHMMSS.ss,BBBB.BBBB,b,LLLLL.LLLL,l,Q,NN,D.D,H.H,h,G.G,g,A.A,RRRR*PP
188
//$GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4,351.5,M,48.0,M,,*45
189
//$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*13
190
//$GPRMC,HHMMSS.sss,A,BBBB.BBBB,b,LLLLL.LLLL,l,GG.G,RR.R,DDMMYY,M.M,m,F*PP
191
//http://www.kowoma.de/gps/zusatzerklaerungen/NMEA.htm
192
 switch(state)
193
  {
194
   case 0: if(data == '$') state++;// $
195
                   fx = 0;
196
                   la = 1;
197
                   lo = 1;
198
                   fix_txt[0] = 0;
199
                   lat_txt[0] = 0;lon_txt[0] = 0;alt_txt[0] = 0;
200
                   break;
201
   case 1: if(data == 'G') state++;// $G
202
                   break;
203
   case 2: if(data == 'P') state++;// $GP
204
                   NMEA_cnt = 3;
205
                   break;
206
//+++++++++++++++++++++++++++++++++++++++++++++++++++
207
   case 3: if(data == 'R') state++;// $GPR
208
                   if(data == 'G') state = 6;// $GPG
209
                   break;
210
   case 4: if(data == 'M') state++;// $GPRM
211
                   break;
212
   case 5: if(data == 'C') state = 100;// $GPRMC
213
                   break;
214
//+++++++++++++++++++++++++++++++++++++++++++++++++++
215
   case 6: if(data == 'G') state++;// $GPGG
216
                   break;
217
   case 7: if(data == 'A') state = 200;// $GPGGA
218
                   break;
219
//+++++++++++++++++++++++++++++++++++++++++++++++++++
220
// $GPRMC        (RMC = recommended minimum sentence C, empfohlener Minimumdatensatz)
221
//+++++++++++++++++++++++++++++++++++++++++++++++++++
222
/*
223
   case 100: if(data == ',') state++;   // $GPRMC,
224
                   NMEA_cnt_rmc %= 1000;
225
                   NMEA_cnt_rmc++;
226
                   break;
227
   case 101: if(data == ',') state = 110;       // $GPRMC,162614.123, // time scipped
228
                   break;
229
   case 110: if(data == ',') state++;
230
                         else fix_txt[0] = data;                // $GPRMC,162614.123,A   A = Active  V = Void
231
                   break;
232
   case 111: if(data == ',') state++;           // / $GPRMC,162614.123,A,
233
                   break;        
234
   case 112: if(data == ',') state++;           // $GPRMC,162614.123,A,5317.123456789    Latitude
235
                         else
236
                         {
237
                   if(la < 16) lat_txt[la++] = data;
238
                           lat_txt[la] = 0;
239
                         }
240
                   break;
241
   case 113: if(data == ',') state++;           //$GPRMC,162614.123,A,5230.5900,N,
242
                         if(data == 'N') lat_txt[0] = '+';
243
                         if(data == 'S') lat_txt[0] = '-';
244
                   break;        
245
   case 114: if(data == ',') state++;           //$GPRMC,162614.123,A,5230.5900,N,00722.123456789
246
                         else
247
                         {
248
                   if(lo < 16) lon_txt[lo++] = data;
249
                           lon_txt[lo] = 0;
250
                         }
251
                   break;
252
   case 115: if(data == ',') state++;           //$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,
253
                         if(data == 'O') lon_txt[0] = '+';
254
                         if(data == 'E') lon_txt[0] = '+';
255
                         if(data == 'W') lon_txt[0] = '-';
256
                   break;        
257
   case 116: if(data == ',') state++;           //$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,10.0,
258
                   break;        
259
   case 117: if(data == ',') state++;           //$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,10.0,90.0,
260
                   break;        
261
   case 118: if(data == ',') state++;           //$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,
262
                   break;        
263
   case 119:
264
           if(data == ',')
265
            {
266
                        state++;                //$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,
267
                        NMEA_In_Lat_Txt[0] = lat_txt[0];
268
                        NMEA_In_Lat_Txt[1] = lat_txt[1];
269
                        NMEA_In_Lat_Txt[2] = lat_txt[2];
270
                        NMEA_In_Lat_Txt[3] = '.';
271
                        NMEA_In_Lat_Txt[4] = lat_txt[3];
272
                        NMEA_In_Lat_Txt[5] = lat_txt[4];
273
                        for(i=5; i<16; i++)
274
                         {
275
                          if(lat_txt[i] == '.') i++;
276
                          NMEA_In_Lat_Txt[i] = lat_txt[i];
277
                         }
278
                        NMEA_In_Lon_Txt[0] = lon_txt[0];
279
                        NMEA_In_Lon_Txt[1] = lon_txt[1];
280
                        NMEA_In_Lon_Txt[2] = lon_txt[2];
281
                        NMEA_In_Lon_Txt[3] = lon_txt[3];
282
                        NMEA_In_Lon_Txt[4] = '.';
283
                        NMEA_In_Lon_Txt[5] = lon_txt[4];
284
                        NMEA_In_Lon_Txt[6] = lon_txt[5];
285
                        for(i=5; i<16; i++)
286
                         {
287
                          if(lon_txt[i] == '.') i++;
288
                          NMEA_In_Lon_Txt[i] = lon_txt[i];
289
                         }
290
                        }
291
                   break;        
292
   case 120: if(data == ',') state++;           //$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,
293
                   break;        
294
   case 121:  state = 0;                //$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*13
295
                   fix_txt[1] = data;
296
                   fix_txt[2] = 0;
297
                   NMEA_In_Fix_Txt[0] = fix_txt[0];
298
                   NMEA_In_Fix_Txt[1] = fix_txt[1];
299
                   break;        
300
*/
301
//+++++++++++++++++++++++++++++++++++++++++++++++++++
302
// $GPGGA 
303
//+++++++++++++++++++++++++++++++++++++++++++++++++++
304
   case 200: if(data == ',') state++;   //$GPGGA,
305
                   NMEA_cnt_gga %= 1000;
306
                   NMEA_cnt_gga++;
307
                   break;
308
   case 201: if(data == ',') state = 212;       //$GPGGA,191410 // time scipped
309
                   break;
310
   case 212: if(data == ',') state++;           //$GPGGA,191410,4735.5634    Latitude
311
                         else
312
                         {
313
                   if(la < 16) lat_txt[la++] = data;
314
                           lat_txt[la] = 0;
315
                         }
316
                   break;
317
   case 213: if(data == ',') state++;           //$GPGGA,191410,4735.5634,N
318
                         if(data == 'N') lat_txt[0] = '+';
319
                         if(data == 'S') lat_txt[0] = '-';
320
                   break;        
321
   case 214: if(data == ',') state++;           //$GPGGA,191410,4735.5634,N,00739.3538
322
                         else
323
                         {
324
                   if(lo < 16) lon_txt[lo++] = data;
325
                           lon_txt[lo] = 0;
326
                         }
327
                   break;
328
   case 215: if(data == ',') state++;           //$GPGGA,191410,4735.5634,N,00739.3538,E
329
                         if(data == 'O') lon_txt[0] = '+';
330
                         if(data == 'E') lon_txt[0] = '+';
331
                         if(data == 'W') lon_txt[0] = '-';
332
                         i = 0; a = 0;
333
                   break;        
334
   case 216:                                                             //$GPGGA,191410,4735.5634,N,00739.3538,E,1 -> 0 = No Fix, 1, = Fix, 2 = DGPS, ...
335
   case 217:                                                             //$GPGGA,191410,4735.5634,N,00739.3538,E,1,04 -> Anzahl Sat
336
   case 218:                                                             //$GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4 HDOP
337
             if(data == ',')
338
                          {
339
                           if(++state != 219)    // letztes Leerzeiten entfernen
340
                             fix_txt[i++] = ' '; // komma durch leerzeichen ersetzten
341
                          }
342
                          else if(i < 9) fix_txt[i++] = data;
343
                          fix_txt[i] = 0;
344
                   break;        
345
   case 219: if(data == ',') state++;           //$GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4,351.5
346
                        else if(a < 9) alt_txt[a++] = data;
347
                        fix_txt[i] = 0;
348
                   break;        
349
   case 220:
350
           if(data == ',')
351
            {
352
                        state++;                                                        //$GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4,351.5,M
353
                        NMEA_In_Lat_Txt[0] = lat_txt[0];
354
                        NMEA_In_Lat_Txt[1] = lat_txt[1];
355
                        NMEA_In_Lat_Txt[2] = lat_txt[2];
356
                        NMEA_In_Lat_Txt[3] = '.';
357
                        NMEA_In_Lat_Txt[4] = lat_txt[3];
358
                        NMEA_In_Lat_Txt[5] = lat_txt[4];
359
                        for(i=5; i<16; i++)
360
                         {
361
                          if(lat_txt[i] == '.') i++;
362
                          NMEA_In_Lat_Txt[i] = lat_txt[i];
363
                         }
364
                        NMEA_In_Lon_Txt[0] = lon_txt[0];
365
                        NMEA_In_Lon_Txt[1] = lon_txt[1];
366
                        NMEA_In_Lon_Txt[2] = lon_txt[2];
367
                        NMEA_In_Lon_Txt[3] = lon_txt[3];
368
                        NMEA_In_Lon_Txt[4] = '.';
369
                        NMEA_In_Lon_Txt[5] = lon_txt[4];
370
                        NMEA_In_Lon_Txt[6] = lon_txt[5];
371
                        for(i=6; i<16; i++)
372
                         {
373
                          if(lon_txt[i] == '.') i++;
374
                          NMEA_In_Lon_Txt[i] = lon_txt[i];
375
                         }
376
                        }
377
                        for(i=0; i<10; i++)
378
                         {
379
                          NMEA_In_Alt_Txt[i] = alt_txt[i];
380
                      NMEA_In_Fix_Txt[i] = fix_txt[i];
381
                         }
382
                   break;        
383
   default: state = 0;
384
  }
385
}
386
 
387
 
41 ingob 388
/********************************************************/
389
/*            UART2 Interrupt Handler                   */
390
/********************************************************/
391
void UART2_IRQHandler(void)
392
{
393
        // if receive irq or receive timeout irq has occured
394
        if((UART_GetITStatus(UART2, UART_IT_Receive) != RESET) || (UART_GetITStatus(UART2, UART_IT_ReceiveTimeOut) != RESET) )
395
        {
396
                UART_ClearITPendingBit(UART2, UART_IT_Receive);                 // clear receive interrupt flag
397
                UART_ClearITPendingBit(UART2, UART_IT_ReceiveTimeOut);  // clear receive timeout interrupt flag
398
 
399
                // if debug UART is UART2
400
                if (DebugUART == UART2)
401
                {       // forward received data to the UART1 tx buffer
402
                        while(UART_GetFlagStatus(UART2, UART_FLAG_RxFIFOEmpty) != SET)
403
                        {
404
                                // wait for space in the tx buffer of the UART1
405
                                while(UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) == SET) {};
406
                                // move the byte from the rx buffer of UART2 to the tx buffer of UART1
880 holgerb 407
if(UART_VersionInfo.HWMajor < 30)       UART_SendData(UART1, UART_ReceiveData(UART2)); 
408
else UART_ReceiveData(UART2);
41 ingob 409
                        }
410
                }
411
                else
412
                {
413
                        // ignore serial data from the FC
414
                        while(UART_GetFlagStatus(UART2, UART_FLAG_RxFIFOEmpty) != SET)
190 killagreg 415
                        {
880 holgerb 416
                         unsigned char c;
417
                         c = UART_ReceiveData(UART2);
418
                         if(UART_VersionInfo.HWMajor >= 30) NEMA_Parser(c);
190 killagreg 419
                        }
41 ingob 420
                }
421
        } // eof receive irq or receive timeout irq
195 killagreg 422
 
380 holgerb 423
 
378 holgerb 424
        VIC1->VAR = 0xFF; // write any value to VIC1 Vector address register
41 ingob 425
}
190 killagreg 426
 
427
/**************************************************************/
428
/*         Transmit tx buffer via uart2                       */
429
/**************************************************************/
430
void UART2_Transmit(void)
431
{
432
        u8 tmp_tx;
433
        if(DebugUART == UART2) return; // no data output if debug uart is rederected to UART2
434
        // if something has to be send and the txd fifo is not full
435
        if((UART2_tx_buffer.Locked == TRUE) && (UART_GetFlagStatus(UART2, UART_FLAG_TxFIFOFull) == RESET))
436
        {
437
                tmp_tx = UART2_tx_buffer.pData[UART2_tx_buffer.Position++]; // read next byte from txd buffer
438
                UART_SendData(UART2, tmp_tx); // put character to txd fifo
439
                // if terminating character or end of txd buffer reached
440
                if((tmp_tx == '\r') || (UART2_tx_buffer.Position == UART2_tx_buffer.Size))
441
                {
442
                        Buffer_Clear(&UART2_tx_buffer);
443
                }
444
        }
445
}
446
 
447
/**************************************************************/
448
/* Send the answers to incomming commands at the uart2        */
449
/**************************************************************/
450
void UART2_TransmitTxData(void)
451
{
452
        if(DebugUART == UART2) return;
453
        UART2_Transmit(); // output pending bytes in tx buffer
454
}
455
 
456
 
457
void UART2_ProcessRxData(void)
458
{
459
 
460
}