⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcd_acm.c

📁 Usb Host/Periphel Control TD1120 codes
💻 C
字号:
/*------------------------------------------------------------------------------
$File: //tdi_sw/tdi/examples/usb/pcd/acm/pcd_acm.c $
$DateTime: 2004/12/20 19:06:16 $
$Revision: #8 $
Purpose: PCD test application to exercise the PCD API
------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------
CONFIDENTIAL AND PROPRIETARY INFORMATION OF SOFTCONNEX TECHNOLOGIES, INC.

THIS NOTICE IS NOT TO BE DELETED, MODIFIED, MOVED OR CHANGED IN ANY WAY.

Copyright (c) 1999 - 2004 by SoftConnex Technologies, Inc. 

This software is protected by copyright laws and international copyright 
treaties, as well as other intellectual property laws and treaties.  This
software is a CONFIDENTIAL, unpublished work of authorship, and with portions 
constituting TRADE SECRETS of SoftConnex Technologies, Inc., a Delaware USA 
corporation.  Any unauthorized use, disclosure,	and/or reproduction of this 
software, or any part of this software; or distribution of this software in any 
form or by any means; or storage of this software in any database or retrieval 
system, without the express written consent of, and license from, SoftConnex 
Technologies, Inc. is strictly prohibited.  This software is protected under the
copyright and/or trade secret laws in other countries in addition to USA.  All 
Rights Reserved.  Failure to abide by the use, disclosure and/or reproduction 
restrictions may result in civil and /or criminal penalties, and will be 
prosecuted to the maximum extent of the law.
------------------------------------------------------------------------------*/
#include "project.h"

extern volatile SctBool enumerationDone;
extern volatile SctBool configurationDone;
extern TdiPeriphController* globalPeriphHandle;

STATIC U8 acmLineCodingBuffer[10];
STATIC volatile SctBool bulkInTransferDone= SCC_FALSE;
STATIC volatile SctBool bulkOutTransferDone = SCC_FALSE;
STATIC volatile SctBool intrInTransferDone = SCC_FALSE;
STATIC U8 PCDACM_BulkBuffer[1024];
STATIC U8 PCDACM_IntrBuffer[1024];


/*------------------------------------------------------------------------------
Name      : PCDAPP_ProcessClassCommand
Purpose   : Process Class command
Arguments : pc - peripheral controller handle
            request - setup packet
Returns   : SctStatus
Notes     : 
-----------------------------------------------------------------------------*/
SctStatus PCDAPP_ProcessClassCommand(TdiPeriphController* pc, 
                                     PeriphSetupRequest* request)
   {
   /* All class-specific commands to be processed here */
   switch (request->bRequest)
      {
      case ACM_GET_ENCAPSULATED_RSP:
         PRINT1("(PCDAPP_ProcessClassCommand) : "
         "ACM_GET_ENCAPSULATED_RESPONSE_COMMAND received.\n");
      break;
      case ACM_GET_COMM_FEATURE:
         PRINT1("(PCDAPP_ProcessClassCommand) : "
         "ACM_GET_COMM_FEATURE_COMMAND received.\n");
      break;
      case ACM_GET_LINE_CODING:
         request->data = acmLineCodingBuffer;
         request->actualLength = request->wLength;
         return SCS_SUCCESS;
      case ACM_SEND_ENCAPSULATED_CMD:
         PRINT1("(PCDAPP_ProcessClassCommand) : "
         "ACM_SEND_ENCAPSULATED_COMMAND received.\n");
      break;
      case ACM_SET_COMM_FEATURE:
         PRINT1("(PCDAPP_ProcessClassCommand) : "
         "ACM_SET_COMM_FEATURE_COMMAND received.\n");
      break;
      case ACM_CLR_COMM_FEATURE:
         PRINT1("(PCDAPP_ProcessClassCommand) : "
         "ACM_CLEAR_COMM_FEATURE_COMMAND received.\n");
      break;
      case ACM_SET_LINE_CODING:
         request->data = acmLineCodingBuffer;
         request->actualLength = request->wLength;
         return SCS_SUCCESS;
      case ACM_SET_CTRL_LINE_STATE:
      break;
      case ACM_SEND_BREAK:
         PRINT1("(PCDAPP_ProcessClassCommand) : "
         "ACM_SEND_BREAK_COMMAND received.\n");
      break;
      default:
         return SCS_ERROR;
      }
   return SCS_SUCCESS;
   }
   
