Subversion Repositories NaviCtrl

Rev

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

Rev 91 Rev 92
Line 79... Line 79...
79
#define MK3MAG_ADDRESS 3
79
#define MK3MAG_ADDRESS 3
Line 80... Line 80...
80
 
80
 
81
#define FALSE   0
81
#define FALSE   0
Line -... Line 82...
-
 
82
#define TRUE    1
-
 
83
 
-
 
84
typedef struct
-
 
85
{
-
 
86
        u8 SWMajor;
-
 
87
        u8 SWMinor;
-
 
88
        u8 ProtoMajor;
-
 
89
        u8 ProtoMinor;
-
 
90
        u8 SWPatch;
-
 
91
        u8 Reserved[5];
-
 
92
}  __attribute__((packed)) UART_VersionInfo_t;
82
#define TRUE    1
93
 
83
 
94
 
84
u8 Request_SendFollowMe         = FALSE;
95
u8 Request_SendFollowMe         = FALSE;
85
u8 Request_VerInfo                      = FALSE;
96
u8 Request_VerInfo                      = FALSE;
86
u8 Request_ExternalControl      = FALSE;
97
u8 Request_ExternalControl      = FALSE;
Line 90... Line 101...
90
u8 Request_DebugLabel           = 255;
101
u8 Request_DebugLabel           = 255;
91
u8 Request_ChannelOnly          = FALSE;
102
u8 Request_ChannelOnly          = FALSE;
92
u8 Request_NaviData                     = FALSE;
103
u8 Request_NaviData                     = FALSE;
93
u8 Request_ErrorMessage     = FALSE;
104
u8 Request_ErrorMessage     = FALSE;
94
u8 Request_NewWaypoint          = FALSE;
105
u8 Request_NewWaypoint          = FALSE;
-
 
106
u8 Request_ReadWaypoint         = 255;
95
u8 Request_Data3D                    = FALSE;
107
u8 Request_Data3D                   = FALSE;
-
 
108
u8 Request_Echo                 = FALSE;
Line 96... Line 109...
96
 
109
 
Line 97... Line 110...
97
u8 DisplayLine = 0;
110
u8 DisplayLine = 0;
Line 103... Line 116...
103
volatile u8 rxd_buffer[RXD_BUFFER_LEN];
116
volatile u8 rxd_buffer[RXD_BUFFER_LEN];
104
volatile u8 txd_complete = TRUE;
117
volatile u8 txd_complete = TRUE;
105
volatile u8 ReceivedBytes = 0;
118
volatile u8 ReceivedBytes = 0;
106
volatile u8 CntCrcError = 0;
119
volatile u8 CntCrcError = 0;
107
volatile u8 *pRxData = NULL;
120
volatile u8 *pRxData = NULL;
108
volatile u8  RxDataLen = 0;
121
volatile u8 RxDataLen = 0;
109
volatile u8  SerialDataOkay = 0;
122
volatile u8 SerialLinkOkay = 0;
Line 110... Line 123...
110
 
123
 
Line 111... Line 124...
111
u8 text[100];
124
u8 text[100];
112
 
125
 
Line 118... Line 131...
118
ExternControl_t ExternControl;
131
ExternControl_t ExternControl;
119
UART_VersionInfo_t UART_VersionInfo;
132
UART_VersionInfo_t UART_VersionInfo;
120
NaviData_t NaviData;
133
NaviData_t NaviData;
121
Waypoint_t FollowMe;
134
Waypoint_t FollowMe;
122
Data3D_t Data3D;
135
Data3D_t Data3D;
-
 
136
u16 Echo; // 2 bytes recieved will be sent back as echo
Line 123... Line 137...
123
 
137
 
124
u32 DebugData_Timer;
138
u32 DebugData_Timer;
125
u32 DebugData_Interval = 5000;  // in ms
139
u32 DebugData_Interval = 5000;  // in ms
126
u32 NaviData_Timer;
140
u32 NaviData_Timer;
Line 240... Line 254...
240
        UART_VersionInfo.SWPatch = VERSION_PATCH;
