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