@@ -139,6 +139,10 @@ void USBPhyHw::connect() {
139
139
// when the internal regulator has settled
140
140
if (!nrf_drv_usbd_is_enabled ())
141
141
nrf_drv_usbd_enable ();
142
+
143
+ if (nrf_drv_power_usbstatus_get () == NRF_DRV_POWER_USB_STATE_READY
144
+ && !nrf_drv_usbd_is_started ())
145
+ nrf_drv_usbd_start (false );// nrf_drv_usbd_start(true);
142
146
}
143
147
}
144
148
@@ -148,8 +152,8 @@ void USBPhyHw::disconnect() {
148
152
149
153
if (nrf_drv_usbd_is_started ())
150
154
nrf_drv_usbd_stop ();
151
- if (nrf_drv_usbd_is_enabled ())
152
- nrf_drv_usbd_disable ();
155
+ // if(nrf_drv_usbd_is_enabled())
156
+ // nrf_drv_usbd_disable();
153
157
}
154
158
155
159
void USBPhyHw::configure () {
@@ -232,7 +236,16 @@ void USBPhyHw::ep0_read(uint8_t *data, uint32_t size) {
232
236
transfer->p_data .rx = data;
233
237
transfer->size = size;
234
238
235
- // Update the number of bytes remaining in the setup data stage
239
+ // if((setup_total == 1) && ((setup_buf.bmRequestType & SETUP_TRANSFER_DIR_MASK) == 0))
240
+ // {
241
+ // setup_remaining -= size;
242
+ // }
243
+ // else
244
+ // {
245
+ // // Update the number of bytes remaining in the setup data stage
246
+ // setup_remaining -= size;
247
+ // }
248
+
236
249
setup_remaining -= size;
237
250
238
251
nrf_drv_usbd_setup_data_clear (); // tell the hardware to receive another OUT packet
@@ -412,10 +425,10 @@ void USBPhyHw::process() {
412
425
if (setup_buf.wLength == 0 ) {
413
426
nrf_drv_usbd_setup_clear ();
414
427
}
415
- else if ((setup_buf.bmRequestType & SETUP_TRANSFER_DIR_MASK) == 0 ) {
416
- // HOST->DEVICE transfer, need to notify hardware of Data OUT stage
417
- nrf_drv_usbd_setup_data_clear ();
418
- }
428
+ // else if((setup_buf.bmRequestType & SETUP_TRANSFER_DIR_MASK) == 0) {
429
+ // // HOST->DEVICE transfer, need to notify hardware of Data OUT stage
430
+ // nrf_drv_usbd_setup_data_clear();
431
+ // }
419
432
420
433
// Notify the Mbed stack
421
434
events->ep0_setup ();
@@ -496,6 +509,10 @@ void USBPhyHw::_reset(void)
496
509
// Disable all endpoints except for control endpoints
497
510
nrf_drv_usbd_ep_default_config ();
498
511
512
+ nrf_drv_usbd_setup_clear ();
513
+
514
+ usb_event_type = USB_HW_EVENT_NONE;
515
+
499
516
// TODO - Clear all endpoint interrupts?
500
517
}
501
518
0 commit comments