mirror of https://github.com/arendst/Tasmota.git
use new API for check of USB cable connection (#21135)
This commit is contained in:
parent
54e4aba750
commit
1721de0b76
|
@ -528,16 +528,11 @@ void setup(void) {
|
|||
|
||||
bool is_connected_to_USB = false;
|
||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED // Not S2
|
||||
rtc_clk_bbpll_add_consumer(); // Maybe unneeded
|
||||
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SOF);
|
||||
usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SOF);
|
||||
// First check if USB cable is connected - maybe add a new SetOption to prevent this
|
||||
for (uint32_t i = 0; i < 1000; i++) { // Allow the host to send at least one SOF packet, 1ms should be enough but let's be very conservative here - maybe unneeded
|
||||
is_connected_to_USB = ((usb_serial_jtag_ll_get_intraw_mask() & USB_SERIAL_JTAG_INTR_SOF) != 0);
|
||||
for (uint32_t i = 0; i < 5; i++) { // wait up to 250 ms - maybe a shorter time is enough
|
||||
is_connected_to_USB = usb_serial_jtag_is_connected();
|
||||
if (is_connected_to_USB) { break; }
|
||||
delay(1);
|
||||
delay(50);
|
||||
}
|
||||
rtc_clk_bbpll_remove_consumer();
|
||||
#else
|
||||
is_connected_to_USB = true; // S2
|
||||
#endif // SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
|
|
Loading…
Reference in New Issue