Numworks Epsilon  1.4.1
Graphing Calculator Operating System
setup_packet.h
Go to the documentation of this file.
1 #ifndef ION_DEVICE_USB_SETUP_PACKET_H
2 #define ION_DEVICE_USB_SETUP_PACKET_H
3 
4 #include <stdint.h>
5 
6 namespace Ion {
7 namespace USB {
8 namespace Device {
9 
10 class SetupPacket {
11 public:
12  enum class TransactionType {
16  };
17 
18  enum class RequestType {
19  Standard = 0,
20  Class = 1,
21  Vendor = 2
22  };
23 
24  enum class RecipientType {
25  Device = 0,
26  Interface = 1,
27  Endpoint = 2,
28  Other = 3
29  };
30 
31  constexpr SetupPacket() :
32  m_bmRequestType(0),
33  m_bRequest(0),
34  m_wValue(0),
35  m_wIndex(0),
36  m_wLength(0)
37  {
38  }
39 
40  SetupPacket(void * buffer);
42  RequestType requestType() const;
44  int descriptorIndex();
45  int descriptorType();
46  uint8_t bmRequestType() { return m_bmRequestType; }
47  uint8_t bRequest() { return m_bRequest; }
48  uint16_t wValue() { return m_wValue; }
49  uint16_t wIndex() { return m_wIndex; }
50  uint16_t wLength() { return m_wLength; }
51 private:
52  uint8_t m_bmRequestType;
53  uint8_t m_bRequest;
54  uint16_t m_wValue;
55  uint16_t m_wIndex;
56  uint16_t m_wLength;
57 };
58 
59 static_assert(sizeof(SetupPacket) == 8, "SetupData must be packed");
60 
61 }
62 }
63 }
64 
65 #endif
unsigned short uint16_t
Definition: stdint.h:5
unsigned char uint8_t
Definition: stdint.h:4
Definition: app.cpp:5
TransactionType followingTransaction() const
RecipientType recipientType() const
RequestType requestType() const
Definition: backlight.h:6