tinyusb/src/portable/nxp/lpc17_40/dcd_lpc17_40.c
static void control_xfer_isr(uint8_t rhport, uint32_t ep_int_status)
{
  // Control out complete
  if ( ep_int_status & BIT_(0) )
  {
    bool is_setup = sie_read(SIE_CMDCODE_ENDPOINT_SELECT+0) & SIE_SELECT_ENDPOINT_SETUP_RECEIVED_MASK;

    LPC_USB->EpIntClr = BIT_(0);

    if (is_setup)
    {
      uint8_t setup_packet[8];
      control_ep_read(setup_packet, 8); // TODO read before clear setup above

      dcd_event_setup_received(rhport, setup_packet, true);
    }
    else if ( _dcd.control.out_buffer )
    {
      // software queued transfer previously
      uint8_t received = control_ep_read(_dcd.control.out_buffer, _dcd.control.out_bytes);

      _dcd.control.out_buffer = NULL;
      _dcd.control.out_bytes = 0;

      dcd_event_xfer_complete(rhport, 0, received, XFER_RESULT_SUCCESS, true);
    }else
    {
      // hardware auto ack packet -> mark as received
      _dcd.control.out_received = true;
    }
  }

  // Control In complete
  if ( ep_int_status & BIT_(1) )
  {
    LPC_USB->EpIntClr = BIT_(1);
    dcd_event_xfer_complete(rhport, TUSB_DIR_IN_MASK, _dcd.control.in_bytes, XFER_RESULT_SUCCESS, true);
  }
}
// handle control xfer (slave mode)
handle control xfer (slave mode)
handle control xfer ( slave mode )
static void control_xfer_isr(uint8_t rhport, uint32_t ep_int_status)
{
  if ( ep_int_status & BIT_(0) )
  {
    bool is_setup = sie_read(SIE_CMDCODE_ENDPOINT_SELECT+0) & SIE_SELECT_ENDPOINT_SETUP_RECEIVED_MASK;
    LPC_USB->EpIntClr = BIT_(0);
    if (is_setup)
    {
      uint8_t setup_packet[8];
      control_ep_read(setup_packet, 8); 
      dcd_event_setup_received(rhport, setup_packet, true);
    }
    else if ( _dcd.control.out_buffer )
    {
      uint8_t received = control_ep_read(_dcd.control.out_buffer, _dcd.control.out_bytes);
      _dcd.control.out_buffer = NULL;
      _dcd.control.out_bytes = 0;
      dcd_event_xfer_complete(rhport, 0, received, XFER_RESULT_SUCCESS, true);
    }else
    {
      _dcd.control.out_received = true;
    }
  }
  if ( ep_int_status & BIT_(1) )
  {
    LPC_USB->EpIntClr = BIT_(1);
    dcd_event_xfer_complete(rhport, TUSB_DIR_IN_MASK, _dcd.control.in_bytes, XFER_RESULT_SUCCESS, true);
  }
}
static void control_xfer_isr ( uint8_t rhport , uint32_t ep_int_status ) { if ( ep_int_status & BIT_ ( 0 ) ) { bool is_setup = sie_read ( SIE_CMDCODE_ENDPOINT_SELECT + 0 ) & SIE_SELECT_ENDPOINT_SETUP_RECEIVED_MASK ; LPC_USB -> EpIntClr = BIT_ ( 0 ) ; if ( is_setup ) { uint8_t setup_packet [ 8 ] ; control_ep_read ( setup_packet , 8 ) ; dcd_event_setup_received ( rhport , setup_packet , true ) ; } else if ( _dcd . control . out_buffer ) { uint8_t received = control_ep_read ( _dcd . control . out_buffer , _dcd . control . out_bytes ) ; _dcd . control . out_buffer = NULL ; _dcd . control . out_bytes = 0 ; dcd_event_xfer_complete ( rhport , 0 , received , XFER_RESULT_SUCCESS , true ) ; } else { _dcd . control . out_received = true ; } } if ( ep_int_status & BIT_ ( 1 ) ) { LPC_USB -> EpIntClr = BIT_ ( 1 ) ; dcd_event_xfer_complete ( rhport , TUSB_DIR_IN_MASK , _dcd . control . in_bytes , XFER_RESULT_SUCCESS , true ) ; } }
handle control xfer (slave mode)
handle control xfer ( slave mode )
// Control out complete // TODO read before clear setup above // software queued transfer previously // hardware auto ack packet -> mark as received // Control In complete