📄 usb_ctrl.c
字号:
/******************************************************************************/
/* Copyright (C) 2001 Texas Instruments, Inc. All Rights Reserved. */
/* */
/* File Name : usb_ctrl.c */
/* Project : TMS320VC5509 USB Module Support */
/* Author : C5000 H/W Applications */
/* */
/* Version : 0.1 */
/* Date : 30 Apr 2001 */
/* Updated : */
/* */
/* Description : Example Control Endpoint (Endpoint 0) Event handler */
/* */
/******************************************************************************/
/*
* USB Test Component Copyright (C) 2004, Spectrum Digital, Inc. All Rights Reserved.
*/
#include "csl.h"
#include "csl_usb.h"
#include "usb_req.h"
#include "usb_ctrl.h"
#include "DspSyscfg.h"
/******************************************************************************/
/* External Variables and Structures */
/* */
/******************************************************************************/
// usbCurConfigStat defined in usb_req.c, set usbCurConfigStat = 0 at reset
extern Uint16 usbCurConfigStat;
// USB_ReqTable[] is defined in the usb_req.c file. USB_ctl( ) parses thru the
// USB_ReqTable[] to select the appropriate routine to service the usb
// request (from host)
extern USB_request_struct USB_ReqTable[];
// myUsbConfig[] array is defined in usb_main.c and used by the USB_ctl( ) to
// to reconfigure the USB module if host requests a reset.
extern USB_EpHandle myUsbConfig[];
/******************************************************************************/
/* Control Endpoint Objects */
/* */
/******************************************************************************/
extern USB_EpObj usbEpObjIn0, usbEpObjOut0;
/******************************************************************************/
/* Data structure to hold the setup packet */
/* */
/******************************************************************************/
USB_SetupStruct USB_Setup = {0, 0, 0, 0, 0, 0};
/******************************************************************************/
/* Function pointer for USB request handlers */
/* */
/******************************************************************************/
// initialize the function pointer to the usb request handler with
// USB_reqUnknown( ), USB_reqUnknown( ) is defined in usb_req.c file
USB_REQUEST_RET (*fpRequestHandler)(USB_REQUEST_ARGS) = USB_reqUnknown;
unsigned short int *data = (unsigned short *)0x8000;
/******************************************************************************/
/* Name : void USB_ctl_handler() */
/* */
/* Purpose : USB Endpoint0 event handler routine */
/* */
/* Author : */
/* */
/* */
/*============================================================================*/
/* Arguments: */
/* */
/* hEp0In : Handle to the In Endpoint0 object */
/* */
/* hEp0Out : Handle to the Out Endpoint0 object */
/* */
/* DevNum : USB device number (USB_DevNum type ) */
/* */
/*============================================================================*/
/* Return Value: */
/* */
/* None */
/* */
/*============================================================================*/
/* Comments: */
/* */
/* if any USB bus event or endpoint0 related event takes place the USB event */
/* dispatcher calls this routine to handle the events */
/* */
/*============================================================================*/
void USB_ctl_handler()
{
// instead of calling USB_ctl( ) this routine can post a SWI of DSP/BIOS
// and SWI will in turn call the USB-ctl( )
USB_ctl(USB0, &usbEpObjIn0, &usbEpObjOut0);
}
/******************************************************************************/
/* Name : USB_ctl */
/* */
/* Purpose : Respond to the USB bus events and handle the usb setup packets */
/* */
/* Author : */
/* */
/* Based on : */
/* */
/* */
/*============================================================================*/
/* Arguments: */
/* */
/* DevNum : USB device number (USB_DevNum type ) */
/* */
/* hEp0In : Initialized handle to Endpt0 IN object */
/* */
/* hEp0Out : Initialized handle to Endpt0 OUT object */
/* */
/*============================================================================*/
/* Return Value: */
/* */
/* None */
/* */
/*============================================================================*/
/* Comments: */
/* */
/* */
/******************************************************************************/
void USB_ctl(USB_DevNum DevNum, USB_EpHandle hEp0In,USB_EpHandle hEp0Out)
{
Uint16 Request;
USB_REQUEST_RET ReqHandlerRet = USB_REQUEST_DONE;
USB_EVENT_MASK USB_ctl_events;
// find out the endpt0 event caused this funcion to be called
// and respond to the events
USB_ctl_events = (USB_getEvents(hEp0Out) | USB_getEvents(hEp0In));
// if the USB reset request received, abort all endpoint activities
// and reconfigure the USB module
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -