Skip to content

Commit

Permalink
ports/esp32: Use shared/tinyusb integration.
Browse files Browse the repository at this point in the history
Uses newer libusb synopsys/dwc2 driver rather than
the IDF tinyusb component.

Signed-off-by: Andrew Leech <[email protected]>
  • Loading branch information
pi-anl committed Jun 20, 2024
1 parent 457e02a commit 722590c
Showing 1 changed file with 35 additions and 28 deletions.
63 changes: 35 additions & 28 deletions ports/esp32/esp32_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,6 @@ list(APPEND MICROPY_SOURCE_DRIVERS
${MICROPY_DIR}/drivers/dht/dht.c
)

if(MICROPY_PY_TINYUSB)
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/tinyusb)

set(TINYUSB_SRC "${MICROPY_DIR}/lib/tinyusb/src")
string(TOUPPER OPT_MCU_${IDF_TARGET} tusb_mcu)

list(APPEND MICROPY_DEF_CORE
CFG_TUSB_MCU=${tusb_mcu}
)

list(APPEND MICROPY_SOURCE_LIB
${TINYUSB_SRC}/tusb.c
${TINYUSB_SRC}/common/tusb_fifo.c
${TINYUSB_SRC}/device/usbd.c
${TINYUSB_SRC}/device/usbd_control.c
${TINYUSB_SRC}/class/cdc/cdc_device.c
${TINYUSB_SRC}/portable/synopsys/dwc2/dcd_dwc2.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd_cdc.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd_descriptor.c
)

list(APPEND MICROPY_INC_CORE
${TINYUSB_SRC}
${MICROPY_DIR}/shared/tinyusb/
)
endif()

list(APPEND MICROPY_SOURCE_PORT
panichandler.c
adc.c
Expand Down Expand Up @@ -220,6 +192,41 @@ target_include_directories(${MICROPY_TARGET} PUBLIC
${IDF_PATH}/components/bt/host/nimble/nimble
)

if(MICROPY_PY_TINYUSB)
string(CONCAT GIT_SUBMODULES "${GIT_SUBMODULES} " lib/tinyusb)

# if(ECHO_SUBMODULES)
# # No-op, we're just doing submodule/variant discovery.
# # Cannot run the add_library/target_include_directories rules (even though
# # the build won't run) because IDF will attempt verify the files exist.
# else()

set(TINYUSB_SRC "${MICROPY_DIR}/lib/tinyusb/src")
string(TOUPPER OPT_MCU_${IDF_TARGET} tusb_mcu)

list(APPEND MICROPY_DEF_CORE
CFG_TUSB_MCU=${tusb_mcu}
)

list(APPEND MICROPY_SOURCE_LIB
${TINYUSB_SRC}/tusb.c
${TINYUSB_SRC}/common/tusb_fifo.c
${TINYUSB_SRC}/device/usbd.c
${TINYUSB_SRC}/device/usbd_control.c
${TINYUSB_SRC}/class/cdc/cdc_device.c
${TINYUSB_SRC}/portable/synopsys/dwc2/dcd_dwc2.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd_cdc.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd_descriptor.c
)

target_include_directories(${MICROPY_TARGET} PRIVATE
${TINYUSB_SRC}
${MICROPY_DIR}/shared/tinyusb/
)
# endif()
endif()

# Add additional extmod and usermod components.
target_link_libraries(${MICROPY_TARGET} micropy_extmod_btree)
target_link_libraries(${MICROPY_TARGET} usermod)
Expand Down

0 comments on commit 722590c

Please sign in to comment.