Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32C3 USB pullup interferes with GPIO configuration #1244

Closed
BRA1L0R opened this issue Mar 5, 2024 · 1 comment
Closed

ESP32C3 USB pullup interferes with GPIO configuration #1244

BRA1L0R opened this issue Mar 5, 2024 · 1 comment
Labels
peripheral:usb USB peripheral

Comments

@BRA1L0R
Copy link
Contributor

BRA1L0R commented Mar 5, 2024

There's already code to disable the USB when setting up GPIO pins for gpio18 and gpio19, but there's no code to clear the pull-ups. They interfere in my design and i found that manually clearing the pullup / pulldown pins fixes everything.

peripherals.USB_DEVICE.conf0().write(|w| {
        w.usb_pad_enable()
            .clear_bit()
            .dm_pullup()
            .clear_bit()
            .dm_pulldown()
            .clear_bit()
            .dp_pullup()
            .clear_bit()
            .dp_pulldown()
            .clear_bit()
    });

This is an example of how I personally fixed the problem. It should be implemented here:

esp-hal/esp-hal/src/gpio.rs

Lines 619 to 624 in 8841d82

#[cfg(esp32c3)]
if GPIONUM == 18 || GPIONUM == 19 {
unsafe { &*crate::peripherals::USB_DEVICE::PTR }
.conf0()
.modify(|_, w| w.usb_pad_enable().clear_bit());
}

@MabezDev
Copy link
Member

MabezDev commented Mar 6, 2024

Thanks for pointing this out, this indeed looks like an oversight. Would you mind PRing a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
peripheral:usb USB peripheral
Projects
Archived in project
Development

No branches or pull requests

3 participants