Subversion Repositories NaviCtrl

Rev

Rev 487 | Rev 490 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 487 Rev 489
Line 61... Line 61...
61
#include "91x_lib.h"
61
#include "91x_lib.h"
62
#include "main.h"
62
#include "main.h"
63
#include "config.h"
63
#include "config.h"
64
#include "menu.h"
64
#include "menu.h"
65
#include "GPS.h"
65
#include "GPS.h"
66
#include "i2c0.h"
-
 
67
#include "i2c1.h"
66
#include "i2c.h"
68
#include "uart0.h"
67
#include "uart0.h"
69
#include "uart1.h"
68
#include "uart1.h"
70
#include "uart2.h"
69
#include "uart2.h"
71
#include "timer1.h"
70
#include "timer1.h"
72
#include "timer2.h"
71
#include "timer2.h"
Line 248... Line 247...
248
        UART_InitStructure.UART_StopBits =                              UART_StopBits_1;
247
        UART_InitStructure.UART_StopBits =                              UART_StopBits_1;
249
        UART_InitStructure.UART_Parity =                                UART_Parity_No ;
248
        UART_InitStructure.UART_Parity =                                UART_Parity_No ;
250
        UART_InitStructure.UART_BaudRate =                              UART1_BAUD_RATE;
249
        UART_InitStructure.UART_BaudRate =                              UART1_BAUD_RATE;
251
        UART_InitStructure.UART_HardwareFlowControl =   UART_HardwareFlowControl_None;
250
        UART_InitStructure. UART_HardwareFlowControl =  UART_HardwareFlowControl_None;
252
        UART_InitStructure.UART_Mode =                                  UART_Mode_Tx_Rx;
251
        UART_InitStructure.UART_Mode =                                  UART_Mode_Tx_Rx;
253
// AVOID_I2C_COLLISION  UART_InitStructure.UART_FIFO =                                  UART_FIFO_Disable;
-
 
254
// AVOID_I2C_COLLISION  UART_InitStructure.UART_TxFIFOLevel =                   UART_FIFOLevel_1_8; // FIFO size 16 bytes, FIFO level 2 bytes
-
 
255
        UART_InitStructure.UART_FIFO =                                  UART_FIFO_Enable;
252
        UART_InitStructure.UART_FIFO =                                  UART_FIFO_Enable;
256
        UART_InitStructure.UART_TxFIFOLevel =                   UART_FIFOLevel_1_2;
253
        UART_InitStructure.UART_TxFIFOLevel =                   UART_FIFOLevel_1_2;
257
        UART_InitStructure.UART_RxFIFOLevel =                   UART_FIFOLevel_1_2; // FIFO size 16 bytes, FIFO level 8 bytes 
254
        UART_InitStructure.UART_RxFIFOLevel =                   UART_FIFOLevel_1_2;      // FIFO size 16 bytes, FIFO level 8 bytes
Line 258... Line 255...
258
 
255
 
Line 275... Line 272...
275
        UART_VersionInfo.SWMajor = VERSION_MAJOR;
272
        UART_VersionInfo.SWMajor = VERSION_MAJOR;
276
        UART_VersionInfo.SWMinor = VERSION_MINOR;
273
        UART_VersionInfo.SWMinor = VERSION_MINOR;
277
        UART_VersionInfo.SWPatch = VERSION_PATCH;
274
        UART_VersionInfo.SWPatch = VERSION_PATCH;
278
        UART_VersionInfo.ProtoMajor = VERSION_SERIAL_MAJOR;
275
        UART_VersionInfo.ProtoMajor = VERSION_SERIAL_MAJOR;
279
        UART_VersionInfo.ProtoMinor = VERSION_SERIAL_MINOR;
276
        UART_VersionInfo.ProtoMinor = VERSION_SERIAL_MINOR;
280
    UART_VersionInfo.HWMajor = Version_HW & 0x7f;
277
    UART_VersionInfo.HWMajor = Version_HW & 0x7F;
281
    UART_VersionInfo.reserved2 = 0;  
278
    UART_VersionInfo.reserved2 = 0;
282
        UART_VersionInfo.Flags = 0;
279
        UART_VersionInfo.Flags = 0;
283
        NaviData.Version = NAVIDATA_VERSION;
