1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Flight - #ifdefs to make it work with both normal and bootloader packet formats.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1609 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-09-13 17:08:52 +00:00 committed by zedamota
parent 41a23a8eeb
commit 66560786f4

View File

@ -142,7 +142,6 @@ int32_t PIOS_USB_HID_ChangeConnectionState(uint32_t Connected)
return 0;
}
int32_t PIOS_USB_HID_Reenumerate()
{
/* Force USB reset and power-down (this will also release the USB pins for direct GPIO control) */
@ -198,11 +197,15 @@ void sendChunk()
{
if(size > PIOS_USB_HID_DATA_LENGTH)
size = PIOS_USB_HID_DATA_LENGTH;
#ifdef USB_HID
bufferGetChunkFromFront(&txBuffer, &tx_buffer[1], size+1);
tx_buffer[0] = 1; /* report ID */
#else
bufferGetChunkFromFront(&txBuffer, &tx_buffer[2], size);
tx_buffer[0] = 1; /* report ID */
tx_buffer[1] = size; /* valid data length */
#endif
/* Wait for any pending transmissions to complete */
while(GetEPTxStatus(ENDP1) == EP_TX_VALID)
{
@ -295,7 +298,6 @@ int32_t PIOS_USB_HID_RxBufferUsed(uint8_t id)
return bufferBufferedData(&rxBuffer);
}
/**
* @brief Callback used to indicate a transmission from device INto host completed
* Checks if any data remains, pads it into HID packet and sends.
@ -320,8 +322,11 @@ void PIOS_USB_HID_EP1_OUT_Callback(void)
PMAToUserBufferCopy((uint8_t *) rx_buffer, GetEPRxAddr(ENDP1 & 0x7F), DataLength);
/* The first byte is report ID (not checked), the second byte is the valid data length */
#ifdef USB_HID
bufferAddChunkToEnd(&rxBuffer, &rx_buffer[1], PIOS_USB_HID_DATA_LENGTH+1);
#else
bufferAddChunkToEnd(&rxBuffer, &rx_buffer[2], rx_buffer[1]);
#endif
SetEPRxStatus(ENDP1, EP_RX_VALID);
}