Blame view

epsilon-master/ion/src/device/usb/stack/interface.h 1.23 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  #ifndef ION_DEVICE_USB_INTERFACE_H
  #define ION_DEVICE_USB_INTERFACE_H
  
  #include "endpoint0.h"
  #include "request_recipient.h"
  #include "setup_packet.h"
  
  namespace Ion {
  namespace USB {
  namespace Device {
  
  class Interface : public RequestRecipient {
  public:
    Interface(Endpoint0 * ep0) :
      RequestRecipient(ep0)
    {
    }
  protected:
    virtual void setActiveInterfaceAlternative(uint8_t interfaceAlternativeIndex) = 0;
    virtual uint8_t getActiveInterfaceAlternative() = 0;
    bool processSetupInRequest(SetupPacket * request, uint8_t * transferBuffer, uint16_t * transferBufferLength, uint16_t transferBufferMaxLength) override;
  private:
    // USB Standard Interface Request Codes
    enum class Request {
      GetStatus       = 0,
      ClearFeature    = 1,
      SetFeature      = 3,
      GetInterface    = 10,
      SetInterface    = 11,
    };
    bool getStatus(uint8_t * transferBuffer, uint16_t * transferBufferLength, uint16_t transferBufferMaxLength);
    bool getInterface(uint8_t * transferBuffer, uint16_t * transferBufferLength, uint16_t transferBufferMaxLength);
    bool setInterface(SetupPacket * request, uint16_t * transferBufferLength);
    bool clearFeature(uint16_t * transferBufferLength);
    bool setFeature(uint16_t * transferBufferLength);
  };
  
  }
  }
  }
  
  #endif