NetBurner 3.5.6
PDF Version
usb_msg.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5#ifndef __USB_MSG_H
6#define __USB_MSG_H
7#include <predef.h>
8#include <stdint.h>
9#include <nettypes.h>
10
11enum class eReq_StdDev_t : uint8_t {
12 eReq_Get_Stat = 0x00, // Get Device Status
13 eReq_Clr_Feat = 0x01, // Clear Device Feature
14 eReq_Set_Feat = 0x03, // Set Device Feature
15 eReq_Set_Addr = 0x05, // Set Device Address
16 eReq_Get_Desc = 0x06, // Get Device Descriptor
17 eReq_Set_Desc = 0x07, // Set Device Descriptor
18 eReq_Get_Cfg = 0x08, // Get Configuration Descriptor
19 eReq_Set_Cfg = 0x09, // Set Configuration Descriptor
20 eReq_Get_Intf = 0x0A, // Get Interface Descriptor
21 eReq_Set_Intf = 0x0B, // Set Interface Descriptor
22 eReq_Sync = 0x0C, // Synch Frame
23};
24
25enum class eDir_t : uint8_t {
26 eDir_OUT = 0x00, // Host-to-Device
27 eDir_IN = 0x80, // Device-to-Host
28 eDir_MASK= 0x80,
29};
30
31enum class eReqType_t : uint8_t {
32 eReqType_Std = (0x00 << 0x5), // Standard request
33 eReqType_Class = (0x01 << 0x5), // Class specific request
34 eReqType_Vendor = (0x02 << 0x5), // Vendor specific request
35 eReqType_Reserved=(0x03 << 0x5), // Reserved request
36 eReqType_MASK = (0x03 << 0x5)
37};
38
39enum class eReqTarget_t : uint8_t {
40 eReqTarget_Dev = 0x00, // Device
41 eReqTarget_Intf = 0x01, // Interface
42 eReqTarget_EndPt = 0x02, // Endpoint
43 eReqTarget_Other = 0x03, // Other
44 eReqTarget_MASK = 0x03,
45};
46
47inline uint8_t bmReqType(eDir_t dir, eReqType_t type, eReqTarget_t target)
48{ return ((uint8_t)dir) | ((uint8_t)type) | ((uint8_t)target); }
49
50#define GET_STATUS 0x8000 //Get device status
51#define SET_ADDRESS 0x0005 //Set Device Address
52#define GET_DESCRIPTOR 0x8006 //Get device descriptor
53#define GET_CONFIGURATION 0x8008 //Get device configuration
54#define SET_CONFIGURATION 0x0009 //Set configuration
55#define GET_INTERFACE 0x800A //Get device configuration
56#define SET_INTERFACE 0x000B //Set configuration
57
58#define EP_GET_STATUS (0x00)
59#define EP_CLR_FEATURE (0x01)
60#define EP_SET_FEATURE (0x02)
61#define EP_SYNCH_FRAME (0x03)
62
63struct usb_setup_pkt_t {
64 uint8_t bmRequestType; // Characteristics of request
65 // D7: Data transfer direction
66 // 0 = Host-to-device
67 // 1 = Device-to-host
68 // D6...5: Type
69 // 0 = Standard
70 // 1 = Class
71 // 2 = Vendor
72 // 3 = Reserved
73 // D4...0: Recipient
74 // 0 = Device
75 // 1 = Interface
76 // 2 = Endpoint
77 // 3 = Other
78 // 4...31 = Reserved
79 uint8_t bRequest; // Specific Request Code
80 leuint16_t wValue; // Varies according to Request
81 leuint16_t wIndex; // Varies according to Request, usually an index or offset
82 leuint16_t wLength; // Number of bytes to transfer if there is a Data stage
83};
84
85
86#endif /* ----- #ifndef __USB_MSG_H ----- */
87
NetBurner IPADDR4 Class. See the IPADDR4 Class page for complete documentation.