Blame view

epsilon-master/ion/src/device/usb/stack/request_recipient.cpp 1.09 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
  #include "request_recipient.h"
  
  namespace Ion {
  namespace USB {
  namespace Device {
  
  bool RequestRecipient::processSetupRequest(SetupPacket * request, uint8_t * transferBuffer, uint16_t * transferBufferLength, uint16_t transferBufferMaxLength) {
    if (request->followingTransaction() == SetupPacket::TransactionType::InTransaction) {
    // There is no data stage in this transaction, or the data stage will be in IN direction.
      if (!processSetupInRequest(request, transferBuffer, transferBufferLength, transferBufferMaxLength)) {
        m_ep0->stallTransaction();
        return false;
      }
      if (*transferBufferLength > 0) {
        m_ep0->computeZeroLengthPacketNeeded();
        m_ep0->sendSomeData();
      } else {
        m_ep0->sendSomeData();
        // On seeing a zero length packet, sendSomeData changed endpoint0 state to
        // LastDataIn, but it should be StatusIn as there was no data stage.
        m_ep0->setState(Endpoint0::State::StatusIn);
      }
    } else {
      // The following transaction will be an OUT transaction.
      m_ep0->clearForOutTransactions(request->wLength());
    }
    return true;
  }
  
  }
  }
  }