254
        UART_VersionInfo.SWPatch = VERSION_PATCH;
241
        UART_VersionInfo.ProtoMajor = VERSION_SERIAL_MAJOR;
255
        UART_VersionInfo.ProtoMajor = VERSION_SERIAL_MAJOR;
242
        UART_VersionInfo.ProtoMinor = VERSION_SERIAL_MINOR;
256
        UART_VersionInfo.ProtoMinor = VERSION_SERIAL_MINOR;
Line 243... Line 257...
243
 
257
 
244
        NaviData.Version = NAVIDATA_VERSION;
-
 
245
        WPList_Clear();
-
 
-
 
258
        NaviData.Version = NAVIDATA_VERSION;
246
        GPS_pWaypoint = WPList_Begin();
259
 
247
        SerialPutString("\r\nUART1 init...ok");
260
        SerialPutString("\r\nUART1 init...ok");
Line 248... Line 261...
248
}
261
}
Line 336... Line 349...
336
                                                if((crc1 == rxd_buffer[ptr_rxd_buffer-2]) && (crc2 == rxd_buffer[ptr_rxd_buffer-1]))
349
                                                if((crc1 == rxd_buffer[ptr_rxd_buffer-2]) && (crc2 == rxd_buffer[ptr_rxd_buffer-1]))
