Hi there.
I'd like to adapt the behaviour of my application depending on wether the native USB console is plugged or not.
Is there a software-based way to know this?
Do I have to use an extra GPIO plugged on the VUSB (with resistors to lower the voltage) ?
Regards,
Arnaud
ESP32-C3 How to know if USB console (GPIO18, GPIO19) is plugged in?
-
- Posts: 9017
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP32-C3 How to know if USB console (GPIO18, GPIO19) is plugged in?
I'm not sure if we have software for that, but the hardware makes the latest SOF received available in a register. While USB is connected, that number should increase at exactly once every millisecond. You could use that.
Re: ESP32-C3 How to know if USB console (GPIO18, GPIO19) is plugged in?
@ESP_Sprite: sounds good enough, I can live with this.
Could you provide a link to some documentation where to look for this register and give it a go?
Arnaud
Could you provide a link to some documentation where to look for this register and give it a go?
Arnaud
Re: ESP32-C3 How to know if USB console (GPIO18, GPIO19) is plugged in?
Found it in the meantime: does the trick very well.
Thanks.
Code: Select all
USB_SERIAL_JTAG_FRAM_NUM_REG
Thanks.
-
- Posts: 3
- Joined: Thu Jan 19, 2023 12:52 pm
Re: ESP32-C3 How to know if USB console (GPIO18, GPIO19) is plugged in?
For esp32-c3 returns zero if usb is not connected, otherwise returns a positive integer (10).
Code: Select all
int is_plugged_usb(void){
uint32_t *aa = USB_SERIAL_JTAG_FRAM_NUM_REG;
uint32_t first = *aa;
vTaskDelay(pdMS_TO_TICKS(10));
return (int) (*aa - first);
}
Who is online
Users browsing this forum: Bing [Bot], bushpulbek, djixon, Majestic-12 [Bot], steevke and 130 guests