mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
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;
|
bool is_connected_to_USB = false;
|
||||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED // Not S2
|
#if SOC_USB_SERIAL_JTAG_SUPPORTED // Not S2
|
||||||
rtc_clk_bbpll_add_consumer(); // Maybe unneeded
|
for (uint32_t i = 0; i < 5; i++) { // wait up to 250 ms - maybe a shorter time is enough
|
||||||
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SOF);
|
is_connected_to_USB = usb_serial_jtag_is_connected();
|
||||||
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);
|
|
||||||
if (is_connected_to_USB) { break; }
|
if (is_connected_to_USB) { break; }
|
||||||
delay(1);
|
delay(50);
|
||||||
}
|
}
|
||||||
rtc_clk_bbpll_remove_consumer();
|
|
||||||
#else
|
#else
|
||||||
is_connected_to_USB = true; // S2
|
is_connected_to_USB = true; // S2
|
||||||
#endif // SOC_USB_SERIAL_JTAG_SUPPORTED
|
#endif // SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user