usbdef.h

来自「PDIUSBD12的嵌入式软件」· C头文件 代码 · 共 84 行

H
84
字号
/*
*   usbdef.h
*
*   Common def's for USB device communications stack.
*   MJB Nov 2005
*/

#ifndef __USBDEF_H__
#define __USBDEF_H__


#define MAX_EP_MASK        7

#define D12_EP0_OUT        0     /* D12 endpoint index values */
#define D12_EP0_IN         1
#define D12_EP1_OUT        2
#define D12_EP1_IN         3
#define D12_EP2_OUT        4
#define D12_EP2_IN         5

#define EP0_MAX_PACKET_SIZE    16    /* D12 on-chip endpoint buffer sizes */
#define EP1_MAX_PACKET_SIZE    4
#define EP2_MAX_PACKET_SIZE    64

#define USB_IDLE           0
#define USB_TRANSMIT       1
#define USB_RECEIVE        2

#define USB_CLASS_CODE_TEST_CLASS_DEVICE  0xDC
#define USB_SUBCLASS_CODE_TEST_CLASS_D12  0xA0
#define USB_PROTOCOL_CODE_TEST_CLASS_D12  0xB0


typedef union _usb_flags
{
	struct _flags
	{
		uchar timer_tick      : 1 ;
		uchar bus_reset       : 1 ;
		uchar suspend         : 1 ;
		uchar setup_packet    : 1 ;
		uchar remote_wakeup   : 1 ;
		uchar in_isr          : 1 ;
		uchar control_state   : 2 ;

		uchar dev_configured  : 1 ;
		uchar test_mode       : 1 ;
		uchar reserved_2      : 1 ;
		uchar reserved_3      : 1 ;
		uchar dma_eot         : 1 ;
		uchar dma_state       : 2 ;
		uchar power_down      : 1 ;
	} bits;
	ushort value;
} USB_FLAGS;

extern  USB_FLAGS    USBflags;

extern  bool   USB_active;                 /* Device is attached */
extern  bool   USB_BulkInTxReady;          /* D12 is ready to accept data for TX on EP2 */
extern  bool   USB_InterruptInTxReady;     /* D12 is ready to accept data for TX on EP1 */
extern  ushort USB_ErrorFlags[];           /* D12 error status words, 1 per EP (debug usage) */


/* Function prototypes -- usbisr.c */

_INTERRUPT_ void usb_isr(void);

void  bus_reset( void );
void  suspend_change( void );
void  dma_eot( void );
void  control_in_handler( void );
void  control_out_handler( void );
void  control_dispatcher( void );
void  interrupt_in_handler( void );
void  endpoint1_out_handler( void );
void  bulk_in_handler( void );
void  bulk_out_handler( void );
void  UpdateUSBErrorFlags( uchar, uchar );


#endif   /* __USBDEF_H__ */

⌨️ 快捷键说明

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