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

📄 usb.h

📁 嵌入式LINUX9系统应用开发详解中USB编程实例
💻 H
字号:
/*********************************************************************
 *
 * Copyright:
 *	MOTOROLA, INC. All Rights Reserved.  
 *  You are hereby granted a copyright license to use, modify, and
 *  distribute the SOFTWARE so long as this entire notice is
 *  retained without alteration in any modified and/or redistributed
 *  versions, and that such modified versions are clearly identified
 *  as such. No licenses are granted by implication, estoppel or
 *  otherwise under any patents or trademarks of Motorola, Inc. This 
 *  software is provided on an "AS IS" basis and without warranty.
 *
 *  To the maximum extent permitted by applicable law, MOTOROLA 
 *  DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING 
 *  IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
 *  PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH REGARD TO THE 
 *  SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) AND ANY 
 *  ACCOMPANYING WRITTEN MATERIALS.
 * 
 *  To the maximum extent permitted by applicable law, IN NO EVENT
 *  SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING 
 *  WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS 
 *  INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
 *  LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.   
 * 
 *  Motorola assumes no responsibility for the maintenance and support
 *  of this software
 ********************************************************************/

/*
 * File:		usb.h
 * Purpose:		USB Header File
 */

#ifndef USB_H
#define USB_H

/********************************************************************/

/* Default size to malloc() when needed */
#define BUFFER_SIZE			1024

/* Total number of EPs in this USB core */
#define NUM_ENDPOINTS		8

/* Depth of the FIFOs in packet lengths (Must be at */
/* least 2 for non-isochronous endpoints) */
#define FIFO_DEPTH			4

/* Definitions for Device Config Change events */
#define CONFIGURATION_CHG	1
#define INTERFACE_CHG		2
#define ADDRESS_CHG			4

/* Definitions for Bus Change events */
#define SUSPEND             1 
#define RESUME              2
#define ENABLE_WAKEUP       4
#define RESET               8

/* Definitions for Transfer Status */
#define SUCCESS				1
#define OVERFLOW_ERROR		2
#define MALLOC_ERROR		4

/********************************************************************/

/* Structure for storing IN and OUT transfer data */
typedef struct {
	uint8 *start;				/* Starting address for buffer */
	uint16 position;			/* Offset pointer within buffer */
	uint16 length;				/* Length of the buffer in bytes */
	uint8 free;					/* Was this buffer malloc()ed? */
} USB_BUFFER;

/* USB Endpoint State Info */
typedef struct {
	uint32 fifo_length;		/* Length of FIFO */
	uint32 in_fifo_start;	/* Starting address of IN-FIFO */
	uint32 out_fifo_start;	/* Starting address of OUT-FIFO */
	uint32 packet_size;		/* Maximum Packet Size */
	uint8 ttype;			/* Transfer Type */
	uint8 dir;				/* Direction of transfer */
	USB_BUFFER buffer;		/* Data Buffer for IN and OUT transfers */
} USB_EP_STATE;

/********************************************************************
* Application Specific Function Prototypes
*********************************************************************/

/* 
 * The following functions must be defined by the application 
 * specific support package 
 */
void usb_ep_halt(uint32);
void usb_ep_unhalt(uint32);
void usb_devcfg_notice(uint8, uint8, uint32);
void usb_ep_tx_done(uint32);
void usb_ep_rx_done(uint32,uint8);
void usb_vendreq_service(uint8,	uint8, uint16, uint16, uint16);
uint16 usb_get_desc_size(void);

/********************************************************************
* Standardized Function Prototypes
*********************************************************************/

/* 
 * The following functions are provided in usb.c
 */
void usb_init(void);
void usb_isr_init(void);
void usb_endpoint0_isr(void);
void usb_endpoint_isr(uint32);
void usb_in_service(uint32, uint32);
void usb_out_service(uint32, uint32);
void usb_devcfg_service(void);
void usb_bus_state_chg_service(uint32);
void usb_vendreq_done(uint32);
void usb_fifo_init(void);
uint32 usb_tx_data(uint32, uint8 *, uint16);
uint8* usb_get_desc(int8, int8, int8, int8);

/********************************************************************/

#endif /* USB_H */

⌨️ 快捷键说明

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