337
                                                {   // checksum valid
350
                                                {   // checksum valid
338
                                                        rxd_buffer_locked = TRUE;               // lock the rxd buffer
351
                                                        rxd_buffer_locked = TRUE;               // lock the rxd buffer
339
                                                        ReceivedBytes = ptr_rxd_buffer + 1;     // store number of received bytes
352
                                                        ReceivedBytes = ptr_rxd_buffer + 1;     // store number of received bytes
340
                                                        rxd_buffer[ptr_rxd_buffer] = '\r';      // set termination character
353
                                                        rxd_buffer[ptr_rxd_buffer] = '\r';      // set termination character
341
                                                        SerialDataOkay = 250;
-
 
342
                                                        // if 2nd byte is an 'R' start bootloader
354
                                                        // if 2nd byte is an 'R' start bootloader
343
                                                        if(rxd_buffer[2] == 'R')
355
                                                        if(rxd_buffer[2] == 'R')
344
                                                        {
356
                                                        {
345
                                                                PowerOff();
357
                                                                PowerOff();
346
                                                                VIC_DeInit();
358
                                                                VIC_DeInit();
Line 532... Line 544...
532
        {
544
        {
533
                case NC_ADDRESS:  // own Slave Address
545
                case NC_ADDRESS:  // own Slave Address
Line 534... Line 546...
534
 
546
 
535
                switch(rxd_buffer[2])
547
                switch(rxd_buffer[2])
-
 
548
                {
-
 
549
                                case 'z': // connection checker
-
 
550
                                Echo = *((u16*)&pRxData[0]); // copy echo pattern
-
 
551
                                SerialLinkOkay = 250;            // reset SerialTimeout
-
 
552
                                Request_Echo = TRUE;
-
 
553
                                break;
536
                {
554
 
537
                        case 'e': // request for the text of the error status
555
                        case 'e': // request for the text of the error status
538
                                Request_ErrorMessage = TRUE;
556
                                Request_ErrorMessage = TRUE;
Line 539... Line 557...
539
                                break;
557
                                break;
Line 569... Line 587...
569
                                                DebugUART = UART0;
587
                                                DebugUART = UART0;
570
                                                break;
588
                                                break;
571
                                }
589
                                }
572
                                break;
590
                                break;
Line 573... Line 591...
573
 
591
 
574
                        case 'w'://  new PCPosition for GPSTargetList
592
                        case 'w'://  Append Waypoint to List
575
                                pWaypoint = (Waypoint_t*)&pRxData[0];
593
                                pWaypoint = (Waypoint_t*)&pRxData[0];
576
                                if(pWaypoint->Position.Status == INVALID)
594
                                if(pWaypoint->Position.Status == INVALID)
577
                                {  // clear WP List
595
                                {  // clear WP List
578
                                        WPList_Clear();
596
                                        WPList_Clear();
Line 586... Line 604...
586
                                        //SerialPutString("\r\nAdd WP to List\r\n");
604
                                        //SerialPutString("\r\nAdd WP to List\r\n");
587
                                }
605
                                }
588
                                Request_NewWaypoint = TRUE;
606
                                Request_NewWaypoint = TRUE;
589
                                break;
607
                                break;
Line -... Line 608...
-
 
608
 
-
 
609
                        case 'x'://  Read Waypoint from List
-
 
610
                                Request_ReadWaypoint = pRxData[0];
-
 
611
                                break;
590
 
612
 
591
                        default:
613
                        default:
592
                                // unsupported command recieved
614
                                // unsupported command recieved
593
                                break;
615
                                break;
594
                } // case NC_ADDRESS
616
                } // case NC_ADDRESS
Line 687... Line 709...
687
/**************************************************************/
709
/**************************************************************/
688
void UART1_TransmitTxData(void)
710
void UART1_TransmitTxData(void)
689
{
711
{
690
        if(!txd_complete || (DebugUART != UART1) ) return;
712
        if(!txd_complete || (DebugUART != UART1) ) return;
Line -... Line 713...
-
 
713
 
-
 
714
        if(Request_Echo && txd_complete)
-
 
715
        {
-
 
716
                SendOutData('Z', NC_ADDRESS, 1, &Echo, sizeof(Echo)); // answer the echo request
-
 
717
                Echo = 0; // reset echo value
-
 
718
                Request_Echo = FALSE;
691
 
719
        }
692
        if(Request_DebugLabel != 0xFF)
720
        if(Request_DebugLabel != 0xFF)
693
        {
721
        {
694
                SendOutData('A', NC_ADDRESS, 2, &Request_DebugLabel, sizeof(Request_DebugLabel), (u8 *) ANALOG_LABEL[Request_DebugLabel], 16);
722
                SendOutData('A', NC_ADDRESS, 2, &Request_DebugLabel, sizeof(Request_DebugLabel), (u8 *) ANALOG_LABEL[Request_DebugLabel], 16);
695
                Request_DebugLabel = 0xFF;
723
                Request_DebugLabel = 0xFF;
Line 771... Line 799...
771
                u8 WPNumber = WPList_GetCount();
799
                u8 WPNumber = WPList_GetCount();
772
                SendOutData('W', NC_ADDRESS, 1, &WPNumber, sizeof(WPNumber));
800
                SendOutData('W', NC_ADDRESS, 1, &WPNumber, sizeof(WPNumber));
773
                Request_NewWaypoint = FALSE;
801
                Request_NewWaypoint = FALSE;
774
        }
802
        }
Line -... Line 803...
-
 
803
 
-
 
804
        if((Request_ReadWaypoint != 0xFF) && txd_complete)
-
 
805
        {
-
 
806
                u8 WPNumber = WPList_GetCount();
-
 
807
                if (Request_ReadWaypoint < WPNumber)
-
 
808
                {
-
 
809
                        SendOutData('X', NC_ADDRESS, 3, &WPNumber, 1, &Request_ReadWaypoint, 1, WPList_GetAt(Request_ReadWaypoint), sizeof(Waypoint_t));
-
 
810
                }
-
 
811
                else
-
 
812
                {
-
 
813
                        SendOutData('X', NC_ADDRESS, 1, &WPNumber, sizeof(WPNumber));
-
 
814
                }
-
 
815
                Request_ReadWaypoint = 0xFF;
-
 
816
        }
775
 
817