26
26
#include " soc/io_mux_reg.h"
27
27
#pragma GCC diagnostic ignored "-Wvolatile"
28
28
#include " hal/usb_serial_jtag_ll.h"
29
+ #include " hal/usb_phy_ll.h"
29
30
#pragma GCC diagnostic warning "-Wvolatile"
30
31
#include " rom/ets_sys.h"
31
32
#include " driver/usb_serial_jtag.h"
@@ -238,13 +239,6 @@ void HWCDC::begin(unsigned long baud)
238
239
log_e (" HW CDC TX Buffer error" );
239
240
}
240
241
}
241
- usb_serial_jtag_ll_disable_intr_mask (USB_SERIAL_JTAG_LL_INTR_MASK);
242
- 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);
243
- if (!intr_handle && esp_intr_alloc (ETS_USB_SERIAL_JTAG_INTR_SOURCE, 0 , hw_cdc_isr_handler, NULL , &intr_handle) != ESP_OK){
244
- isr_log_e (" HW USB CDC failed to init interrupts" );
245
- end ();
246
- return ;
247
- }
248
242
// Setting USB D+ D- pins
249
243
uint8_t pin = USB_DM_GPIO_NUM;
250
244
if (perimanGetPinBusType (pin) != ESP32_BUS_TYPE_INIT){
@@ -264,6 +258,15 @@ void HWCDC::begin(unsigned long baud)
264
258
if (!perimanSetPinBus (pin, ESP32_BUS_TYPE_USB_DP, (void *) this , -1 , -1 )){
265
259
goto err;
266
260
}
261
+ // Configure PHY
262
+ usb_phy_ll_int_jtag_enable (&USB_SERIAL_JTAG);
263
+ usb_serial_jtag_ll_disable_intr_mask (USB_SERIAL_JTAG_LL_INTR_MASK);
264
+ 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);
265
+ if (!intr_handle && esp_intr_alloc (ETS_USB_SERIAL_JTAG_INTR_SOURCE, 0 , hw_cdc_isr_handler, NULL , &intr_handle) != ESP_OK){
266
+ isr_log_e (" HW USB CDC failed to init interrupts" );
267
+ end ();
268
+ return ;
269
+ }
267
270
return ;
268
271
269
272
err:
0 commit comments