280
        NaviData.Version = NAVIDATA_VERSION;
Line 284... Line 281...
284
 
281
 
Line 653... Line 650...
653
/**************************************************************/
650
/**************************************************************/
654
void UART1_Transmit(void)
651
void UART1_Transmit(void)
655
{
652
{
656
        u8 tmp_tx;
653
        u8 tmp_tx;
657
        if(DebugUART != UART1) return;
654
        if(DebugUART != UART1) return;
658
// AVOID_I2C_COLLISION  if(I2C0_State != I2C_STATE_IDLE)   return;
-
 
659
        // if something has to be send and the txd fifo is not full
655
        // if something has to be send and the txd fifo is not full
660
        if(UART1_tx_buffer.Locked == TRUE)
656
        if(UART1_tx_buffer.Locked == TRUE)
661
        {
657
        {
662
                // while there is some space in the tx fifo
658
                // while there is some space in the tx fifo
663
                while(UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) != SET)
659
                while(UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) != SET)
Line 687... Line 683...
687
//$GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4,351.5,M,48.0,M,,*45
683
//$GPGGA,191410,4735.5634,N,00739.3538,E,1,04,4.4,351.5,M,48.0,M,,*45
688
//$GPGGA,092120.20,,,,,0,00,99.99,,,,,,*6C
684
//$GPGGA,092120.20,,,,,0,00,99.99,,,,,,*6C
689
//http://www.kowoma.de/gps/zusatzerklaerungen/NMEA.htm
685
//http://www.kowoma.de/gps/zusatzerklaerungen/NMEA.htm
690
void CreateNmeaGGA(void)
686
void CreateNmeaGGA(void)
691
{
687
{
692
 unsigned char array[200], i = 0, crc = 0, x;
688
        u8 array[200], i = 0, crc = 0, x;
693
 long tmp1, tmp2;
689
        s32 tmp1, tmp2;
-
 
690
 
694
 i += sprintf(array, "$GPGGA,");
691
        i += sprintf(array, "$GPGGA,");
695
// +++++++++++++++++++++++++++++++++++++++++++
692
        // +++++++++++++++++++++++++++++++++++++++++++
696
 if(SystemTime.Valid)
693
        if(SystemTime.Valid)
697
  {
694
        {
698
   i += sprintf(&array[i], "%02d%02d%02d.%02d,",SystemTime.Hour,SystemTime.Min,SystemTime.Sec,SystemTime.mSec/10);
695
                i += sprintf(&array[i], "%02d%02d%02d.%02d,", SystemTime.Hour, SystemTime.Min, SystemTime.Sec, SystemTime.mSec/10);
Line 703... Line 700...
703
  }
700
        }
704
// +++++++++++++++++++++++++++++++++++++++++++
701
        // +++++++++++++++++++++++++++++++++++++++++++
705
 if(GPSData.Flags & FLAG_GPSFIXOK)
702
        if(GPSData.Flags & FLAG_GPSFIXOK)
706
 {
703
        {
707
  tmp1 = abs(GPSData.Position.Latitude)/10000000L;
704
                tmp1 = abs(GPSData.Position.Latitude)/10000000L;
708
  i += sprintf(&array[i],"%02d",(int)tmp1);
705
                i += sprintf(&array[i],"%02d",(s16)tmp1);
Line 709... Line 706...
709
 
706
 
710
  tmp1 = abs(GPSData.Position.Latitude)%10000000L;
707
                tmp1 = abs(GPSData.Position.Latitude)%10000000L;
711
  tmp1 *= 6; // in Minuten
708
                tmp1 *= 6; // in Minuten
712
  tmp2 = tmp1 / 1000000L;
709
                tmp2 = tmp1 / 1000000L;
713
  i += sprintf(&array[i],"%02d",(int)tmp2);
710
                i += sprintf(&array[i],"%02d", (s16)tmp2);
714
  tmp2 = tmp1 % 1000000L;
711
                tmp2 = tmp1 % 1000000L;
715
  tmp2 /= 10; // eine Stelle zu viel
712
                tmp2 /= 10; // eine Stelle zu viel
Line 716... Line 713...
716
  i += sprintf(&array[i],".%05d,",(int)tmp2);
713
                i += sprintf(&array[i],".%05d,", (s16)tmp2);
717
 
714
 
718
  if(GPSData.Position.Latitude >= 0) i += sprintf(&array[i],"N,");
715
                if(GPSData.Position.Latitude >= 0) i += sprintf(&array[i],"N,");
Line 719... Line 716...
719
  else i += sprintf(&array[i],"S,");
716
                else i += sprintf(&array[i],"S,");
720
// +++++++++++++++++++++++++++++++++++++++++++
717
                // +++++++++++++++++++++++++++++++++++++++++++
Line 721... Line 718...
721
 
718
 
722
  tmp1 = abs(GPSData.Position.Longitude)/10000000L;
719
                tmp1 = abs(GPSData.Position.Longitude)/10000000L;
723
  i += sprintf(&array[i],"%03d",(int)tmp1);
720
                i += sprintf(&array[i],"%03d", (s16)tmp1);
724
 
721
 
725
  tmp1 = abs(GPSData.Position.Longitude)%10000000L;
722
                tmp1 = abs(GPSData.Position.Longitude)%10000000L;
726
  tmp1 *= 6; // in Minuten
723
                tmp1 *= 6; // in Minuten
727
  tmp2 = tmp1 / 1000000L;
724
                tmp2 = tmp1 / 1000000L;
Line 728... Line 725...
728
  i += sprintf(&array[i],"%02d",(int)tmp2);
725
                i += sprintf(&array[i],"%02d", (s16)tmp2);
729
  tmp2 = tmp1 % 1000000L;
726
                tmp2 = tmp1 % 1000000L;
730
  tmp2 /= 10; // eine Stelle zu viel
727
                tmp2 /= 10; // eine Stelle zu viel
731
  i += sprintf(&array[i],".%05d,",(int)tmp2);
728
                i += sprintf(&array[i],".%05d,", (s16)tmp2);
732
 
729
 
733
 
730
 
734
  if(GPSData.Position.Longitude >= 0) i += sprintf(&array[i],"E,");
731
                if(GPSData.Position.Longitude >= 0) i += sprintf(&array[i],"E,");
735
  else i += sprintf(&array[i],"W,");
732
                else i += sprintf(&array[i],"W,");
736
  i += sprintf(&array[i],"%d,",GPSData.SatFix);
733
                i += sprintf(&array[i],"%d,",GPSData.SatFix);
737
  i += sprintf(&array[i],"%d,",GPSData.NumOfSats);
734
                i += sprintf(&array[i],"%d,",GPSData.NumOfSats);
738
  i += sprintf(&array[i],"%d.%d,",GPSData.Position_Accuracy/100,abs(GPSData.Position_Accuracy%100));
735
                i += sprintf(&array[i],"%d.%d,",(s16)(GPSData.Position_Accuracy/100),abs(GPSData.Position_Accuracy%100));
739
//  i += sprintf(&array[i],"%d.%d,M,",GPSData.Position.Altitude/1000,abs(GPSData.Position.Altitude%1000)/100);
736
                //  i += sprintf(&array[i],"%d.%d,M,",GPSData.Position.Altitude/1000,abs(GPSData.Position.Altitude%1000)/100);
740
 tmp1 = NaviData.Altimeter / 2; // in dm
737
                tmp1 = NaviData.Altimeter / 2; // in dm
Line 758... Line 755...
758
//$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*13
755
//$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*13
759
//$GPRMC,HHMMSS.sss,A,BBBB.BBBB,b,LLLLL.LLLL,l,GG.G,RR.R,DDMMYY,M.M,m,F*PP
756
//$GPRMC,HHMMSS.sss,A,BBBB.BBBB,b,LLLLL.LLLL,l,GG.G,RR.R,DDMMYY,M.M,m,F*PP
Line 760... Line 757...
760
 
757
 
761
void CreateNmeaRMC(void)
758
void CreateNmeaRMC(void)
762
{
759
{
763
 unsigned char array[200], i = 0, crc = 0, x;
760
        u8 array[200], i = 0, crc = 0, x;
764
 int tmp_int;
761
        s16 tmp_int;
765
 long tmp1, tmp2;
762
        s32 tmp1, tmp2;
766
// +++++++++++++++++++++++++++++++++++++++++++
763
        // +++++++++++++++++++++++++++++++++++++++++++
767
 i += sprintf(array, "$GPRMC,");
764
        i += sprintf(array, "$GPRMC,");
768
// +++++++++++++++++++++++++++++++++++++++++++
765
        // +++++++++++++++++++++++++++++++++++++++++++
769
 if(SystemTime.Valid)
766
        if(SystemTime.Valid)
Line 776... Line 773...
776
  }
773
        }
777
 if(GPSData.Flags & FLAG_GPSFIXOK)
774
        if(GPSData.Flags & FLAG_GPSFIXOK)
778
 {
775
        {
779
// +++++++++++++++++++++++++++++++++++++++++++
776
                // +++++++++++++++++++++++++++++++++++++++++++
780
  tmp1 = abs(GPSData.Position.Latitude)/10000000L;
777
                tmp1 = abs(GPSData.Position.Latitude)/10000000L;
781
  i += sprintf(&array[i],"A,%02d",(int)tmp1); // Status: A = Okay  V = Warnung
778
                i += sprintf(&array[i],"A,%02d", (s16)tmp1); // Status: A = Okay  V = Warnung
Line 782... Line 779...
782
 
779
 
783
  tmp1 = abs(GPSData.Position.Latitude)%10000000L;
780
                tmp1 = abs(GPSData.Position.Latitude)%10000000L;
784
  tmp1 *= 6; // in Minuten
781
                tmp1 *= 6; // in Minuten
785
  tmp2 = tmp1 / 1000000L;
782
                tmp2 = tmp1 / 1000000L;
786
  i += sprintf(&array[i],"%02d",(int)tmp2);
783
                i += sprintf(&array[i],"%02d", (s16)tmp2);
787
  tmp2 = tmp1 % 1000000L;
784
                tmp2 = tmp1 % 1000000L;
788
  tmp2 /= 10; // eine Stelle zu viel
785
                tmp2 /= 10; // eine Stelle zu viel
789
  i += sprintf(&array[i],".%05d,",(int)tmp2);
786
                i += sprintf(&array[i],".%05d,", (s16)tmp2);
790
  if(GPSData.Position.Latitude >= 0) i += sprintf(&array[i],"N,");
787
                if(GPSData.Position.Latitude >= 0) i += sprintf(&array[i],"N,");
791
  else i += sprintf(&array[i],"S,");
788
                else i += sprintf(&array[i],"S,");
792
// +++++++++++++++++++++++++++++++++++++++++++
789
                // +++++++++++++++++++++++++++++++++++++++++++
793
  tmp1 = abs(GPSData.Position.Longitude)/10000000L;
790
                tmp1 = abs(GPSData.Position.Longitude)/10000000L;
Line 794... Line 791...
794
  i += sprintf(&array[i],"%03d",(int)tmp1);
791
                i += sprintf(&array[i],"%03d", (s16)tmp1);
795
 
792
 
796
  tmp1 = abs(GPSData.Position.Longitude)%10000000L;
793
                tmp1 = abs(GPSData.Position.Longitude)%10000000L;
797
  tmp1 *= 6; // in Minuten
794
                tmp1 *= 6; // in Minuten
798
  tmp2 = tmp1 / 1000000L;
795
                tmp2 = tmp1 / 1000000L;
799
  i += sprintf(&array[i],"%02d",(int)tmp2);
796
                i += sprintf(&array[i],"%02d", (s16)tmp2);
800
  tmp2 = tmp1 % 1000000L;
797
                tmp2 = tmp1 % 1000000L;
801
  tmp2 /= 10; // eine Stelle zu viel
798
                tmp2 /= 10; // eine Stelle zu viel
802
  i += sprintf(&array[i],".%05d,",(int)tmp2);
799
                i += sprintf(&array[i],".%05d,", (s16)tmp2);
803
  if(GPSData.Position.Longitude >= 0) i += sprintf(&array[i],"E,");
800
                if(GPSData.Position.Longitude >= 0) i += sprintf(&array[i],"E,");
804
  else i += sprintf(&array[i],"W,");
801
                else i += sprintf(&array[i],"W,");
805
// +++++++++++++++++++++++++++++++++++++++++++
802
                // +++++++++++++++++++++++++++++++++++++++++++