Rev 112 | Rev 119 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 112 | Rev 114 | ||
---|---|---|---|
Line 156... | Line 156... | ||
156 | /* Process incomming data from debug uart */ |
156 | /* Process incomming data from debug uart */ |
157 | /**************************************************************/ |
157 | /**************************************************************/ |
158 | void USB_ProcessRxData(void) |
158 | void USB_ProcessRxData(void) |
159 | { |
159 | { |
160 | SerialMsg_t SerialMsg; |
160 | SerialMsg_t SerialMsg; |
- | 161 | Waypoint_t * pWaypoint = NULL; |
|
161 | // if data in the rxd buffer are not locked immediately return |
162 | // if data in the rxd buffer are not locked immediately return |
162 | DebugOut.Analog[4] = USB_rx_buffer.Position; |
- | |
163 | if((USB_rx_buffer.Locked == FALSE) || (DebugUART != UART1) ) return; |
163 | if((USB_rx_buffer.Locked == FALSE) || (DebugUART != UART1) ) return; |
164 | Waypoint_t * pWaypoint = NULL; |
- | |
Line 165... | Line 164... | ||
165 | 164 | ||
- | 165 | MKProtocol_DecodeSerialFrame(&USB_rx_buffer, &SerialMsg); // decode serial frame in rxd buffer |
|
166 | MKProtocol_DecodeSerialFrame(&USB_rx_buffer, &SerialMsg); // decode serial frame in rxd buffer |
166 | |
167 | if(SerialMsg.CmdID != 'z') SerialLinkOkay = 250; // reset SerialTimeout, but not in case of the "ping" |
167 | if(SerialMsg.CmdID != 'z') SerialLinkOkay = 250; // reset SerialTimeout, but not in case of the "ping" |
168 | switch(SerialMsg.Address) // check for Slave Address |
168 | switch(SerialMsg.Address) // check for Slave Address |
169 | { |
169 | { |
170 | case NC_ADDRESS: // own Slave Address |
170 | case NC_ADDRESS: // own Slave Address |
Line 326... | Line 326... | ||
326 | //----------------------------------------------------------------- |
326 | //----------------------------------------------------------------- |
327 | void USB_SendData(u8 *pdata, u16 count) |
327 | void USB_SendData(u8 *pdata, u16 count) |
328 | { |
328 | { |
329 | u8 i; |
329 | u8 i; |
330 | count++; |
330 | count++; |
- | 331 | u16 timeout = 0; |
|
Line 331... | Line 332... | ||
331 | 332 | ||
332 | for (i=0;i< (count/64)+1;i++) |
333 | for (i=0;i< (count/64)+1;i++) |
333 | { |
334 | { |
334 | while (_GetEPTxStatus(ENDP1) != EP_TX_NAK); |
335 | while (_GetEPTxStatus(ENDP1) != EP_TX_NAK){if (timeout++ > 60000) return;} |
335 | if (i < (count/64)) |
336 | if (i < (count/64)) |
336 | { |
337 | { |
337 | UserToPMABufferCopy(&pdata[i*64], ENDP1_TXADDR, 64); |
338 | UserToPMABufferCopy(&pdata[i*64], ENDP1_TXADDR, 64); |
338 | SetEPTxCount(ENDP1,64); |
339 | SetEPTxCount(ENDP1,64); |
Line 350... | Line 351... | ||
350 | /* Transmit tx buffer via usb */ |
351 | /* Transmit tx buffer via usb */ |
351 | /**************************************************************/ |
352 | /**************************************************************/ |
352 | void USB_Transmit(void) |
353 | void USB_Transmit(void) |
353 | { // nur blockweises kopieren des sendebuffers, nicht alles mit einem mal |
354 | { // nur blockweises kopieren des sendebuffers, nicht alles mit einem mal |
354 | // if something has to be send and the txd fifo is not full |
355 | // if something has to be send and the txd fifo is not full |
- | 356 | u16 i; |
|
355 | if(USB_tx_buffer.Locked == TRUE) |
357 | if(USB_tx_buffer.Locked == TRUE) |
356 | { |
358 | { |
- | 359 | if(_GetEPTxStatus(ENDP1) == EP_TX_NAK) |
|
357 | if(_GetEPTxStatus(ENDP1) == EP_TX_NAK) // ready to send |
360 | //if(_GetEPTxStatus(ENDP1) != EP_TX_VALID) // ready to send |
358 | { |
361 | { |
359 | if(USB_tx_buffer.Position < USB_tx_buffer.DataBytes) |
362 | if(USB_tx_buffer.Position < USB_tx_buffer.DataBytes) |
360 | { |
363 | { |
361 | u16 i = USB_tx_buffer.DataBytes - USB_tx_buffer.Position; // bytes to send |
364 | i = USB_tx_buffer.DataBytes - USB_tx_buffer.Position; // bytes to send |
362 | if(i > 64) i = 64; // limit packet size to 64 bytes |
365 | if(i > 64) i = 64; // limit packet size to 64 bytes |
363 | UserToPMABufferCopy(&(USB_tx_buffer.pData[USB_tx_buffer.Position]), ENDP1_TXADDR, i); |
366 | UserToPMABufferCopy(&(USB_tx_buffer.pData[USB_tx_buffer.Position]), ENDP1_TXADDR, i); |
364 | SetEPTxCount(ENDP1,i); |
367 | SetEPTxCount(ENDP1,i); |
- | 368 | SetEPTxValid(ENDP1); |
|
365 | USB_tx_buffer.Position += i; |
369 | USB_tx_buffer.Position += i; |
366 | } |
370 | } |
367 | } |
371 | } |
368 | if(USB_tx_buffer.Position >= USB_tx_buffer.DataBytes) // all bytes transfered |
372 | if(USB_tx_buffer.Position >= USB_tx_buffer.DataBytes) // all bytes transfered |
369 | { |
373 | { |