rp2040 cdc_msc work well
This commit is contained in:
parent
a780a8762b
commit
c58c8c4229
|
@ -1,11 +1,12 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
# use directory name for project id
|
||||||
|
get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||||
|
|
||||||
# TOP is absolute path to root directory of TinyUSB git repo
|
# TOP is absolute path to root directory of TinyUSB git repo
|
||||||
set(TOP "../../..")
|
set(TOP "../../..")
|
||||||
get_filename_component(TOP "${TOP}" REALPATH)
|
get_filename_component(TOP "${TOP}" REALPATH)
|
||||||
|
|
||||||
set(PROJECT board_test)
|
|
||||||
|
|
||||||
# Check for -DFAMILY=
|
# Check for -DFAMILY=
|
||||||
if(NOT DEFINED FAMILY)
|
if(NOT DEFINED FAMILY)
|
||||||
message(FATAL_ERROR "Invalid FAMILY specified")
|
message(FATAL_ERROR "Invalid FAMILY specified")
|
||||||
|
@ -20,16 +21,36 @@ pico_sdk_init()
|
||||||
|
|
||||||
add_executable(${PROJECT})
|
add_executable(${PROJECT})
|
||||||
|
|
||||||
|
# TinyUSB Stack source
|
||||||
|
set(SRC_TINYUSB
|
||||||
|
${TOP}/src/tusb.c
|
||||||
|
${TOP}/src/common/tusb_fifo.c
|
||||||
|
${TOP}/src/device/usbd.c
|
||||||
|
${TOP}/src/device/usbd_control.c
|
||||||
|
${TOP}/src/class/audio/audio_device.c
|
||||||
|
${TOP}/src/class/cdc/cdc_device.c
|
||||||
|
${TOP}/src/class/dfu/dfu_rt_device.c
|
||||||
|
${TOP}/src/class/hid/hid_device.c
|
||||||
|
${TOP}/src/class/midi/midi_device.c
|
||||||
|
${TOP}/src/class/msc/msc_device.c
|
||||||
|
${TOP}/src/class/net/net_device.c
|
||||||
|
${TOP}/src/class/usbtmc/usbtmc_device.c
|
||||||
|
${TOP}/src/class/vendor/vendor_device.c
|
||||||
|
${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c
|
||||||
|
${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c
|
||||||
|
)
|
||||||
|
|
||||||
target_sources(${PROJECT} PUBLIC
|
target_sources(${PROJECT} PUBLIC
|
||||||
src/main.c
|
src/main.c
|
||||||
"${TOP}/hw/bsp/${FAMILY}/family.c"
|
${TOP}/hw/bsp/${FAMILY}/family.c
|
||||||
|
${SRC_TINYUSB}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${PROJECT} PUBLIC
|
target_include_directories(${PROJECT} PUBLIC
|
||||||
"src/"
|
src/
|
||||||
"${TOP}/hw"
|
${TOP}/hw
|
||||||
"${TOP}/src"
|
${TOP}/src
|
||||||
"${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}"
|
${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT} PUBLIC
|
target_compile_definitions(${PROJECT} PUBLIC
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
# use directory name for project id
|
||||||
|
get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||||
|
|
||||||
|
# TOP is absolute path to root directory of TinyUSB git repo
|
||||||
|
set(TOP "../../..")
|
||||||
|
get_filename_component(TOP "${TOP}" REALPATH)
|
||||||
|
|
||||||
|
# Check for -DFAMILY=
|
||||||
|
if(NOT DEFINED FAMILY)
|
||||||
|
message(FATAL_ERROR "Invalid FAMILY specified")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
|
||||||
|
project(${PROJECT})
|
||||||
|
|
||||||
|
if(FAMILY STREQUAL "rp2040")
|
||||||
|
|
||||||
|
pico_sdk_init()
|
||||||
|
|
||||||
|
add_executable(${PROJECT})
|
||||||
|
|
||||||
|
# TinyUSB Stack source
|
||||||
|
set(SRC_TINYUSB
|
||||||
|
${TOP}/src/tusb.c
|
||||||
|
${TOP}/src/common/tusb_fifo.c
|
||||||
|
${TOP}/src/device/usbd.c
|
||||||
|
${TOP}/src/device/usbd_control.c
|
||||||
|
${TOP}/src/class/audio/audio_device.c
|
||||||
|
${TOP}/src/class/cdc/cdc_device.c
|
||||||
|
${TOP}/src/class/dfu/dfu_rt_device.c
|
||||||
|
${TOP}/src/class/hid/hid_device.c
|
||||||
|
${TOP}/src/class/midi/midi_device.c
|
||||||
|
${TOP}/src/class/msc/msc_device.c
|
||||||
|
${TOP}/src/class/net/net_device.c
|
||||||
|
${TOP}/src/class/usbtmc/usbtmc_device.c
|
||||||
|
${TOP}/src/class/vendor/vendor_device.c
|
||||||
|
${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c
|
||||||
|
${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Example source
|
||||||
|
set(SRC_EXAMPLE
|
||||||
|
src/main.c
|
||||||
|
src/msc_disk.c
|
||||||
|
src/usb_descriptors.c
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(${PROJECT} PUBLIC
|
||||||
|
${SRC_EXAMPLE}
|
||||||
|
${TOP}/hw/bsp/${FAMILY}/family.c
|
||||||
|
${SRC_TINYUSB}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT} PUBLIC
|
||||||
|
src/
|
||||||
|
${TOP}/hw
|
||||||
|
${TOP}/src
|
||||||
|
${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(${PROJECT} PUBLIC
|
||||||
|
CFG_TUSB_MCU=OPT_MCU_RP2040
|
||||||
|
CFG_TUSB_OS=OPT_OS_PICO
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT} pico_stdlib)
|
||||||
|
|
||||||
|
pico_add_extra_outputs(${PROJECT})
|
||||||
|
|
||||||
|
endif()
|
|
@ -65,7 +65,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This example doesn't use an RTOS
|
// This example doesn't use an RTOS
|
||||||
|
#ifndef CFG_TUSB_OS
|
||||||
#define CFG_TUSB_OS OPT_OS_NONE
|
#define CFG_TUSB_OS OPT_OS_NONE
|
||||||
|
#endif
|
||||||
|
|
||||||
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
|
||||||
// #define CFG_TUSB_DEBUG 0
|
// #define CFG_TUSB_DEBUG 0
|
||||||
|
|
|
@ -83,6 +83,8 @@ void board_init(void)
|
||||||
gpio_set_dir(LED_PIN, GPIO_OUT);
|
gpio_set_dir(LED_PIN, GPIO_OUT);
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
|
#ifndef BUTTON_BOOTSEL
|
||||||
|
#endif
|
||||||
|
|
||||||
// todo probably set up device mode?
|
// todo probably set up device mode?
|
||||||
#if TUSB_OPT_DEVICE_ENABLED
|
#if TUSB_OPT_DEVICE_ENABLED
|
||||||
|
@ -94,20 +96,6 @@ void board_init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////--------------------------------------------------------------------+
|
|
||||||
//// USB Interrupt Handler
|
|
||||||
////--------------------------------------------------------------------+
|
|
||||||
//void USB_IRQHandler(void)
|
|
||||||
//{
|
|
||||||
//#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
|
|
||||||
// tuh_isr(0);
|
|
||||||
//#endif
|
|
||||||
//
|
|
||||||
//#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
|
|
||||||
// tud_int_handler(0);
|
|
||||||
//#endif
|
|
||||||
//}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Board porting API
|
// Board porting API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -141,3 +129,9 @@ int board_uart_write(void const * buf, int len)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// USB Interrupt Handler
|
||||||
|
// rp2040 implementation will install approriate handler when initializing
|
||||||
|
// tinyusb. There is no need to forward IRQ from application
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
|
Loading…
Reference in New Issue