@@ -242,24 +242,41 @@ void HWCDC::begin(unsigned long baud)
242
242
log_e (" HW CDC TX Buffer error" );
243
243
}
244
244
}
245
+ <<<<<<< Updated upstream
245
246
// Setting USB D+ D- pins
247
+ =======
248
+ // Setting USB D+ D- pins || reduces number of debug messages
249
+ >>>>>>> Stashed changes
246
250
uint8_t pin = USB_DM_GPIO_NUM;
247
- if (perimanGetPinBusType (pin) != ESP32_BUS_TYPE_INIT){
248
- if (!perimanClearPinBus (pin)){
251
+ if (perimanGetPinBusType (pin) != ESP32_BUS_TYPE_USB_DM){
252
+ if (perimanGetPinBusType (pin) != ESP32_BUS_TYPE_INIT){
253
+ if (!perimanClearPinBus (pin)){
254
+ goto err;
255
+ }
256
+ }
257
+ if (!perimanSetPinBus (pin, ESP32_BUS_TYPE_USB_DM, (void *) this , -1 , -1 )){
249
258
goto err;
250
259
}
251
260
}
252
- if (!perimanSetPinBus (pin, ESP32_BUS_TYPE_USB_DM, (void *) this , -1 , -1 )){
253
- goto err;
254
- }
255
261
pin = USB_DP_GPIO_NUM;
256
- if (perimanGetPinBusType (pin) != ESP32_BUS_TYPE_INIT){
257
- if (!perimanClearPinBus (pin)){
262
+ if (perimanGetPinBusType (pin) != ESP32_BUS_TYPE_USB_DP){
263
+ if (perimanGetPinBusType (pin) != ESP32_BUS_TYPE_INIT){
264
+ if (!perimanClearPinBus (pin)){
265
+ goto err;
266
+ }
267
+ }
268
+ if (!perimanSetPinBus (pin, ESP32_BUS_TYPE_USB_DP, (void *) this , -1 , -1 )){
258
269
goto err;
259
270
}
260
271
}
261
- if (!perimanSetPinBus (pin, ESP32_BUS_TYPE_USB_DP, (void *) this , -1 , -1 )){
262
- goto err;
272
+ // Configure PHY
273
+ usb_phy_ll_int_jtag_enable (&USB_SERIAL_JTAG);
274
+ usb_serial_jtag_ll_disable_intr_mask (USB_SERIAL_JTAG_LL_INTR_MASK);
275
+ usb_serial_jtag_ll_ena_intr_mask (USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT | USB_SERIAL_JTAG_INTR_BUS_RESET);
276
+ if (!intr_handle && esp_intr_alloc (ETS_USB_SERIAL_JTAG_INTR_SOURCE, 0 , hw_cdc_isr_handler, NULL , &intr_handle) != ESP_OK){
277
+ isr_log_e (" HW USB CDC failed to init interrupts" );
278
+ end ();
279
+ return ;
263
280
}
264
281
// Configure PHY
265
282
usb_phy_ll_int_jtag_enable (&USB_SERIAL_JTAG);
0 commit comments