diff options
| author | Reinhard Panhuber <[email protected]> | 2021-02-12 18:05:20 +0100 |
|---|---|---|
| committer | Reinhard Panhuber <[email protected]> | 2021-02-12 18:05:20 +0100 |
| commit | cdf600048f717f187243b8118eac43b793c3feec (patch) | |
| tree | 00d88a8e39560c2e1a35f6c9feb97062733d9d8b /examples/device/usbtmc | |
| parent | 185414721ff549058a199ade40966015e6260996 (diff) | |
| parent | 09868434cd9f53394350cce682333ada97f796c3 (diff) | |
Merge remote-tracking branch 'upstream/master' into edpt_ISO_xfer
Diffstat (limited to 'examples/device/usbtmc')
| -rw-r--r-- | examples/device/usbtmc/CMakeLists.txt | 42 | ||||
| -rw-r--r-- | examples/device/usbtmc/src/tusb_config.h | 3 | ||||
| -rw-r--r-- | examples/device/usbtmc/src/usb_descriptors.c | 5 |
3 files changed, 47 insertions, 3 deletions
diff --git a/examples/device/usbtmc/CMakeLists.txt b/examples/device/usbtmc/CMakeLists.txt new file mode 100644 index 000000000..9a4aa382b --- /dev/null +++ b/examples/device/usbtmc/CMakeLists.txt @@ -0,0 +1,42 @@ +# use directory name for project id +get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) + +# TOP is absolute path to root directory of TinyUSB git repo +set(TOP "../../..") +get_filename_component(TOP "${TOP}" REALPATH) + +# Check for -DFAMILY= +if(FAMILY STREQUAL "rp2040") + cmake_minimum_required(VERSION 3.12) + set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk) + include(${PICO_SDK_PATH}/pico_sdk_init.cmake) + project(${PROJECT}) + pico_sdk_init() + add_executable(${PROJECT}) + + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + + # Example source + target_sources(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/usbtmc_app.c + ) + + # Example include + target_include_directories(${PROJECT} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) + + # Example defines + target_compile_definitions(${PROJECT} PUBLIC + CFG_TUSB_OS=OPT_OS_PICO + ) + + target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration) + pico_add_extra_outputs(${PROJECT}) + +else() + message(FATAL_ERROR "Invalid FAMILY specified") +endif() diff --git a/examples/device/usbtmc/src/tusb_config.h b/examples/device/usbtmc/src/tusb_config.h index 603e67453..a192d0dbc 100644 --- a/examples/device/usbtmc/src/tusb_config.h +++ b/examples/device/usbtmc/src/tusb_config.h @@ -46,8 +46,9 @@ #error "Incorrect RHPort configuration" #endif -// This example doesn't use an RTOS +#ifndef CFG_TUSB_OS #define CFG_TUSB_OS OPT_OS_NONE +#endif // CFG_TUSB_DEBUG is defined by compiler in DEBUG build // #define CFG_TUSB_DEBUG 0 diff --git a/examples/device/usbtmc/src/usb_descriptors.c b/examples/device/usbtmc/src/usb_descriptors.c index 505456769..2336266b8 100644 --- a/examples/device/usbtmc/src/usb_descriptors.c +++ b/examples/device/usbtmc/src/usb_descriptors.c @@ -80,10 +80,11 @@ uint8_t const * tud_descriptor_device_cb(void) TUD_USBTMC_BULK_DESCRIPTORS(/* OUT = */0x01, /* IN = */ 0x81, /* packet size = */USBTMCD_MAX_PACKET_SIZE) #if CFG_TUD_USBTMC_ENABLE_INT_EP -// Interrupt endpoint should be 2 bytes on a FS USB link +// USBTMC Interrupt xfer always has length of 2, but we use epMaxSize=8 for +// compatibility with mcus that only allow 8, 16, 32 or 64 for FS endpoints # define TUD_USBTMC_DESC(_itfnum) \ TUD_USBTMC_DESC_MAIN(_itfnum, /* _epCount = */ 3), \ - TUD_USBTMC_INT_DESCRIPTOR(/* INT ep # */ 0x82, /* epMaxSize = */ 2, /* bInterval = */16u ) + TUD_USBTMC_INT_DESCRIPTOR(/* INT ep # */ 0x82, /* epMaxSize = */ 8, /* bInterval = */16u ) # define TUD_USBTMC_DESC_LEN (TUD_USBTMC_IF_DESCRIPTOR_LEN + TUD_USBTMC_BULK_DESCRIPTORS_LEN + TUD_USBTMC_INT_DESCRIPTOR_LEN) #else |
