Пример #1
0
/******************************************************************************
 *
 *    @name       Virtual_Com_App
 *
 *    @brief      Implements Loopback COM Port
 *
 *    @param      None
 *
 *    @return     None
 *
 *****************************************************************************
 * Receives data from USB Host and transmits back to the Host
 *****************************************************************************/
static void Virtual_Com_App(void)
{
    static uint_8 status = 0;
    /* Loopback Application Code */
    if(g_recv_size)
    {
    	/* Copy Received Buffer to Send Buffer */
    	for (status = 0; status < g_recv_size; status++)
    	{
    		g_curr_send_buf[status] = g_curr_recv_buf[status];
    	}
    	g_send_size = g_recv_size;
    	g_recv_size = 0;
    }
    if(g_send_size)
    {
        /* Send Data to USB Host*/
        uint_8 size = g_send_size;
        g_send_size = 0;
        status = USB_Class_CDC_Interface_DIC_Send_Data(CONTROLLER_ID,
        g_curr_send_buf,size);
        if(status != USB_OK)
        {
            /* Send Data Error Handling Code goes here */
        }
    }

    return;
}
Пример #2
0
uint8 LPLD_USB_VirtualCom_Tx(uint8 *tx_buf,uint32_t len)
{
  if(!usb_valid)return -1;
  uint8 status = 0;
  is_usr_usb_sending=1;
  status = USB_Class_CDC_Interface_DIC_Send_Data(CONTROLLER_ID,tx_buf,len);
  return status;
}
Пример #3
0
/*
** ===================================================================
**     Method      :  CDC1_SendDataBlock (component FSL_USB_CDC_Device)
**
**     Description :
**         Sends a USB data block
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
uint8_t CDC1_SendDataBlock(uint8_t *data, uint16_t dataSize)
{
  uint8_t res = ERR_OK;

  transactionOngoing = TRUE;
  if (USB_Class_CDC_Interface_DIC_Send_Data(CONTROLLER_ID, data, dataSize)!=USB_OK) {
    transactionOngoing = FALSE;
    return ERR_FAULT;
  }
  /* wait for transaction finish */
  while(transactionOngoing) { /* wait until transaction is finished */
    CDC1_RunUsbEngine();
  }
  return res;
}
Пример #4
0
/******************************************************************************
 *
 *    @name       Virtual_Com_App
 *
 *    @brief      Implements Loopback COM Port
 *
 *    @param      None
 *
 *    @return     None
 *
 *****************************************************************************
 * Receives data from USB Host and transmits back to the Host
 *****************************************************************************/
void cdc_process(void)
{
    static uint_8 status 	 = 0;
    uint_8 		  sem_status = 0;
	uint_8 size;
	OS_SR_SAVE_VAR;

	size = g_send_size;
	g_send_size = 0;

    /*check whether enumeration is complete or not */
     if((start_app==TRUE) && (start_transactions==TRUE))
     {	
		
		OSEnterCritical();
			is_message_sent = 1;
		OSExitCritical();
		
		status = USB_Class_CDC_Interface_DIC_Send_Data(CONTROLLER_ID, g_curr_send_buf,size);
		sem_status = OSSemPend(USB_Sem,500);	   
		
		if (sem_status != OK)
		{
			OSEnterCritical();
				is_message_sent = 0;
			OSExitCritical();
		}
		
        if(status != USB_OK)
        {
            /* Send Data Error Handling Code goes here */
        	status = 0;
        }		
     }
#if 0     
     else
     {
    	  while(GetStart_transactions() == FALSE)
    	  {
    		  DelayTask(100);
    	  }
     }
#endif     


}
Пример #5
0
/*
*  LPLD_USB_VirtualCom_Tx
*  将USB CDC类模式虚拟成串口模式,该函数是串口发送函数
*  参数:
*      *tx_buf -- 指向用户数据存储区,用于储存要发送的数据
*      len -- 要发送的数据长度
*  输出:0x00   发送成功
*        非0x00 发送失败
*/
uint8 LPLD_USB_VirtualCom_Tx(uint8 *tx_buf,uint8 len)
{
  uint8 status = 0;
  status = USB_Class_CDC_Interface_DIC_Send_Data(CONTROLLER_ID,tx_buf,len);
  return status;
}