/**************************************************************************//**
 * @brief
 *   Callback function called when the DMA finishes a transfer.
 * @param channel
 *   The DMA channel that finished.
 * @param primary
 *   Primary or Alternate DMA descriptor
 * @param user
 *   User defined pointer (Not used in this example.)
 *****************************************************************************/
void PingPongTransferCompleteRX(unsigned int channel, bool primary, void *user)
{
  (void) channel;              /* Unused parameter */
  (void) user;                 /* Unused parameter */

//  FillBufferFromSDcard((bool) wavHeader.channels, primary);

  /* Stop DMA if bytecounter is equal to datasize or larger */
  bool stop = false;
  int8_t * buffer;

  /* Set buffer pointer correct ram buffer */
  if (primary)
  {
    buffer = ramBufferDacData0Stereo;
  }
  else /* Alternate */
  {
    buffer = ramBufferDacData1Stereo;
  }
  USB_Transmit((uint8_t *)buffer, 256);
  rxPackets++;
  /* Refresh the DMA control structure */
  DMA_RefreshPingPong(1,
                      primary,
                      false,
                      NULL,
                      NULL,
                      (2 * BUFFERSIZE) - 1,
                      stop);
}
Example #2
0
void USB_TransmitTxData(void)
{
	USB_Transmit(); // output pending bytes in tx buffer
	if((USB_tx_buffer.Locked == TRUE)) return;

	if(CheckDelay(USB_AboTimeOut))
	{
		USB_DebugData_Interval = 0;
		USB_NaviData_Interval = 0;
		USB_Data3D_Interval = 0;
		USB_Display_Interval = 0;
	}

	if((USB_Request_DebugLabel != 0xFF) && (USB_tx_buffer.Locked == FALSE))
	{
		MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'A', NC_ADDRESS, 2, &USB_Request_DebugLabel, sizeof(USB_Request_DebugLabel), (u8 *) ANALOG_LABEL[USB_Request_DebugLabel], 16);
		USB_Request_DebugLabel = 0xFF;
	}
	else if(USB_ConfirmFrame && (USB_tx_buffer.Locked == FALSE))
	{
		MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'B', NC_ADDRESS, 1, &USB_ConfirmFrame, sizeof(USB_ConfirmFrame));
		USB_ConfirmFrame = 0;
	}
	else if( (( (USB_DebugData_Interval > 0) && CheckDelay(USB_DebugData_Timer)) || USB_Request_DebugData) && (USB_tx_buffer.Locked == FALSE))
	{
		MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'D', NC_ADDRESS, 1,(u8 *)&DebugOut, sizeof(DebugOut));
		USB_DebugData_Timer = SetDelay(USB_DebugData_Interval);
		USB_Request_DebugData = FALSE;
	}
	else if((( (USB_Data3D_Interval > 0) && CheckDelay(USB_Data3D_Timer) ) || USB_Request_Data3D) && (USB_tx_buffer.Locked == FALSE))
	{
		MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'C', NC_ADDRESS, 1,(u8 *)&Data3D, sizeof(Data3D));
		USB_Data3D_Timer = SetDelay(USB_Data3D_Interval);
		USB_Request_Data3D = FALSE;
	}
	else if(USB_Request_ExternalControl && (USB_tx_buffer.Locked == FALSE))
	{
		MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'G', NC_ADDRESS, 1, (u8 *)&ExternControl, sizeof(ExternControl));
		USB_Request_ExternalControl = FALSE;
	}
	else if( (( (USB_Display_Interval > 0) && CheckDelay(USB_Display_Timer)) || USB_Request_Display) && (USB_tx_buffer.Locked == FALSE))
	{
		Menu_Update(USB_DisplayKeys);
		USB_DisplayKeys = 0;
		MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'H', NC_ADDRESS, 1, (u8*)DisplayBuff, sizeof(DisplayBuff));
		USB_Request_Display = FALSE;
	}
	else if(USB_Request_Display1 && (USB_tx_buffer.Locked == FALSE))
	{
		Menu_Update(0);
		MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'L', NC_ADDRESS, 3, (u8*)&MenuItem, sizeof(MenuItem), (u8*)&MaxMenuItem, sizeof(MaxMenuItem),(u8*)DisplayBuff, sizeof(DisplayBuff));
		USB_Request_Display1 = FALSE;
	}
	else if(USB_Request_VersionInfo && (USB_tx_buffer.Locked == FALSE))
	{
		MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'V', NC_ADDRESS,1, (u8 *)&UART_VersionInfo, sizeof(UART_VersionInfo));
		USB_Request_VersionInfo = FALSE;
	}
	else if(( (USB_NaviData_Interval && CheckDelay(USB_NaviData_Timer) ) || USB_Request_NaviData) && (USB_tx_buffer.Locked == FALSE))
	{
		NaviData.Errorcode = ErrorCode;
		MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'O', NC_ADDRESS,1, (u8 *)&NaviData, sizeof(NaviData));
		USB_NaviData_Timer = SetDelay(USB_NaviData_Interval);
		USB_Request_NaviData = FALSE;
	}
	else if(USB_Request_ErrorMessage && (USB_tx_buffer.Locked == FALSE))
	{
		MKProtocol_CreateSerialFrame(&USB_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG));
		USB_Request_ErrorMessage = FALSE;
	}
	USB_Transmit(); // output pending bytes in tx buffer
}