Skip to content

Commit a0f92cd

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 1092543 commit a0f92cd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ports/esp32/usb.c

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

31-
#if MICROPY_HW_USB_CDC
32-
#include "esp_rom_gpio.h"
3331
#include "esp_mac.h"
34-
#include "esp_private/usb_phy.h"
3532

3633
#include "shared/tinyusb/mp_usbd.h"
3734

35+
#if MICROPY_HW_USB_CDC
36+
#include "esp_rom_gpio.h"
37+
#include "esp_private/usb_phy.h"
38+
3839
static usb_phy_handle_t phy_hdl;
3940

4041

@@ -69,12 +70,12 @@ void usb_usj_mode(void) {
6970
}
7071
#endif
7172

73+
#endif // MICROPY_HW_USB_CDC
74+
7275
void mp_usbd_port_get_serial_number(char *serial_buf) {
7376
// use factory default MAC as serial ID
7477
uint8_t mac[8];
7578
esp_efuse_mac_get_default(mac);
7679
MP_STATIC_ASSERT(sizeof(mac) * 2 <= MICROPY_HW_USB_DESC_STR_MAX);
7780
mp_usbd_hex_str(serial_buf, mac, sizeof(mac));
7881
}
79-
80-
#endif // MICROPY_HW_USB_CDC

0 commit comments

Comments
 (0)