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

📄 chap_9.h

📁 44b0中USB slave端程序
💻 H
字号:

#ifndef __CHAP_9_H__
#define __CHAP_9_H__

#define MSB(x)    (((x) >> 8) & 0xFF)

#define MAX_ENDPOINTS      (U8)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


   //*************************************************************************
   // Chap_9.c 使用的结构体
   //*************************************************************************
/************ USB事件结构体 *********************/
typedef union _epp_flags
{
	struct _flags
	{
		unsigned  remote_wakeup		   	: 1;
		unsigned  control_state			: 2;
		unsigned  configuration			: 1;
		unsigned  command				: 1;
	} bits;
	U16 value;
} EPPFLAGS;

typedef struct _device_request
{
	U8 bmRequestType;
	U8 bRequest;
	U16 wValue;
	U16 wIndex;
	U16 wLength;
} DEVICE_REQUEST;


/*********** 控制传输结构体 ************/
#define MAX_CONTROLDATA_SIZE	8

typedef struct _control_xfer
{
	DEVICE_REQUEST DeviceRequest;
	U16 wLength;
	U16 wCount;
	U8 * pData;
	U8 dataBuffer[MAX_CONTROLDATA_SIZE];
} CONTROL_XFER;


   //*************************************************************************
   // USB 标准设备请求函数
   //*************************************************************************

void get_status(void);
void clear_feature(void);
void set_feature(void);
void set_address(void);
void get_descriptor(void);
void get_configuration(void);
void set_configuration(void);
void get_interface(void);
void set_interface(void);
void reserved(void);
void stall_ep0(void);
void ep0_txdone(void);
void ep0_rxdone(void);
void init_unconfig(void);
void init_config(void);
void single_transmit(U8 * pData, U8 len);
void code_transmit(U8 * pRomData, U16 len);
void control_handler(void);


#endif

⌨️ 快捷键说明

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