Subversion Repositories NaviCtrl

Rev

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

Rev 275 Rev 280
Line 97... Line 97...
97
u8 USB_Request_Display1         = FALSE;
97
u8 USB_Request_Display1         = FALSE;
98
u8 USB_Request_DebugData        = FALSE;
98
u8 USB_Request_DebugData        = FALSE;
99
u8 USB_Request_DebugLabel       = 255;
99
u8 USB_Request_DebugLabel       = 255;
100
u8 USB_Request_NaviData         = FALSE;
100
u8 USB_Request_NaviData         = FALSE;
101
u8 USB_Request_ErrorMessage     = FALSE;
101
u8 USB_Request_ErrorMessage     = FALSE;
102
u8 USB_Request_NewWaypoint      = FALSE;
-
 
103
u8 USB_Request_ReadWaypoint     = 255;
-
 
104
u8 USB_Request_Data3D           = FALSE;
102
u8 USB_Request_Data3D           = FALSE;
105
u8 USB_Request_Echo                 = FALSE;
103
u8 USB_Request_Echo                 = FALSE;
106
u8 USB_DisplayKeys = 0;
104
u8 USB_DisplayKeys = 0;
107
u8 USB_DisplayLine                      = 0;
105
u8 USB_DisplayLine                      = 0;
108
u8 USB_ConfirmFrame = 0;
106
u8 USB_ConfirmFrame = 0;
Line 170... Line 168...
170
/**************************************************************/
168
/**************************************************************/
171
void USB_ProcessRxData(void)
169
void USB_ProcessRxData(void)
172
{
170
{
173
        u8 c;
171
        u8 c;
174
        SerialMsg_t SerialMsg;
172
        SerialMsg_t SerialMsg;
175
        Waypoint_t * pWaypoint = NULL;
-
 
-
 
173
 
176
        // if data in the rxd buffer are not locked immediately return
174
        // if data in the rxd buffer are not locked immediately return
177
        // if rx buffer is not locked
175
        // if rx buffer is not locked
178
        if(USB_rx_buffer.Locked == FALSE)
176
        if(USB_rx_buffer.Locked == FALSE)
179
        {
177
        {
180
                //collect data from primary rx fifo
178
                //collect data from primary rx fifo
Line 202... Line 200...
202
 
200
 
203
                        case 'e': // request for the text of the error status
201
                        case 'e': // request for the text of the error status
204
                                USB_Request_ErrorMessage = TRUE;
202
                                USB_Request_ErrorMessage = TRUE;
Line 205... Line -...
205
                                break;
-
 
206
 
-
 
207
                        case 's'://  new target position
-
 
208
                                pWaypoint = (Waypoint_t*)SerialMsg.pData;
-
 
209
                                BeepTime = 300;
-
 
210
                                if(pWaypoint->Position.Status == NEWDATA)
-
 
211
                                {
-
 
212
                                        WPList_Clear(); // empty WPList
-
 
213
                                        WPList_Append(pWaypoint);
-
 
214
                                        GPS_pWaypoint = WPList_Begin();
-
 
215
                                }
-
 
216
                                break;
-
 
217
 
-
 
218
                        case 'w'://  Append Waypoint to List
-
 
219
                                {
-
 
220
                                        pWaypoint = (Waypoint_t*)SerialMsg.pData;
-
 
221
 
-
 
222
                                        if((pWaypoint->Position.Status == INVALID) && (pWaypoint->Index == 0))
-
 
223
                                        {
-
 
224
                                                WPList_Clear();
-
 
225
                                                GPS_pWaypoint = WPList_Begin();
-
 
226
                                                USB_Request_NewWaypoint = TRUE; // return new WP number
-
 
227
                                        }
-
 
228
                                        else
-
 
229
                                        {  // app current WP to the list
-
 
230
                                                if (pWaypoint->Index == (WPList_GetCount() + 1))
-
 
231
                                                {
-
 
232
                                                        WPList_Append(pWaypoint);
-
 
233
                                                        BeepTime = 500;
-
 
234
                                                        USB_Request_NewWaypoint = TRUE; // return new WP number
-
 
235
                                                }
-
 
236
                                        }
-
 
237
                                }
-
 
238
                                break;
-
 
239
 
-
 
240
                        case 'x'://  Read Waypoint from List
-
 
241
                                USB_Request_ReadWaypoint = SerialMsg.pData[0];
-
 
242
                                break;
203
                                break;
243
 
204
 
244
                        default:
205
                        default:
245
                                // unsupported command recieved
206
                                // unsupported command recieved
246
                                break;
207
                                break;
Line 492... Line 453...
492
        else if(USB_Request_ErrorMessage && (USB_tx_buffer.Locked == FALSE))
453
        else if(USB_Request_ErrorMessage && (USB_tx_buffer.Locked == FALSE))
493
        {
454
        {
494
                MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG));
455
                MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG));
495
                USB_Request_ErrorMessage = FALSE;
456
                USB_Request_ErrorMessage = FALSE;
496
        }
457
        }
497
        else if(USB_Request_NewWaypoint && (USB_tx_buffer.Locked == FALSE))
-
 
498
        {
-
 
499
                u8 WPNumber = WPList_GetCount();
-
 
500
                MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'W', NC_ADDRESS, 1, &WPNumber, sizeof(WPNumber));
-
 
501
                USB_Request_NewWaypoint = FALSE;
-
 
502
        }
-
 
503
        else if((USB_Request_ReadWaypoint != 0xFF) && (USB_tx_buffer.Locked == FALSE))
-
 
504
        {
-
 
505
                u8 WPNumber = WPList_GetCount();
-
 
506
                if (USB_Request_ReadWaypoint < WPNumber)
-
 
507
                {
-
 
508
                        MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'X', NC_ADDRESS, 3, &WPNumber, 1, &USB_Request_ReadWaypoint, 1, WPList_GetAt(USB_Request_ReadWaypoint), sizeof(Waypoint_t));
-
 
509
                }
-
 
510
                else
-
 
511
                {
-
 
512
                        MKProtocol_CreateSerialFrame(&USB_tx_buffer,'X', NC_ADDRESS, 1, &WPNumber, sizeof(WPNumber));
-
 
513
                }
-
 
514
                USB_Request_ReadWaypoint = 0xFF;
-
 
515
        }
-
 
516
        USB_Transmit(); // output pending bytes in tx buffer
458
        USB_Transmit(); // output pending bytes in tx buffer
517
}
459
}