tinyusb/src/portable/nxp/lpc18_43/dcd_lpc18_43.c
static void bus_reset(uint8_t rhport)
{
  LPC_USBHS_T* lpc_usb = LPC_USB[rhport];

  // The reset value for all endpoint types is the control endpoint. If one endpoint
  // direction is enabled and the paired endpoint of opposite direction is disabled, then the
  // endpoint type of the unused direction must bechanged from the control type to any other
  // type (e.g. bulk). Leaving an unconfigured endpoint control will cause undefined behavior
  // for the data PID tracking on the active endpoint.

  // USB0 has 5 but USB1 only has 3 non-control endpoints
  for( int i=1; i < (rhport ? 6 : 4); i++)
  {
    lpc_usb->ENDPTCTRL[i] = (TUSB_XFER_BULK << 2) | (TUSB_XFER_BULK << 18);
  }

  //------------- Clear All Registers -------------//
  lpc_usb->ENDPTNAK       = lpc_usb->ENDPTNAK;
  lpc_usb->ENDPTNAKEN     = 0;
  lpc_usb->USBSTS_D       = lpc_usb->USBSTS_D;
  lpc_usb->ENDPTSETUPSTAT = lpc_usb->ENDPTSETUPSTAT;
  lpc_usb->ENDPTCOMPLETE  = lpc_usb->ENDPTCOMPLETE;

  while (lpc_usb->ENDPTPRIME);
  lpc_usb->ENDPTFLUSH = 0xFFFFFFFF;
  while (lpc_usb->ENDPTFLUSH);

  // read reset bit in portsc

  //------------- Queue Head & Queue TD -------------//
  dcd_data_t* p_dcd = dcd_data_ptr[rhport];
  tu_memclr(p_dcd, sizeof(dcd_data_t));

  //------------- Set up Control Endpoints (0 OUT, 1 IN) -------------//
	p_dcd->qhd[0].zero_length_termination = p_dcd->qhd[1].zero_length_termination = 1;
	p_dcd->qhd[0].max_package_size = p_dcd->qhd[1].max_package_size = CFG_TUD_ENDOINT0_SIZE;
	p_dcd->qhd[0].qtd_overlay.next = p_dcd->qhd[1].qtd_overlay.next = QTD_NEXT_INVALID;

	p_dcd->qhd[0].int_on_setup = 1; // OUT only
}
/// follows LPC43xx User Manual 23.10.3
follows LPC43xx User Manual 23.10.3
follows LPC43xx User Manual 23 . 10 . 3
static void bus_reset(uint8_t rhport)
{
  LPC_USBHS_T* lpc_usb = LPC_USB[rhport];
  for( int i=1; i < (rhport ? 6 : 4); i++)
  {
    lpc_usb->ENDPTCTRL[i] = (TUSB_XFER_BULK << 2) | (TUSB_XFER_BULK << 18);
  }
  lpc_usb->ENDPTNAK       = lpc_usb->ENDPTNAK;
  lpc_usb->ENDPTNAKEN     = 0;
  lpc_usb->USBSTS_D       = lpc_usb->USBSTS_D;
  lpc_usb->ENDPTSETUPSTAT = lpc_usb->ENDPTSETUPSTAT;
  lpc_usb->ENDPTCOMPLETE  = lpc_usb->ENDPTCOMPLETE;
  while (lpc_usb->ENDPTPRIME);
  lpc_usb->ENDPTFLUSH = 0xFFFFFFFF;
  while (lpc_usb->ENDPTFLUSH);
  dcd_data_t* p_dcd = dcd_data_ptr[rhport];
  tu_memclr(p_dcd, sizeof(dcd_data_t));
	p_dcd->qhd[0].zero_length_termination = p_dcd->qhd[1].zero_length_termination = 1;
	p_dcd->qhd[0].max_package_size = p_dcd->qhd[1].max_package_size = CFG_TUD_ENDOINT0_SIZE;
	p_dcd->qhd[0].qtd_overlay.next = p_dcd->qhd[1].qtd_overlay.next = QTD_NEXT_INVALID;
	p_dcd->qhd[0].int_on_setup = 1; 
}
static void bus_reset ( uint8_t rhport ) { LPC_USBHS_T * lpc_usb = LPC_USB [ rhport ] ; for ( int i = 1 ; i < ( rhport ? 6 : 4 ) ; i ++ ) { lpc_usb -> ENDPTCTRL [ i ] = ( TUSB_XFER_BULK << 2 ) | ( TUSB_XFER_BULK << 18 ) ; } lpc_usb -> ENDPTNAK = lpc_usb -> ENDPTNAK ; lpc_usb -> ENDPTNAKEN = 0 ; lpc_usb -> USBSTS_D = lpc_usb -> USBSTS_D ; lpc_usb -> ENDPTSETUPSTAT = lpc_usb -> ENDPTSETUPSTAT ; lpc_usb -> ENDPTCOMPLETE = lpc_usb -> ENDPTCOMPLETE ; while ( lpc_usb -> ENDPTPRIME ) ; lpc_usb -> ENDPTFLUSH = 0xFFFFFFFF ; while ( lpc_usb -> ENDPTFLUSH ) ; dcd_data_t * p_dcd = dcd_data_ptr [ rhport ] ; tu_memclr ( p_dcd , sizeof ( dcd_data_t ) ) ; p_dcd -> qhd [ 0 ] . zero_length_termination = p_dcd -> qhd [ 1 ] . zero_length_termination = 1 ; p_dcd -> qhd [ 0 ] . max_package_size = p_dcd -> qhd [ 1 ] . max_package_size = CFG_TUD_ENDOINT0_SIZE ; p_dcd -> qhd [ 0 ] . qtd_overlay . next = p_dcd -> qhd [ 1 ] . qtd_overlay . next = QTD_NEXT_INVALID ; p_dcd -> qhd [ 0 ] . int_on_setup = 1 ; }
follows LPC43xx User Manual 23.10.3
follows LPC43xx User Manual 23 . 10 . 3
// The reset value for all endpoint types is the control endpoint. If one endpoint // direction is enabled and the paired endpoint of opposite direction is disabled, then the // endpoint type of the unused direction must bechanged from the control type to any other // type (e.g. bulk). Leaving an unconfigured endpoint control will cause undefined behavior // for the data PID tracking on the active endpoint. // USB0 has 5 but USB1 only has 3 non-control endpoints //------------- Clear All Registers -------------// // read reset bit in portsc //------------- Queue Head & Queue TD -------------// //------------- Set up Control Endpoints (0 OUT, 1 IN) -------------// // OUT only