📄 drv_usb_ctl.h
字号:
/************************************************* Copyright (C), 2007, DTK Computer. File name: drv_usb_hwif.h Author: MMI Group Version: 1.0 Date: 2008.04.30 Description: usb module for hardware interface Others: Function List: History: <author> <time> <version > <desc> Bosco Lee 08/30/04 1.0 build this moudle *************************************************/ #ifndef __DRV_USB_CTL_H__#define __DRV_USB_CTL_H__#include "drv_usb_main.h"// 获取x的高8位#define MSB(x) (((x) >> 8) & 0xFF) #define MAX_ENDPOINTS (D_UINT8)0x3 // 下面的值为 Get Status 命令的返回值#define USB_GETSTATUS_SELF_POWERED 0x01#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02 /********* USB 状态取值 **************/ #define USB_IDLE 0#define USB_TRANSMIT 1#define USB_RECEIVE 2 #define CMD_IDLE 0#define CMD_SET_ADDRESS 1 //*************************************************************************// Chap_9.c 使用的结构体//************************************************************************* /************ USB事件结构体 *********************/ typedef union _epp_flags { struct _flags { D_UINT8 timer:1; D_UINT8 bus_reset:1; //总线复位标志 D_UINT8 suspend:1; //挂起改变标志 // D_UINT8 setup_packet:1; //收到SETUP包 D_UINT8 trans_done:1; D_UINT8 remote_wakeup:1; //远程唤醒标志(未使用) D_UINT8 in_isr:1; //USB中断服务标志 D_UINT8 control_state:2; //控制端点处理标志 //0: IDLE 空闲状态 //1: TRANSMIT 数据发送状态 //2: RECEIVE 数据接收状态 D_UINT8 configuration:1; //配置标志(0: 未配置; 1: 已经配置) D_UINT8 command:1; //set_address()指示标志 // D_UINT8 ep1_txdone:1; //端点 1 收到数据标志 // D_UINT8 ep2_rxdone:1; //端点 2 收到数据标志 D_UINT8 bulk_state:3; } bits; D_UINT16 value; } EPPFLAGS;typedef struct _device_request{ D_UINT8 bmRequestType; D_UINT8 bRequest; D_UINT16 wValue; D_UINT16 wIndex; D_UINT16 wLength;} DEVICE_REQUEST;/*********** 控制传输结构体 ************/ #define MAX_CONTROLDATA_SIZE 8 typedef struct _control_xfer{ DEVICE_REQUEST DeviceRequest; D_UINT16 wLength; D_UINT16 wCount; D_UINT8 * pData; D_UINT8 dataBuffer[MAX_CONTROLDATA_SIZE];} CONTROL_XFER;//定义控制传输结构变量extern CONTROL_XFER ControlData;//定义USB事件标志变量extern EPPFLAGS bEPPflags; //************************************************************************* // USB 标准设备请求函数 //*************************************************************************extern void get_status (void);extern void clear_feature (void);extern void set_feature (void);extern void set_address (void);extern void get_descriptor (void);extern void set_descriptor (void);extern void get_configuration (void);extern void set_configuration (void);extern void get_interface (void);extern void set_interface (void);extern void synch_frame (void);extern void reserved (void);extern void get_max_lun (void);extern void stall_ep0 (void);extern void ep0_setupdone (void);extern void ep0_outdone (void);extern void ep0_indone (void);extern void init_unconfig (void);extern void init_config (void);extern void single_transmit (D_UINT8 * pData, D_UINT8 len);extern void code_transmit (D_UINT8 * pRomData, D_INT16 len);extern void control_handler (void);extern EPPFLAGS bEPPflags;//extern code void (*StandardDeviceRequest[])(void); //extern code void (*ClassDeviceRequest[])(void); #endif /* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -