KugleFirmware/Libraries/Periphirals/USBCDC/usbd_cdc_if.c
/**
  * @brief  Data received over USB OUT endpoint are sent over CDC interface
  *         through this function.
  *
  *         @note
  *         This function will block any OUT packet reception on USB endpoint
  *         untill exiting this function. If you exit this function before transfer
  *         is complete on CDC interface (ie. using DMA controller) it will result
  *         in receiving more data while previous ones are still not sent.
  *
  * @param  Buf: Buffer of data to be received
  * @param  Len: Number of data received (in bytes)
  * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
  */
@brief  Data received over USB OUT endpoint are sent over CDC interface
through this function.

@note
This function will block any OUT packet reception on USB endpoint
untill exiting this function. If you exit this function before transfer
is complete on CDC interface  it will result
in receiving more data while previous ones are still not sent.

@param  Buf: Buffer of data to be received
@param  Len: Number of data received (in bytes)
@retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
@brief Data received over USB OUT endpoint are sent over CDC interface through this function . @note This function will block any OUT packet reception on USB endpoint untill exiting this function . If you exit this function before transfer is complete on CDC interface it will result in receiving more data while previous ones are still not sent . @param Buf : Buffer of data to be received @param Len : Number of data received ( in bytes ) @retval Result of the operation : USBD_OK if all operations are OK else USBD_FAIL
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
{
  portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
  uint32_t remainingLength = *Len;
  uint16_t copyLength;
  uint8_t * copyPtr = Buf;
  while (remainingLength > 0) {
	  copyLength = remainingLength;
	  if (copyLength > USB_PACKAGE_MAX_SIZE) copyLength = USB_PACKAGE_MAX_SIZE;
	  memcpy(tmpPackage.data, copyPtr, copyLength);
	  tmpPackage.length = copyLength;
	  if (ReceiveQueue)
		  xQueueSendFromISR(ReceiveQueue, (void *)&tmpPackage, &xHigherPriorityTaskWoken);
	  copyPtr += copyLength;
	  remainingLength -= copyLength;
  }
  if (ReceiveSemaphore)
	  xSemaphoreGiveFromISR( ReceiveSemaphore, &xHigherPriorityTaskWoken );
  USBD_CDC_SetRxBuffer(hUsbDeviceFS, &Buf[0]);
  USBD_CDC_ReceivePacket(hUsbDeviceFS);
  portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
  return (USBD_OK);
}
static int8_t CDC_Receive_FS ( uint8_t * Buf , uint32_t * Len ) { portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE ; uint32_t remainingLength = * Len ; uint16_t copyLength ; uint8_t * copyPtr = Buf ; while ( remainingLength > 0 ) { copyLength = remainingLength ; if ( copyLength > USB_PACKAGE_MAX_SIZE ) copyLength = USB_PACKAGE_MAX_SIZE ; memcpy ( tmpPackage . data , copyPtr , copyLength ) ; tmpPackage . length = copyLength ; if ( ReceiveQueue ) xQueueSendFromISR ( ReceiveQueue , ( void * ) & tmpPackage , & xHigherPriorityTaskWoken ) ; copyPtr += copyLength ; remainingLength -= copyLength ; } if ( ReceiveSemaphore ) xSemaphoreGiveFromISR ( ReceiveSemaphore , & xHigherPriorityTaskWoken ) ; USBD_CDC_SetRxBuffer ( hUsbDeviceFS , & Buf [ 0 ] ) ; USBD_CDC_ReceivePacket ( hUsbDeviceFS ) ; portYIELD_FROM_ISR ( xHigherPriorityTaskWoken ) ; return ( USBD_OK ) ; }
@brief  Data received over USB OUT endpoint are sent over CDC interface
         through this function.
@brief Data received over USB OUT endpoint are sent over CDC interface through this function .
/* USER CODE BEGIN 6 */ /* USER CODE END 6 */