/*------------------------------------------------------------------------------
Name      : PCDAPP_ProcessVendorCommand
Purpose   : Process Class command
Arguments : pc - peripheral controller handle 
            request - setup packet
Returns   : SctStatus
Notes     : 
-----------------------------------------------------------------------------*/
SctStatus PCDAPP_ProcessVendorCommand(TdiPeriphController* pc, 
                                      PeriphSetupRequest* request)
   {
   /* Nothing to do- Dummy function  */
   return SCS_SUCCESS;
   }

/*------------------------------------------------------------------------------
Name      : PCDACM_BulkInCallBack
Purpose   : Call back function for Bulk In completion
Arguments : urb - pointer to urb
Returns   : None
Notes     : None
-----------------------------------------------------------------------------*/
STATIC void PCDACM_BulkInCallBack(TdiPurb *urb)
   {
   bulkInTransferDone = SCC_TRUE;
   }
   
/*------------------------------------------------------------------------------
Name      : PCDACM_BulkOutCallBack
Purpose   : Call back function for Bulk Out completion
Arguments : urb - pointer to urb
Returns   : None
Notes     : None
-----------------------------------------------------------------------------*/
STATIC void PCDACM_BulkOutCallBack(TdiPurb *urb)
   {
   bulkOutTransferDone = SCC_TRUE;
   }
   
/*------------------------------------------------------------------------------
Name      : PCDACM_IntrInCallBack
Purpose   : Call back function for Intr In completion
Arguments : urb - pointer to urb
Returns   : None
Notes     : None
-----------------------------------------------------------------------------*/
STATIC void PCDACM_IntrInCallBack(TdiPurb *urb)
   {
   intrInTransferDone = SCC_TRUE;
   }

/*------------------------------------------------------------------------------
Name      : PCDACM_App
Purpose   : This function is used to run a test application to exercise different
            PCD API functions
Arguments : None
Returns   : None
Notes     : This function is an example for PCD API usage
-----------------------------------------------------------------------------*/
void PCDACM_App(void)
   {
   U32 status;
   TdiPeriphController* pc = globalPeriphHandle;
   TdiPurb bulkInUrb;
   TdiPurb bulkOutUrb;
   TdiPurb intrInUrb;
   
   /* Do some bus control operation */   
   while (1)
      {
      while (!enumerationDone)
         {
         /* Do nothing */
         }
      
      while (!configurationDone)
         {
         /* Do nothing */
         }
         
      ep1->urb = &intrInUrb;
      intrInUrb.direction = USB_REQUEST_DIRECTION_IN;
      intrInUrb.length = 10;
      intrInUrb.lengthSoFar = 0;
      intrInUrb.dataPosition = 0;
      intrInUrb.status = 0;
      intrInUrb.ep = ep1;
      intrInUrb.data = PCDACM_IntrBuffer;
      intrInUrb.pc = pc;
      intrInUrb.callBackFunction = PCDACM_IntrInCallBack;
      
      /* init DURB for Interrupt Rx */
      status = PCD_Transfer(pc, &intrInUrb);
   
      ep2->urb = &bulkOutUrb;
      bulkOutUrb.direction = 0;
      bulkOutUrb.length = PCDAPPXFERLENGTH;
      bulkOutUrb.lengthSoFar = 0;
      bulkOutUrb.dataPosition = 0;
      bulkOutUrb.status = 0;
      bulkOutUrb.ep = ep2;
      bulkOutUrb.data = PCDACM_BulkBuffer;
      bulkOutUrb.pc = pc;
      bulkOutUrb.callBackFunction = PCDACM_BulkOutCallBack;
      
      
      /* init DURB for bulk Rx */
      status = PCD_Transfer(pc, &bulkOutUrb);
      
      /* Wait for Bulk Out to complete */
      while (!bulkOutTransferDone)
         {
         }
      
      bulkOutTransferDone = SCC_FALSE;
      
      ep3->urb = &bulkInUrb;
      bulkInUrb.direction = USB_REQUEST_DIRECTION_IN;
      bulkInUrb.length = 1;
      bulkInUrb.lengthSoFar = 0;
      bulkInUrb.dataPosition = 0;
      bulkInUrb.status = 0;
      bulkInUrb.ep = ep3;
      bulkInUrb.data = PCDACM_BulkBuffer;
      bulkInUrb.pc = pc;
      bulkInUrb.callBackFunction = PCDACM_BulkInCallBack;

      
      /* init DURB for Bulk Tx */
      status = PCD_Transfer(pc, &bulkInUrb);
      
      /* Wait for Bulk Out to complete */
      while (!bulkInTransferDone)
         {
         }
      } /* EndWhile */
   }
   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -