Skip to content

Commit 4030666

Browse files
committed
esp32/usb: Fix building with USB CDC disabled.
This commit fixes the build issues in the ESP32 port that arise when explicitly disabling USB CDC support. The USB support code gated the USB serial number retrieval behind the USB CDC support definition, even though all USB devices must be able to be queried for their serial number. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
1 parent b136a72 commit 4030666

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ports/esp32/usb.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@
2828
#include "py/mphal.h"
2929
#include "usb.h"
3030

31-
#if MICROPY_HW_USB_CDC
32-
#include "esp_rom_gpio.h"
31+
#if MICROPY_HW_ENABLE_USBDEV
32+
3333
#include "esp_mac.h"
34-
#include "esp_private/usb_phy.h"
3534

3635
#include "shared/tinyusb/mp_usbd.h"
3736

37+
#if MICROPY_HW_USB_CDC
38+
#include "esp_rom_gpio.h"
39+
#include "esp_private/usb_phy.h"
40+
3841
static usb_phy_handle_t phy_hdl;
3942

4043

@@ -69,6 +72,8 @@ void usb_usj_mode(void) {
6972
}
7073
#endif
7174

75+
#endif // MICROPY_HW_USB_CDC
76+
7277
void mp_usbd_port_get_serial_number(char *serial_buf) {
7378
// use factory default MAC as serial ID
7479
uint8_t mac[8];
@@ -77,4 +82,4 @@ void mp_usbd_port_get_serial_number(char *serial_buf) {
7782
mp_usbd_hex_str(serial_buf, mac, sizeof(mac));
7883
}
7984

80-
#endif // MICROPY_HW_USB_CDC
85+
#endif // MICROPY_HW_ENABLE_USBDEV

0 commit comments

Comments
 (0)