Blame view

epsilon-master/ion/src/device/usb/stack/setup_packet.cpp 814 Bytes
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
  #include "setup_packet.h"
  #include <string.h>
  
  namespace Ion {
  namespace USB {
  namespace Device {
  
  SetupPacket::SetupPacket(void * buffer) {
    memcpy(this, buffer, sizeof(SetupPacket));
  }
  
  SetupPacket::TransactionType SetupPacket::followingTransaction() const {
    if (m_wLength == 0 || (m_bmRequestType & 0b10000000) != 0) {
      return TransactionType::InTransaction;
    } else {
      return TransactionType::OutTransaction;
    }
  }
  
  SetupPacket::RequestType SetupPacket::requestType() const {
    return (RequestType) ((m_bmRequestType & 0b01100000) >> 5);
  }
  
  SetupPacket::RecipientType SetupPacket::recipientType() const {
    return (RecipientType) (m_bmRequestType & 0b00001111);
  }
  
  int SetupPacket::descriptorIndex() {
    return m_wValue & 0xFF;
  }
  
  int SetupPacket::descriptorType() {
    return m_wValue >> 8;
  }
  
  }
  }
  }