📄 usb_definition.h
字号:
/*
This file includes the definitions which used in USB Device firmware
*/
#ifndef _USB_DEFINITION_H_
#define _USB_DEFINITION_H_
#include "USB_Descriptor.h"
#define OFF 0
#define ON 1
#define REMOTE_WAKEUP_SUPPORT OFF
#define SELF_POWERED_SUPPORT OFF
#define SUSPEND_ENABLE ON
#define EP0_PACKET_SIZE 64
#define EP1_PACKET_SIZE 64 // 64bytes
#define EP2_PACKET_SIZE 64 // 64bytes
// ENDPOINT INDEX IDENTIFIERS
#define EP0_IDX 0x00
#define EP1_IN_IDX 0x01
#define EP2_OUT_IDX 0x02
// Define device states
#define DEV_ATTACHED 0x00 // Device is in Attached State
#define DEV_POWERED 0x01 // Device is in Powered State
#define DEV_DEFAULT 0x02 // Device is in Default State
#define DEV_ADDRESS 0x03 // Device is in Addressed State
#define DEV_CONFIGURED 0x04 // Device is in Configured State
#define DEV_SUSPENDED 0x05 // Device is in Suspended State
// Define Endpoint States
#define EP_IDLE 0x00 // This signifies Endpoint Idle State
#define EP_TX 0x01 // Endpoint Transmit State
#define EP_RX 0x02 // Endpoint Receive State
#define EP_HALT 0x03 // Endpoint Halt State (return stalls)
#define EP_STALL 0x04 // Endpoint Stall (send procedural stall next status phase)
#define EP_ADDRESS 0x05 // Endpoint Address (change FADDR during next status phase)
// Standard Descriptor Types
#define DSC_DEVICE 0x01 // Device Descriptor
#define DSC_CONFIG 0x02 // Configuration Descriptor
#define DSC_INTERFACE 0x04 // Interface Descriptor
#define DSC_ENDPOINT 0x05 // Endpoint Descriptor
// Standard Request Codes
#define GET_STATUS 0x00 // Code for Get Status
#define CLEAR_FEATURE 0x01 // Code for Clear Feature
#define SET_FEATURE 0x03 // Code for Set Feature
#define SET_ADDRESS 0x05 // Code for Set Address
#define GET_DESCRIPTOR 0x06 // Code for Get Descriptor
#define SET_DESCRIPTOR 0x07 // Code for Set Descriptor(not used)
#define GET_CONFIGURATION 0x08 // Code for Get Configuration
#define SET_CONFIGURATION 0x09 // Code for Set Configuration
#define GET_INTERFACE 0x0A // Code for Get Interface
#define SET_INTERFACE 0x0B // Code for Set Interface
#define SYNCH_FRAME 0x0C // Code for Synch Frame(not used)
#define MSD_RESET 0xFF // Mass-storage device Reset
#define MSD_GET_MAX_LUN 0xFE // Mass-storage device Get Max LUN
// Define bmRequestType bitmaps
#define IN_DEVICE 0x00 // Request made to device, direction is IN
#define OUT_DEVICE 0x80 // Request made to device, direction is OUT
#define IN_INTERFACE 0x01 // Request made to interface, direction is IN
#define OUT_INTERFACE 0x81 // Request made to interface, direction is OUT
#define IN_ENDPOINT 0x02 // Request made to endpoint, direction is IN
#define OUT_ENDPOINT 0x82 // Request made to endpoint, direction is OUT
// Define wIndex bitmaps
#define IN_EP1 0x81 // Index values used by Set and Clear feature
#define OUT_EP1 0x01 // commands for Endpoint_Halt
#define IN_EP2 0x82
#define OUT_EP2 0x02
// Define wValue bitmaps for Standard Feature Selectors
#define DEVICE_REMOTE_WAKEUP 0x01 // Remote wakeup feature(not used)
#define ENDPOINT_HALT 0x00 // Endpoint_Halt feature selector
// Function prototypes
// USB Routines
void USBResume(void);
void USBReset(void);
void USBReset(void);
void HandleSetup(void);
void HandleIn1(void);
void HandleOut2(void);
void USBSuspend(void);
// Standard Request
void GetStatus(void);
void ClearFeature(void);
void SetFeature(void);
void SetAddress(void);
void GetDescriptor(void);
void GetConfiguration(void);
void SetConfiguration(void);
void GetInterface(void);
void SetInterface(void);
// Other function prototypes
void FIFORead(BYTE bEp, UINT uNumBytes, BYTE * pData);
void FIFOWrite(BYTE bEp, UINT uNumBytes, BYTE * pData);
void ForceStall(void);
#endif /* _USB_DEFINITION_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -