Skip to content

Commit c1bf19e

Browse files
authored
Merge pull request #3023 from ennebi/mtp
Add support for MTP device class
2 parents f655d21 + 610f353 commit c1bf19e

File tree

43 files changed

+4475
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4475
-32
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,25 +199,28 @@ jobs:
199199
runs-on: [self-hosted, X64, hathach, hardware-in-the-loop]
200200
steps:
201201
- name: Clean workspace
202-
if: github.run_attempt == '1'
203202
run: |
204203
echo "Cleaning up for the first run"
205204
rm -rf "${{ github.workspace }}"
206205
mkdir -p "${{ github.workspace }}"
207206
208207
- name: Checkout TinyUSB
209-
if: github.run_attempt == '1'
210208
uses: actions/checkout@v4
211-
with:
212-
sparse-checkout: test/hil
213209

214210
- name: Download Artifacts
215-
if: github.run_attempt == '1'
216211
uses: actions/download-artifact@v4
217212
with:
218213
path: cmake-build
219214
merge-multiple: true
220215

216+
- name: Cache skip list
217+
uses: actions/cache@v4
218+
with:
219+
path: ${{ env.HIL_JSON }}.skip
220+
key: hil-skip-${{ github.run_id }}-${{ github.run_attempt }}
221+
restore-keys: |
222+
hil-skip-${{ github.run_id }}-
223+
221224
- name: Test on actual hardware
222225
run: |
223226
ls cmake-build/

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Supports multiple device configurations by dynamically changing USB descriptors,
6060
- Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ...
6161
- Mass Storage Class (MSC): with multiple LUNs
6262
- Musical Instrument Digital Interface (MIDI)
63+
- Media Transfer Protocol (MTP/PTP)
6364
- Network with RNDIS, Ethernet Control Model (ECM), Network Control Model (NCM)
6465
- Test and Measurement Class (USBTMC)
6566
- Video class 1.5 (UVC): work in progress

docs/reference/getting_started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ By default log message is printed via on-board UART which is slow and take lots
178178
* Pros: work with most if not all MCUs
179179
* Software viewer is JLink RTT Viewer/Client/Logger which is bundled with JLink driver package.
180180

181-
* ``LOGGER=swo``\ : Use dedicated SWO pin of ARM Cortex SWD debug header.
181+
* ``LOGGER=swo`` : Use dedicated SWO pin of ARM Cortex SWD debug header.
182182

183183
* Cons: only work with ARM Cortex MCUs minus M0
184184
* Pros: should be compatible with more debugger that support SWO.

examples/device/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ family_add_subdirectory(hid_generic_inout)
2626
family_add_subdirectory(hid_multiple_interface)
2727
family_add_subdirectory(midi_test)
2828
family_add_subdirectory(msc_dual_lun)
29+
family_add_subdirectory(mtp)
2930
family_add_subdirectory(net_lwip_webserver)
3031
family_add_subdirectory(uac2_headset)
3132
family_add_subdirectory(uac2_speaker_fb)

examples/device/cdc_msc/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) {
184184
(void) index; // for multiple configurations
185185

186186
// if link speed is high return fullspeed config, and vice versa
187-
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
187+
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
188188
memcpy(desc_other_speed_config,
189189
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
190190
CONFIG_TOTAL_LEN);

examples/device/cdc_msc_freertos/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index) {
186186
(void) index; // for multiple configurations
187187

188188
// if link speed is high return fullspeed config, and vice versa
189-
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
189+
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
190190
memcpy(desc_other_speed_config,
191191
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
192192
CONFIG_TOTAL_LEN);

examples/device/cdc_uac2/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) {
176176
(void) index; // for multiple configurations
177177

178178
// if link speed is high return fullspeed config, and vice versa
179-
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
179+
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
180180
memcpy(desc_other_speed_config,
181181
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
182182
CONFIG_TOTAL_LEN);

examples/device/hid_composite/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index)
154154
{
155155
(void) index; // for multiple configurations
156156

157-
// other speed config is basically configuration with type = OHER_SPEED_CONFIG
157+
// other speed config is basically configuration with type = OTHER_SPEED_CONFIG
158158
memcpy(desc_other_speed_config, desc_configuration, CONFIG_TOTAL_LEN);
159159
desc_other_speed_config[1] = TUSB_DESC_OTHER_SPEED_CONFIG;
160160

examples/device/hid_composite_freertos/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index)
153153
{
154154
(void) index; // for multiple configurations
155155

156-
// other speed config is basically configuration with type = OHER_SPEED_CONFIG
156+
// other speed config is basically configuration with type = OTHER_SPEED_CONFIG
157157
memcpy(desc_other_speed_config, desc_configuration, CONFIG_TOTAL_LEN);
158158
desc_other_speed_config[1] = TUSB_DESC_OTHER_SPEED_CONFIG;
159159

examples/device/mtp/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
3+
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
4+
5+
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
6+
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
7+
8+
project(${PROJECT} C CXX ASM)
9+
10+
# Checks this example is valid for the family and initializes the project
11+
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
12+
13+
# Espressif has its own cmake build system
14+
if(FAMILY STREQUAL "espressif")
15+
return()
16+
endif()
17+
18+
if (RTOS STREQUAL zephyr)
19+
set(EXE_NAME app)
20+
else()
21+
set(EXE_NAME ${PROJECT})
22+
add_executable(${EXE_NAME})
23+
endif()
24+
25+
# Example source
26+
target_sources(${EXE_NAME} PRIVATE
27+
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
28+
${CMAKE_CURRENT_SOURCE_DIR}/src/mtp_fs_example.c
29+
${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
30+
)
31+
32+
# Example include
33+
target_include_directories(${EXE_NAME} PUBLIC
34+
${CMAKE_CURRENT_SOURCE_DIR}/src
35+
)
36+
37+
# Configure compilation flags and libraries for the example without RTOS.
38+
# See the corresponding function in hw/bsp/FAMILY/family.cmake for details.
39+
family_configure_device_example(${EXE_NAME} ${RTOS})

0 commit comments

Comments
 (0)