mirror of
https://github.com/hathach/tinyusb.git
synced 2026-03-04 14:47:13 +00:00
Merge remote-tracking branch 'tinyusb/master' into uac1
This commit is contained in:
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
@ -199,25 +199,28 @@ jobs:
|
||||
runs-on: [self-hosted, X64, hathach, hardware-in-the-loop]
|
||||
steps:
|
||||
- name: Clean workspace
|
||||
if: github.run_attempt == '1'
|
||||
run: |
|
||||
echo "Cleaning up for the first run"
|
||||
rm -rf "${{ github.workspace }}"
|
||||
mkdir -p "${{ github.workspace }}"
|
||||
|
||||
- name: Checkout TinyUSB
|
||||
if: github.run_attempt == '1'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: test/hil
|
||||
|
||||
- name: Download Artifacts
|
||||
if: github.run_attempt == '1'
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: cmake-build
|
||||
merge-multiple: true
|
||||
|
||||
- name: Cache skip list
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.HIL_JSON }}.skip
|
||||
key: hil-skip-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
restore-keys: |
|
||||
hil-skip-${{ github.run_id }}-
|
||||
|
||||
- name: Test on actual hardware
|
||||
run: |
|
||||
ls cmake-build/
|
||||
|
||||
2
.github/workflows/ci_set_matrix.py
vendored
2
.github/workflows/ci_set_matrix.py
vendored
@ -44,7 +44,7 @@ family_list = {
|
||||
"stm32h7 stm32h7rs": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||
"stm32l0 stm32l4": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||
"stm32n6": ["arm-gcc"],
|
||||
"stm32u5 stm32wb": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||
"stm32u0 stm32u5 stm32wb": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||
"stm32wba": ["arm-gcc", "arm-clang"],
|
||||
"xmc4000": ["arm-gcc"],
|
||||
"-bespressif_s2_devkitc": ["esp-idf"],
|
||||
|
||||
49
.github/workflows/claude.yml
vendored
Normal file
49
.github/workflows/claude.yml
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
name: Claude Code
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_review_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened, assigned]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
claude:
|
||||
if: |
|
||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
issues: read
|
||||
id-token: write
|
||||
actions: read # Required for Claude to read CI results on PRs
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
# This is an optional setting that allows Claude to read CI results on PRs
|
||||
additional_permissions: |
|
||||
actions: read
|
||||
|
||||
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
|
||||
# prompt: 'Update the pull request description to include a summary of changes.'
|
||||
|
||||
# Optional: Add claude_args to customize behavior and configuration
|
||||
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
||||
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
|
||||
# claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'
|
||||
69
CLAUDE.md
Normal file
69
CLAUDE.md
Normal file
@ -0,0 +1,69 @@
|
||||
# TinyUSB Development Guide
|
||||
|
||||
## Build Commands
|
||||
|
||||
### CMake Build System (Preferred)
|
||||
CMake with Ninja is the preferred build method for TinyUSB development.
|
||||
|
||||
- Build example with Ninja:
|
||||
```bash
|
||||
cd examples/device/cdc_msc
|
||||
mkdir build && cd build
|
||||
cmake -G Ninja -DBOARD=raspberry_pi_pico ..
|
||||
ninja
|
||||
```
|
||||
- Debug build: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DCMAKE_BUILD_TYPE=Debug ..`
|
||||
- With logging: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DLOG=2 ..`
|
||||
- With RTT logger: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DLOG=2 -DLOGGER=rtt ..`
|
||||
- Flash with JLink: `ninja cdc_msc-jlink`
|
||||
- Flash with OpenOCD: `ninja cdc_msc-openocd`
|
||||
- Generate UF2: `ninja cdc_msc-uf2`
|
||||
- List all targets: `ninja -t targets`
|
||||
|
||||
### Make Build System (Alternative)
|
||||
- Build example: `cd examples/device/cdc_msc && make BOARD=raspberry_pi_pico all`
|
||||
- For specific example: `cd examples/{device|host|dual}/{example_name} && make BOARD=raspberry_pi_pico all`
|
||||
- Flash with JLink: `make BOARD=raspberry_pi_pico flash-jlink`
|
||||
- Flash with OpenOCD: `make BOARD=raspberry_pi_pico flash-openocd`
|
||||
- Debug build: `make BOARD=raspberry_pi_pico DEBUG=1 all`
|
||||
- With logging: `make BOARD=raspberry_pi_pico LOG=2 all`
|
||||
- With RTT logger: `make BOARD=raspberry_pi_pico LOG=2 LOGGER=rtt all`
|
||||
- Generate UF2: `make BOARD=raspberry_pi_pico all uf2`
|
||||
|
||||
### Additional Options
|
||||
- Select RootHub port: `RHPORT_DEVICE=1` (make) or `-DRHPORT_DEVICE=1` (cmake)
|
||||
- Set port speed: `RHPORT_DEVICE_SPEED=OPT_MODE_FULL_SPEED` (make) or `-DRHPORT_DEVICE_SPEED=OPT_MODE_FULL_SPEED` (cmake)
|
||||
|
||||
### Dependencies
|
||||
- Get dependencies: `python tools/get_deps.py rp2040`
|
||||
- Or from example: `cd examples/device/cdc_msc && make BOARD=raspberry_pi_pico get-deps`
|
||||
|
||||
### Testing
|
||||
- Run unit tests: `cd test/unit-test && ceedling test:all`
|
||||
- Run specific test: `cd test/unit-test && ceedling test:test_fifo`
|
||||
|
||||
### Pre-commit Hooks
|
||||
Before building, it's recommended to run pre-commit to ensure code quality:
|
||||
- Run pre-commit on all files: `pre-commit run --all-files`
|
||||
- Run pre-commit on staged files: `pre-commit run`
|
||||
- Install pre-commit hook: `pre-commit install`
|
||||
|
||||
## Code Style Guidelines
|
||||
- Use C99 standard
|
||||
- Memory-safe: no dynamic allocation
|
||||
- Thread-safe: defer all interrupt events to non-ISR task functions
|
||||
- 2-space indentation, no tabs
|
||||
- Use snake_case for variables/functions
|
||||
- Use UPPER_CASE for macros and constants
|
||||
- Follow existing variable naming patterns in files you're modifying
|
||||
- Include proper header comments with MIT license
|
||||
- Add descriptive comments for non-obvious functions
|
||||
- When including headers, group in order: C stdlib, tusb common, drivers, classes
|
||||
- Always check return values from functions that can fail
|
||||
- Use TU_ASSERT() for error checking with return statements
|
||||
|
||||
## Project Structure
|
||||
- src/: Core TinyUSB stack code
|
||||
- hw/: Board support packages and MCU drivers
|
||||
- examples/: Reference examples for device/host/dual
|
||||
- test/: Unit tests and hardware integration tests
|
||||
@ -60,6 +60,7 @@ Supports multiple device configurations by dynamically changing USB descriptors,
|
||||
- Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ...
|
||||
- Mass Storage Class (MSC): with multiple LUNs
|
||||
- Musical Instrument Digital Interface (MIDI)
|
||||
- Media Transfer Protocol (MTP/PTP)
|
||||
- Network with RNDIS, Ethernet Control Model (ECM), Network Control Model (NCM)
|
||||
- Test and Measurement Class (USBTMC)
|
||||
- Video class 1.5 (UVC): work in progress
|
||||
@ -115,7 +116,7 @@ Supported CPUs
|
||||
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | F402_F405 | ✔ | ✔ | ✔ | dwc2 | F405 is HS |
|
||||
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| Brigetek | FT90x | ✔ | | ✔ | ft9xx | 1-dir ep |
|
||||
| Bridgetek | FT90x | ✔ | | ✔ | ft9xx | 1-dir ep |
|
||||
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| Broadcom | BCM2711, BCM2837 | ✔ | | ✔ | dwc2 | |
|
||||
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
@ -147,7 +148,7 @@ Supported CPUs
|
||||
| | +-----------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | | 32mz | ✔ | | | pic32mz | musb variant |
|
||||
+--------------+-----+-----------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| Mind Montion | mm32 | ✔ | | ✖ | mm32f327x_otg | ci_fs variant |
|
||||
| MindMotion | mm32 | ✔ | | ✖ | mm32f327x_otg | ci_fs variant |
|
||||
+--------------+-----+-----------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| NordicSemi | nRF 52833, 52840, 5340 | ✔ | ✖ | ✖ | nrf5x | only ep8 is ISO |
|
||||
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
@ -202,8 +203,6 @@ Supported CPUs
|
||||
| | C0, G0, H5 | ✔ | | ✖ | stm32_fsdev | |
|
||||
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | G4 | ✔ | ✖ | ✖ | stm32_fsdev | |
|
||||
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | L0, L1 | ✔ | ✖ | ✖ | stm32_fsdev | |
|
||||
| +----+------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | L4 | 4x2, 4x3 | ✔ | ✖ | ✖ | stm32_fsdev | |
|
||||
| | +------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
@ -211,6 +210,8 @@ Supported CPUs
|
||||
| +----+------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | N6 | ✔ | ✔ | ✔ | dwc2 | |
|
||||
| +----+------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | U0 | ✔ | ✖ | ✖ | stm32_fsdev | |
|
||||
| +----+------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | U5 | 535, 545 | ✔ | | ✖ | stm32_fsdev | |
|
||||
| | +------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | | 575, 585 | ✔ | ✔ | ✖ | dwc2 | |
|
||||
|
||||
@ -299,6 +299,7 @@ stm32l4r5nucleo STM32 L4R5 Nucleo stm32l4 https://www.s
|
||||
stm32n6570dk STM32 N6570-DK stm32n6 https://www.st.com/en/evaluation-tools/stm32n6570-dk.html
|
||||
stm32n657nucleo STM32 N657X0-Q Nucleo stm32n6 https://www.st.com/en/evaluation-tools/nucleo-n657x0-q.html
|
||||
b_u585i_iot2a STM32 B-U585i IOT2A Discovery kit stm32u5 https://www.st.com/en/evaluation-tools/b-u585i-iot02a.html
|
||||
stm32u083cdk STM32 U083C Discovery Kit stm32u0 https://www.st.com/en/evaluation-tools/stm32u083c-dk.html
|
||||
stm32u545nucleo STM32 U545 Nucleo stm32u5 https://www.st.com/en/evaluation-tools/nucleo-u545re-q.html
|
||||
stm32u575eval STM32 U575 Eval stm32u5 https://www.st.com/en/evaluation-tools/stm32u575i-ev.html
|
||||
stm32u575nucleo STM32 U575 Nucleo stm32u5 https://www.st.com/en/evaluation-tools/nucleo-u575zi-q.html
|
||||
|
||||
@ -178,7 +178,7 @@ By default log message is printed via on-board UART which is slow and take lots
|
||||
* Pros: work with most if not all MCUs
|
||||
* Software viewer is JLink RTT Viewer/Client/Logger which is bundled with JLink driver package.
|
||||
|
||||
* ``LOGGER=swo``\ : Use dedicated SWO pin of ARM Cortex SWD debug header.
|
||||
* ``LOGGER=swo`` : Use dedicated SWO pin of ARM Cortex SWD debug header.
|
||||
|
||||
* Cons: only work with ARM Cortex MCUs minus M0
|
||||
* Pros: should be compatible with more debugger that support SWO.
|
||||
|
||||
@ -134,8 +134,8 @@ endif
|
||||
ifeq ($(LOGGER),rtt)
|
||||
CFLAGS += -DLOGGER_RTT
|
||||
#CFLAGS += -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
||||
INC += $(TOP)/$(lib/SEGGER_RTT)/RTT
|
||||
SRC_C += $(lib/SEGGER_RTT)/RTT/SEGGER_RTT.c
|
||||
INC += $(TOP)/lib/SEGGER_RTT/RTT
|
||||
SRC_C += lib/SEGGER_RTT/RTT/SEGGER_RTT.c
|
||||
endif
|
||||
ifeq ($(LOGGER),swo)
|
||||
CFLAGS += -DLOGGER_SWO
|
||||
|
||||
@ -26,6 +26,7 @@ family_add_subdirectory(hid_generic_inout)
|
||||
family_add_subdirectory(hid_multiple_interface)
|
||||
family_add_subdirectory(midi_test)
|
||||
family_add_subdirectory(msc_dual_lun)
|
||||
family_add_subdirectory(mtp)
|
||||
family_add_subdirectory(net_lwip_webserver)
|
||||
family_add_subdirectory(uac2_headset)
|
||||
family_add_subdirectory(uac2_speaker_fb)
|
||||
|
||||
@ -184,7 +184,7 @@ uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) {
|
||||
(void) index; // for multiple configurations
|
||||
|
||||
// if link speed is high return fullspeed config, and vice versa
|
||||
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
|
||||
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
|
||||
memcpy(desc_other_speed_config,
|
||||
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
|
||||
CONFIG_TOTAL_LEN);
|
||||
|
||||
@ -186,7 +186,7 @@ uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index) {
|
||||
(void) index; // for multiple configurations
|
||||
|
||||
// if link speed is high return fullspeed config, and vice versa
|
||||
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
|
||||
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
|
||||
memcpy(desc_other_speed_config,
|
||||
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
|
||||
CONFIG_TOTAL_LEN);
|
||||
|
||||
@ -176,7 +176,7 @@ uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) {
|
||||
(void) index; // for multiple configurations
|
||||
|
||||
// if link speed is high return fullspeed config, and vice versa
|
||||
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
|
||||
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
|
||||
memcpy(desc_other_speed_config,
|
||||
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
|
||||
CONFIG_TOTAL_LEN);
|
||||
|
||||
@ -154,7 +154,7 @@ uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index)
|
||||
{
|
||||
(void) index; // for multiple configurations
|
||||
|
||||
// other speed config is basically configuration with type = OHER_SPEED_CONFIG
|
||||
// other speed config is basically configuration with type = OTHER_SPEED_CONFIG
|
||||
memcpy(desc_other_speed_config, desc_configuration, CONFIG_TOTAL_LEN);
|
||||
desc_other_speed_config[1] = TUSB_DESC_OTHER_SPEED_CONFIG;
|
||||
|
||||
|
||||
@ -153,7 +153,7 @@ uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index)
|
||||
{
|
||||
(void) index; // for multiple configurations
|
||||
|
||||
// other speed config is basically configuration with type = OHER_SPEED_CONFIG
|
||||
// other speed config is basically configuration with type = OTHER_SPEED_CONFIG
|
||||
memcpy(desc_other_speed_config, desc_configuration, CONFIG_TOTAL_LEN);
|
||||
desc_other_speed_config[1] = TUSB_DESC_OTHER_SPEED_CONFIG;
|
||||
|
||||
|
||||
39
examples/device/mtp/CMakeLists.txt
Normal file
39
examples/device/mtp/CMakeLists.txt
Normal file
@ -0,0 +1,39 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
|
||||
|
||||
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
|
||||
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
project(${PROJECT} C CXX ASM)
|
||||
|
||||
# Checks this example is valid for the family and initializes the project
|
||||
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
# Espressif has its own cmake build system
|
||||
if(FAMILY STREQUAL "espressif")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (RTOS STREQUAL zephyr)
|
||||
set(EXE_NAME app)
|
||||
else()
|
||||
set(EXE_NAME ${PROJECT})
|
||||
add_executable(${EXE_NAME})
|
||||
endif()
|
||||
|
||||
# Example source
|
||||
target_sources(${EXE_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/mtp_fs_example.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
|
||||
)
|
||||
|
||||
# Example include
|
||||
target_include_directories(${EXE_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
# Configure compilation flags and libraries for the example without RTOS.
|
||||
# See the corresponding function in hw/bsp/FAMILY/family.cmake for details.
|
||||
family_configure_device_example(${EXE_NAME} ${RTOS})
|
||||
6
examples/device/mtp/CMakePresets.json
Normal file
6
examples/device/mtp/CMakePresets.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": 6,
|
||||
"include": [
|
||||
"../../../hw/bsp/BoardPresets.json"
|
||||
]
|
||||
}
|
||||
11
examples/device/mtp/Makefile
Normal file
11
examples/device/mtp/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
include ../../build_system/make/make.mk
|
||||
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
include ../../build_system/make/rules.mk
|
||||
6
examples/device/mtp/prj.conf
Normal file
6
examples/device/mtp/prj.conf
Normal file
@ -0,0 +1,6 @@
|
||||
CONFIG_GPIO=y
|
||||
CONFIG_FPU=y
|
||||
CONFIG_NO_OPTIMIZATIONS=y
|
||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
CONFIG_NRFX_POWER=y
|
||||
CONFIG_NRFX_UARTE0=y
|
||||
1
examples/device/mtp/skip.txt
Normal file
1
examples/device/mtp/skip.txt
Normal file
@ -0,0 +1 @@
|
||||
board:cynthion_d11
|
||||
110
examples/device/mtp/src/main.c
Normal file
110
examples/device/mtp/src/main.c
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2025 Ennebi Elettronica (https://ennebielettronica.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "tusb.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
/* Blink pattern
|
||||
* - 250 ms : device not mounted
|
||||
* - 1000 ms : device mounted
|
||||
* - 2500 ms : device is suspended
|
||||
*/
|
||||
enum {
|
||||
BLINK_NOT_MOUNTED = 250,
|
||||
BLINK_MOUNTED = 1000,
|
||||
BLINK_SUSPENDED = 2500,
|
||||
};
|
||||
|
||||
static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED;
|
||||
|
||||
void led_blinking_task(void);
|
||||
|
||||
/*------------- MAIN -------------*/
|
||||
int main(void) {
|
||||
board_init();
|
||||
|
||||
// init device stack on configured roothub port
|
||||
tusb_rhport_init_t dev_init = {
|
||||
.role = TUSB_ROLE_DEVICE,
|
||||
.speed = TUSB_SPEED_AUTO
|
||||
};
|
||||
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||
board_init_after_tusb();
|
||||
|
||||
while (1) {
|
||||
tud_task(); // tinyusb device task
|
||||
led_blinking_task();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Device callbacks
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invoked when device is mounted
|
||||
void tud_mount_cb(void) {
|
||||
blink_interval_ms = BLINK_MOUNTED;
|
||||
}
|
||||
|
||||
// Invoked when device is unmounted
|
||||
void tud_umount_cb(void) {
|
||||
blink_interval_ms = BLINK_NOT_MOUNTED;
|
||||
}
|
||||
|
||||
// Invoked when usb bus is suspended
|
||||
// remote_wakeup_en : if host allow us to perform remote wakeup
|
||||
// Within 7ms, device must draw an average of current less than 2.5 mA from bus
|
||||
void tud_suspend_cb(bool remote_wakeup_en) {
|
||||
(void) remote_wakeup_en;
|
||||
blink_interval_ms = BLINK_SUSPENDED;
|
||||
}
|
||||
|
||||
// Invoked when usb bus is resumed
|
||||
void tud_resume_cb(void) {
|
||||
blink_interval_ms = tud_mounted() ? BLINK_MOUNTED : BLINK_NOT_MOUNTED;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLINKING TASK
|
||||
//--------------------------------------------------------------------+
|
||||
void led_blinking_task(void) {
|
||||
static uint32_t start_ms = 0;
|
||||
static bool led_state = false;
|
||||
|
||||
// Blink every interval ms
|
||||
if (board_millis() - start_ms < blink_interval_ms) return; // not enough time
|
||||
start_ms += blink_interval_ms;
|
||||
|
||||
board_led_write(led_state);
|
||||
led_state = 1 - led_state; // toggle
|
||||
}
|
||||
624
examples/device/mtp/src/mtp_fs_example.c
Normal file
624
examples/device/mtp/src/mtp_fs_example.c
Normal file
@ -0,0 +1,624 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2025 Ennebi Elettronica (https://ennebielettronica.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "tusb.h"
|
||||
|
||||
#include "tinyusb_logo_png.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Dataset
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//------------- device info -------------//
|
||||
#define DEV_INFO_MANUFACTURER "TinyUSB"
|
||||
#define DEV_INFO_MODEL "MTP Example"
|
||||
#define DEV_INFO_VERSION "1.0"
|
||||
#define DEV_PROP_FRIENDLY_NAME "TinyUSB MTP"
|
||||
|
||||
//------------- storage info -------------//
|
||||
#define STORAGE_DESCRIPTRION { 'd', 'i', 's', 'k', 0 }
|
||||
#define VOLUME_IDENTIFIER { 'v', 'o', 'l', 0 }
|
||||
|
||||
typedef MTP_STORAGE_INFO_STRUCT(TU_ARRAY_SIZE((uint16_t[]) STORAGE_DESCRIPTRION),
|
||||
TU_ARRAY_SIZE(((uint16_t[])VOLUME_IDENTIFIER))
|
||||
) storage_info_t;
|
||||
|
||||
storage_info_t storage_info = {
|
||||
#ifdef CFG_EXAMPLE_MTP_READONLY
|
||||
.storage_type = MTP_STORAGE_TYPE_FIXED_ROM,
|
||||
#else
|
||||
.storage_type = MTP_STORAGE_TYPE_FIXED_RAM,
|
||||
#endif
|
||||
|
||||
.filesystem_type = MTP_FILESYSTEM_TYPE_GENERIC_HIERARCHICAL,
|
||||
.access_capability = MTP_ACCESS_CAPABILITY_READ_WRITE,
|
||||
.max_capacity_in_bytes = 0, // calculated at runtime
|
||||
.free_space_in_bytes = 0, // calculated at runtime
|
||||
.free_space_in_objects = 0, // calculated at runtime
|
||||
.storage_description = {
|
||||
.count = (TU_FIELD_SZIE(storage_info_t, storage_description)-1) / sizeof(uint16_t),
|
||||
.utf16 = STORAGE_DESCRIPTRION
|
||||
},
|
||||
.volume_identifier = {
|
||||
.count = (TU_FIELD_SZIE(storage_info_t, volume_identifier)-1) / sizeof(uint16_t),
|
||||
.utf16 = VOLUME_IDENTIFIER
|
||||
}
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MTP FILESYSTEM
|
||||
//--------------------------------------------------------------------+
|
||||
// only allow to add 1 more object to make it simpler to manage memory
|
||||
#define FS_MAX_FILE_COUNT 3UL
|
||||
#define FS_MAX_FILENAME_LEN 16
|
||||
|
||||
#ifdef CFG_EXAMPLE_MTP_READONLY
|
||||
#define FS_MAX_CAPACITY_BYTES 0
|
||||
#else
|
||||
#define FS_MAX_CAPACITY_BYTES (4 * 1024UL)
|
||||
|
||||
// object data buffer (excluding 2 predefined files) with simple allocation pointer
|
||||
uint8_t fs_buf[FS_MAX_CAPACITY_BYTES];
|
||||
#endif
|
||||
|
||||
#define FS_FIXED_DATETIME "20250808T173500.0" // "YYYYMMDDTHHMMSS.s"
|
||||
#define README_TXT_CONTENT "TinyUSB MTP Filesystem example"
|
||||
|
||||
typedef struct {
|
||||
uint16_t name[FS_MAX_FILENAME_LEN];
|
||||
uint16_t object_format;
|
||||
uint16_t protection_status;
|
||||
uint32_t image_pix_width;
|
||||
uint32_t image_pix_height;
|
||||
uint32_t image_bit_depth;
|
||||
uint32_t parent;
|
||||
uint16_t association_type;
|
||||
uint32_t size;
|
||||
uint8_t* data;
|
||||
} fs_file_t;
|
||||
|
||||
// Files system, handle is index + 1
|
||||
static fs_file_t fs_objects[FS_MAX_FILE_COUNT] = {
|
||||
{
|
||||
.name = { 'r', 'e', 'a', 'd', 'm', 'e', '.', 't', 'x', 't', 0 }, // readme.txt
|
||||
.object_format = MTP_OBJ_FORMAT_TEXT,
|
||||
.protection_status = MTP_PROTECTION_STATUS_READ_ONLY,
|
||||
.image_pix_width = 0,
|
||||
.image_pix_height = 0,
|
||||
.image_bit_depth = 0,
|
||||
.parent = 0,
|
||||
.association_type = MTP_ASSOCIATION_UNDEFINED,
|
||||
.data = (uint8_t*) (uintptr_t) README_TXT_CONTENT,
|
||||
.size = sizeof(README_TXT_CONTENT)-1
|
||||
},
|
||||
{
|
||||
.name = { 't', 'i', 'n', 'y', 'u', 's', 'b', '.', 'p', 'n', 'g', 0 }, // "tinyusb.png"
|
||||
.object_format = MTP_OBJ_FORMAT_PNG,
|
||||
.protection_status = MTP_PROTECTION_STATUS_READ_ONLY,
|
||||
.image_pix_width = 128,
|
||||
.image_pix_height = 64,
|
||||
.image_bit_depth = 32,
|
||||
.parent = 0,
|
||||
.association_type = MTP_ASSOCIATION_UNDEFINED,
|
||||
.data = (uint8_t*) (uintptr_t) logo_bin,
|
||||
.size = logo_len,
|
||||
}
|
||||
};
|
||||
|
||||
enum {
|
||||
SUPPORTED_STORAGE_ID = 0x00010001u // physical = 1, logical = 1
|
||||
};
|
||||
|
||||
static int32_t fs_get_device_info(tud_mtp_cb_data_t* cb_data);
|
||||
static int32_t fs_open_close_session(tud_mtp_cb_data_t* cb_data);
|
||||
static int32_t fs_get_storage_ids(tud_mtp_cb_data_t* cb_data);
|
||||
static int32_t fs_get_storage_info(tud_mtp_cb_data_t* cb_data);
|
||||
static int32_t fs_get_device_properties(tud_mtp_cb_data_t* cb_data);
|
||||
static int32_t fs_get_object_handles(tud_mtp_cb_data_t* cb_data);
|
||||
static int32_t fs_get_object_info(tud_mtp_cb_data_t* cb_data);
|
||||
static int32_t fs_get_object(tud_mtp_cb_data_t* cb_data);
|
||||
static int32_t fs_delete_object(tud_mtp_cb_data_t* cb_data);
|
||||
static int32_t fs_send_object_info(tud_mtp_cb_data_t* cb_data);
|
||||
static int32_t fs_send_object(tud_mtp_cb_data_t* cb_data);
|
||||
|
||||
typedef int32_t (*fs_op_handler_t)(tud_mtp_cb_data_t* cb_data);
|
||||
typedef struct {
|
||||
uint32_t op_code;
|
||||
fs_op_handler_t handler;
|
||||
}fs_op_handler_dict_t;
|
||||
|
||||
fs_op_handler_dict_t fs_op_handler_dict[] = {
|
||||
{ MTP_OP_GET_DEVICE_INFO, fs_get_device_info },
|
||||
{ MTP_OP_OPEN_SESSION, fs_open_close_session },
|
||||
{ MTP_OP_CLOSE_SESSION, fs_open_close_session },
|
||||
{ MTP_OP_GET_STORAGE_IDS, fs_get_storage_ids },
|
||||
{ MTP_OP_GET_STORAGE_INFO, fs_get_storage_info },
|
||||
{ MTP_OP_GET_DEVICE_PROP_DESC, fs_get_device_properties },
|
||||
{ MTP_OP_GET_DEVICE_PROP_VALUE, fs_get_device_properties },
|
||||
{ MTP_OP_GET_OBJECT_HANDLES, fs_get_object_handles },
|
||||
{ MTP_OP_GET_OBJECT_INFO, fs_get_object_info },
|
||||
{ MTP_OP_GET_OBJECT, fs_get_object },
|
||||
{ MTP_OP_DELETE_OBJECT, fs_delete_object },
|
||||
{ MTP_OP_SEND_OBJECT_INFO, fs_send_object_info },
|
||||
{ MTP_OP_SEND_OBJECT, fs_send_object },
|
||||
};
|
||||
|
||||
static bool is_session_opened = false;
|
||||
static uint32_t send_obj_handle = 0;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
//
|
||||
//--------------------------------------------------------------------+
|
||||
// Get pointer to object info from handle
|
||||
static inline fs_file_t* fs_get_file(uint32_t handle) {
|
||||
if (handle == 0 || handle > FS_MAX_FILE_COUNT) {
|
||||
return NULL;
|
||||
}
|
||||
return &fs_objects[handle-1];
|
||||
}
|
||||
|
||||
static inline bool fs_file_exist(fs_file_t* f) {
|
||||
return f->name[0] != 0;
|
||||
}
|
||||
|
||||
// Get the number of allocated nodes in filesystem
|
||||
static uint32_t fs_get_file_count(void) {
|
||||
uint32_t count = 0;
|
||||
for (size_t i = 0; i < FS_MAX_FILE_COUNT; i++) {
|
||||
if (fs_file_exist(&fs_objects[i])) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static inline fs_file_t* fs_create_file(void) {
|
||||
for (size_t i = 0; i < FS_MAX_FILE_COUNT; i++) {
|
||||
fs_file_t* f = &fs_objects[i];
|
||||
if (!fs_file_exist(f)) {
|
||||
send_obj_handle = i + 1;
|
||||
return f;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// simple malloc
|
||||
static inline uint8_t* fs_malloc(size_t size) {
|
||||
#ifdef CFG_EXAMPLE_MTP_READONLY
|
||||
(void) size;
|
||||
return NULL;
|
||||
#else
|
||||
if (size > FS_MAX_CAPACITY_BYTES) {
|
||||
return NULL;
|
||||
}
|
||||
return fs_buf;
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Control Request callback
|
||||
//--------------------------------------------------------------------+
|
||||
bool tud_mtp_request_cancel_cb(tud_mtp_request_cb_data_t* cb_data) {
|
||||
mtp_request_reset_cancel_data_t cancel_data;
|
||||
memcpy(&cancel_data, cb_data->buf, sizeof(cancel_data));
|
||||
(void) cancel_data.code;
|
||||
(void ) cancel_data.transaction_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invoked when received Device Reset request
|
||||
// return false to stall the request
|
||||
bool tud_mtp_request_device_reset_cb(tud_mtp_request_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invoked when received Get Extended Event request. Application fill callback data's buffer for response
|
||||
// return negative to stall the request
|
||||
int32_t tud_mtp_request_get_extended_event_cb(tud_mtp_request_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return false; // not implemented yet
|
||||
}
|
||||
|
||||
// Invoked when received Get DeviceStatus request. Application fill callback data's buffer for response
|
||||
// return negative to stall the request
|
||||
int32_t tud_mtp_request_get_device_status_cb(tud_mtp_request_cb_data_t* cb_data) {
|
||||
uint16_t* buf16 = (uint16_t*)(uintptr_t) cb_data->buf;
|
||||
buf16[0] = 4; // length
|
||||
buf16[1] = MTP_RESP_OK; // status
|
||||
return 4;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Bulk Only Protocol
|
||||
//--------------------------------------------------------------------+
|
||||
int32_t tud_mtp_command_received_cb(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
fs_op_handler_t handler = NULL;
|
||||
for (size_t i = 0; i < TU_ARRAY_SIZE(fs_op_handler_dict); i++) {
|
||||
if (fs_op_handler_dict[i].op_code == command->header.code) {
|
||||
handler = fs_op_handler_dict[i].handler;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t resp_code;
|
||||
if (handler == NULL) {
|
||||
resp_code = MTP_RESP_OPERATION_NOT_SUPPORTED;
|
||||
} else {
|
||||
resp_code = handler(cb_data);
|
||||
if (resp_code > MTP_RESP_UNDEFINED) {
|
||||
// send response if needed
|
||||
io_container->header->code = (uint16_t)resp_code;
|
||||
tud_mtp_response_send(io_container);
|
||||
}
|
||||
}
|
||||
|
||||
return resp_code;
|
||||
}
|
||||
|
||||
int32_t tud_mtp_data_xfer_cb(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
|
||||
fs_op_handler_t handler = NULL;
|
||||
for (size_t i = 0; i < TU_ARRAY_SIZE(fs_op_handler_dict); i++) {
|
||||
if (fs_op_handler_dict[i].op_code == command->header.code) {
|
||||
handler = fs_op_handler_dict[i].handler;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t resp_code;
|
||||
if (handler == NULL) {
|
||||
resp_code = MTP_RESP_OPERATION_NOT_SUPPORTED;
|
||||
} else {
|
||||
resp_code = handler(cb_data);
|
||||
if (resp_code > MTP_RESP_UNDEFINED) {
|
||||
// send response if needed
|
||||
io_container->header->code = (uint16_t)resp_code;
|
||||
tud_mtp_response_send(io_container);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tud_mtp_data_complete_cb(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
mtp_container_info_t* resp = &cb_data->io_container;
|
||||
switch (command->header.code) {
|
||||
case MTP_OP_SEND_OBJECT_INFO: {
|
||||
fs_file_t* f = fs_get_file(send_obj_handle);
|
||||
if (f == NULL) {
|
||||
resp->header->code = MTP_RESP_GENERAL_ERROR;
|
||||
break;
|
||||
}
|
||||
// parameter is: storage id, parent handle, new handle
|
||||
mtp_container_add_uint32(resp, SUPPORTED_STORAGE_ID);
|
||||
mtp_container_add_uint32(resp, f->parent);
|
||||
mtp_container_add_uint32(resp, send_obj_handle);
|
||||
resp->header->code = MTP_RESP_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
resp->header->code = (cb_data->xfer_result == XFER_RESULT_SUCCESS) ? MTP_RESP_OK : MTP_RESP_GENERAL_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
tud_mtp_response_send(resp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tud_mtp_response_complete_cb(tud_mtp_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return 0; // nothing to do
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// File System Handlers
|
||||
//--------------------------------------------------------------------+
|
||||
static int32_t fs_get_device_info(tud_mtp_cb_data_t* cb_data) {
|
||||
// Device info is already prepared up to playback formats. Application only need to add string fields
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
mtp_container_add_cstring(io_container, DEV_INFO_MANUFACTURER);
|
||||
mtp_container_add_cstring(io_container, DEV_INFO_MODEL);
|
||||
mtp_container_add_cstring(io_container, DEV_INFO_VERSION);
|
||||
|
||||
enum { MAX_SERIAL_NCHARS = 32 };
|
||||
uint16_t serial_utf16[MAX_SERIAL_NCHARS+1];
|
||||
size_t nchars = board_usb_get_serial(serial_utf16, MAX_SERIAL_NCHARS);
|
||||
serial_utf16[tu_min32(nchars, MAX_SERIAL_NCHARS)] = 0; // ensure null termination
|
||||
mtp_container_add_string(io_container, serial_utf16);
|
||||
|
||||
tud_mtp_data_send(io_container);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t fs_open_close_session(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
if (command->header.code == MTP_OP_OPEN_SESSION) {
|
||||
if (is_session_opened) {
|
||||
return MTP_RESP_SESSION_ALREADY_OPEN;
|
||||
}
|
||||
is_session_opened = true;
|
||||
} else { // close session
|
||||
if (!is_session_opened) {
|
||||
return MTP_RESP_SESSION_NOT_OPEN;
|
||||
}
|
||||
is_session_opened = false;
|
||||
}
|
||||
return MTP_RESP_OK;
|
||||
}
|
||||
|
||||
static int32_t fs_get_storage_ids(tud_mtp_cb_data_t* cb_data) {
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
uint32_t storage_ids [] = { SUPPORTED_STORAGE_ID };
|
||||
mtp_container_add_auint32(io_container, 1, storage_ids);
|
||||
tud_mtp_data_send(io_container);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t fs_get_storage_info(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
const uint32_t storage_id = command->params[0];
|
||||
TU_VERIFY(SUPPORTED_STORAGE_ID == storage_id, -1);
|
||||
// update storage info with current free space
|
||||
storage_info.max_capacity_in_bytes = sizeof(README_TXT_CONTENT) + logo_len + FS_MAX_CAPACITY_BYTES;
|
||||
storage_info.free_space_in_objects = FS_MAX_FILE_COUNT - fs_get_file_count();
|
||||
storage_info.free_space_in_bytes = storage_info.free_space_in_objects ? FS_MAX_CAPACITY_BYTES : 0;
|
||||
mtp_container_add_raw(io_container, &storage_info, sizeof(storage_info));
|
||||
tud_mtp_data_send(io_container);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t fs_get_device_properties(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
const uint16_t dev_prop_code = (uint16_t) command->params[0];
|
||||
|
||||
if (command->header.code == MTP_OP_GET_DEVICE_PROP_DESC) {
|
||||
// get describing dataset
|
||||
mtp_device_prop_desc_header_t device_prop_header;
|
||||
device_prop_header.device_property_code = dev_prop_code;
|
||||
switch (dev_prop_code) {
|
||||
case MTP_DEV_PROP_DEVICE_FRIENDLY_NAME:
|
||||
device_prop_header.datatype = MTP_DATA_TYPE_STR;
|
||||
device_prop_header.get_set = MTP_MODE_GET;
|
||||
mtp_container_add_raw(io_container, &device_prop_header, sizeof(device_prop_header));
|
||||
mtp_container_add_cstring(io_container, DEV_PROP_FRIENDLY_NAME); // factory
|
||||
mtp_container_add_cstring(io_container, DEV_PROP_FRIENDLY_NAME); // current
|
||||
mtp_container_add_uint8(io_container, 0); // no form
|
||||
tud_mtp_data_send(io_container);
|
||||
break;
|
||||
|
||||
default:
|
||||
return MTP_RESP_PARAMETER_NOT_SUPPORTED;
|
||||
}
|
||||
} else {
|
||||
// get value
|
||||
switch (dev_prop_code) {
|
||||
case MTP_DEV_PROP_DEVICE_FRIENDLY_NAME:
|
||||
mtp_container_add_cstring(io_container, DEV_PROP_FRIENDLY_NAME);
|
||||
tud_mtp_data_send(io_container);
|
||||
break;
|
||||
|
||||
default:
|
||||
return MTP_RESP_PARAMETER_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t fs_get_object_handles(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
|
||||
const uint32_t storage_id = command->params[0];
|
||||
const uint32_t obj_format = command->params[1]; // optional
|
||||
const uint32_t parent_handle = command->params[2]; // folder handle, 0xFFFFFFFF is root
|
||||
(void)obj_format;
|
||||
|
||||
if (storage_id != 0xFFFFFFFF && storage_id != SUPPORTED_STORAGE_ID) {
|
||||
return MTP_RESP_INVALID_STORAGE_ID;
|
||||
}
|
||||
|
||||
uint32_t handles[FS_MAX_FILE_COUNT] = { 0 };
|
||||
uint32_t count = 0;
|
||||
for (uint8_t i = 0; i < FS_MAX_FILE_COUNT; i++) {
|
||||
fs_file_t* f = &fs_objects[i];
|
||||
if (fs_file_exist(f) &&
|
||||
(parent_handle == f->parent || (parent_handle == 0xFFFFFFFF && f->parent == 0))) {
|
||||
handles[count++] = i + 1; // handle is index + 1
|
||||
}
|
||||
}
|
||||
mtp_container_add_auint32(io_container, count, handles);
|
||||
tud_mtp_data_send(io_container);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t fs_get_object_info(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
const uint32_t obj_handle = command->params[0];
|
||||
fs_file_t* f = fs_get_file(obj_handle);
|
||||
if (f == NULL) {
|
||||
return MTP_RESP_INVALID_OBJECT_HANDLE;
|
||||
}
|
||||
mtp_object_info_header_t obj_info_header = {
|
||||
.storage_id = SUPPORTED_STORAGE_ID,
|
||||
.object_format = f->object_format,
|
||||
.protection_status = f->protection_status,
|
||||
.object_compressed_size = f->size,
|
||||
.thumb_format = MTP_OBJ_FORMAT_UNDEFINED,
|
||||
.thumb_compressed_size = 0,
|
||||
.thumb_pix_width = 0,
|
||||
.thumb_pix_height = 0,
|
||||
.image_pix_width = f->image_pix_width,
|
||||
.image_pix_height = f->image_pix_height,
|
||||
.image_bit_depth = f->image_bit_depth,
|
||||
.parent_object = f->parent,
|
||||
.association_type = f->association_type,
|
||||
.association_desc = 0,
|
||||
.sequence_number = 0
|
||||
};
|
||||
mtp_container_add_raw(io_container, &obj_info_header, sizeof(obj_info_header));
|
||||
mtp_container_add_string(io_container, f->name);
|
||||
mtp_container_add_cstring(io_container, FS_FIXED_DATETIME);
|
||||
mtp_container_add_cstring(io_container, FS_FIXED_DATETIME);
|
||||
mtp_container_add_cstring(io_container, ""); // keywords, not used
|
||||
tud_mtp_data_send(io_container);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t fs_get_object(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
const uint32_t obj_handle = command->params[0];
|
||||
const fs_file_t* f = fs_get_file(obj_handle);
|
||||
if (f == NULL) {
|
||||
return MTP_RESP_INVALID_OBJECT_HANDLE;
|
||||
}
|
||||
|
||||
if (cb_data->phase == MTP_PHASE_COMMAND) {
|
||||
// If file contents is larger than CFG_TUD_MTP_EP_BUFSIZE, data may only partially is added here
|
||||
// the rest will be sent in tud_mtp_data_more_cb
|
||||
mtp_container_add_raw(io_container, f->data, f->size);
|
||||
tud_mtp_data_send(io_container);
|
||||
} else if (cb_data->phase == MTP_PHASE_DATA) {
|
||||
// continue sending remaining data: file contents offset is xferred byte minus header size
|
||||
const uint32_t offset = cb_data->total_xferred_bytes - sizeof(mtp_container_header_t);
|
||||
const uint32_t xact_len = tu_min32(f->size - offset, io_container->payload_bytes);
|
||||
if (xact_len > 0) {
|
||||
memcpy(io_container->payload, f->data + offset, xact_len);
|
||||
tud_mtp_data_send(io_container);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t fs_send_object_info(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
const uint32_t storage_id = command->params[0];
|
||||
const uint32_t parent_handle = command->params[1]; // folder handle, 0xFFFFFFFF is root
|
||||
(void) parent_handle;
|
||||
|
||||
if (!is_session_opened) {
|
||||
return MTP_RESP_SESSION_NOT_OPEN;
|
||||
}
|
||||
if (storage_id != 0xFFFFFFFF && storage_id != SUPPORTED_STORAGE_ID) {
|
||||
return MTP_RESP_INVALID_STORAGE_ID;
|
||||
}
|
||||
|
||||
if (cb_data->phase == MTP_PHASE_COMMAND) {
|
||||
tud_mtp_data_receive(io_container);
|
||||
} else if (cb_data->phase == MTP_PHASE_DATA) {
|
||||
mtp_object_info_header_t* obj_info = (mtp_object_info_header_t*) io_container->payload;
|
||||
if (obj_info->storage_id != 0 && obj_info->storage_id != SUPPORTED_STORAGE_ID) {
|
||||
return MTP_RESP_INVALID_STORAGE_ID;
|
||||
}
|
||||
|
||||
if (obj_info->parent_object) {
|
||||
fs_file_t* parent = fs_get_file(obj_info->parent_object);
|
||||
if (parent == NULL || !parent->association_type) {
|
||||
return MTP_RESP_INVALID_PARENT_OBJECT;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t* f_buf = fs_malloc(obj_info->object_compressed_size);
|
||||
if (f_buf == NULL) {
|
||||
return MTP_RESP_STORE_FULL;
|
||||
}
|
||||
fs_file_t* f = fs_create_file();
|
||||
if (f == NULL) {
|
||||
return MTP_RESP_STORE_FULL;
|
||||
}
|
||||
|
||||
f->object_format = obj_info->object_format;
|
||||
f->protection_status = obj_info->protection_status;
|
||||
f->image_pix_width = obj_info->image_pix_width;
|
||||
f->image_pix_height = obj_info->image_pix_height;
|
||||
f->image_bit_depth = obj_info->image_bit_depth;
|
||||
f->parent = obj_info->parent_object;
|
||||
f->association_type = obj_info->association_type;
|
||||
f->size = obj_info->object_compressed_size;
|
||||
f->data = f_buf;
|
||||
uint8_t* buf = io_container->payload + sizeof(mtp_object_info_header_t);
|
||||
mtp_container_get_string(buf, f->name);
|
||||
// ignore date created/modified/keywords
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t fs_send_object(tud_mtp_cb_data_t* cb_data) {
|
||||
mtp_container_info_t* io_container = &cb_data->io_container;
|
||||
fs_file_t* f = fs_get_file(send_obj_handle);
|
||||
if (f == NULL) {
|
||||
return MTP_RESP_INVALID_OBJECT_HANDLE;
|
||||
}
|
||||
|
||||
if (cb_data->phase == MTP_PHASE_COMMAND) {
|
||||
io_container->header->len += f->size;
|
||||
tud_mtp_data_receive(io_container);
|
||||
} else {
|
||||
// file contents offset is total xferred minus header size minus last received chunk
|
||||
const uint32_t offset = cb_data->total_xferred_bytes - sizeof(mtp_container_header_t) - io_container->payload_bytes;
|
||||
memcpy(f->data + offset, io_container->payload, io_container->payload_bytes);
|
||||
if (cb_data->total_xferred_bytes - sizeof(mtp_container_header_t) < f->size) {
|
||||
tud_mtp_data_receive(io_container);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t fs_delete_object(tud_mtp_cb_data_t* cb_data) {
|
||||
const mtp_container_command_t* command = cb_data->command_container;
|
||||
const uint32_t obj_handle = command->params[0];
|
||||
const uint32_t obj_format = command->params[1]; // optional
|
||||
(void) obj_format;
|
||||
|
||||
if (!is_session_opened) {
|
||||
return MTP_RESP_SESSION_NOT_OPEN;
|
||||
}
|
||||
fs_file_t* f = fs_get_file(obj_handle);
|
||||
if (f == NULL) {
|
||||
return MTP_RESP_INVALID_OBJECT_HANDLE;
|
||||
}
|
||||
|
||||
// delete object by clear the name
|
||||
f->name[0] = 0;
|
||||
return MTP_RESP_OK;
|
||||
}
|
||||
175
examples/device/mtp/src/tinyusb_logo_png.h
Normal file
175
examples/device/mtp/src/tinyusb_logo_png.h
Normal file
@ -0,0 +1,175 @@
|
||||
// convert using tools/file2carray.py
|
||||
const size_t logo_len = 2733;
|
||||
const uint8_t logo_bin[] __attribute__((aligned(16))) = {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
||||
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x08, 0x06, 0x00, 0x00, 0x00, 0xd2, 0xd6, 0x7f,
|
||||
0x7f, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
|
||||
0xbd, 0xa7, 0x93, 0x00, 0x00, 0x0a, 0x62, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0xed, 0x9c, 0x7d,
|
||||
0x54, 0x54, 0x65, 0x1a, 0xc0, 0x7f, 0xc3, 0x00, 0x29, 0x1f, 0x31, 0x88, 0x61, 0x90, 0xd6, 0xa1,
|
||||
0xb3, 0xba, 0x1a, 0x18, 0x7e, 0xf2, 0xad, 0x40, 0x82, 0xb8, 0x9b, 0x2b, 0x43, 0x1e, 0xd2, 0x00,
|
||||
0x53, 0xc0, 0xea, 0xec, 0xc9, 0x70, 0x18, 0x3d, 0x5b, 0xb1, 0x9e, 0x4a, 0x6d, 0x13, 0x2d, 0xcb,
|
||||
0x76, 0xcd, 0x00, 0xf3, 0x8b, 0x10, 0x8a, 0x8e, 0xd6, 0xee, 0xda, 0x8a, 0x96, 0x30, 0x66, 0xa2,
|
||||
0xa0, 0x91, 0x64, 0xae, 0x16, 0x98, 0x45, 0x9d, 0x2c, 0x93, 0x8f, 0x05, 0x11, 0x92, 0x81, 0xbb,
|
||||
0x7f, 0xa8, 0x93, 0x33, 0x23, 0xcc, 0xdc, 0x61, 0x60, 0x46, 0xb8, 0xbf, 0xbf, 0x78, 0xdf, 0xfb,
|
||||
0x3c, 0xcf, 0xfb, 0xc0, 0x7d, 0xee, 0x73, 0xdf, 0xf7, 0xb9, 0xef, 0x8b, 0x8c, 0x6b, 0x08, 0x82,
|
||||
0x90, 0x08, 0x2c, 0x03, 0x02, 0x81, 0x21, 0x48, 0x0c, 0x44, 0xda, 0x81, 0x6a, 0xe0, 0x55, 0x99,
|
||||
0x4c, 0x56, 0x0c, 0x20, 0x03, 0x10, 0x04, 0x61, 0x35, 0xb0, 0xc2, 0x86, 0x8e, 0x49, 0xf4, 0x3f,
|
||||
0x6b, 0x64, 0x32, 0x59, 0x96, 0x4c, 0x10, 0x84, 0x19, 0xc0, 0x47, 0x5c, 0x0b, 0x06, 0x89, 0x41,
|
||||
0x45, 0xac, 0x03, 0xa0, 0x42, 0xba, 0xf9, 0x83, 0x15, 0x95, 0x4c, 0x10, 0x84, 0x8b, 0x80, 0x97,
|
||||
0xad, 0x3d, 0x91, 0xb0, 0x09, 0x4d, 0x32, 0x41, 0x10, 0x3a, 0x01, 0x07, 0x5b, 0x7b, 0x22, 0x61,
|
||||
0x1b, 0x1c, 0x90, 0xd2, 0xff, 0xa0, 0x46, 0x7a, 0xf2, 0x07, 0x39, 0x52, 0x00, 0x0c, 0x72, 0x1c,
|
||||
0x2d, 0x55, 0x3c, 0x52, 0x5e, 0x4e, 0x53, 0x63, 0x93, 0x28, 0x9d, 0x49, 0x93, 0x27, 0x31, 0xe2,
|
||||
0xce, 0x3b, 0x4d, 0xca, 0x5d, 0xba, 0x74, 0x89, 0xea, 0x13, 0xd5, 0x26, 0xe5, 0x46, 0x8c, 0xf0,
|
||||
0xe6, 0x77, 0xa3, 0x47, 0x8b, 0xf2, 0x41, 0x42, 0x1f, 0x99, 0x20, 0x08, 0x5d, 0x58, 0x30, 0x0f,
|
||||
0x48, 0x7c, 0x68, 0x2e, 0x9f, 0x57, 0x55, 0x89, 0xd2, 0xd9, 0x94, 0x9b, 0xc3, 0xcc, 0xb8, 0x38,
|
||||
0x93, 0x72, 0x27, 0xbf, 0x38, 0x49, 0xc2, 0x9c, 0x39, 0x78, 0x78, 0x78, 0x74, 0x2b, 0xd3, 0xd6,
|
||||
0xd6, 0x46, 0xbc, 0x52, 0xc9, 0x9a, 0x75, 0x6b, 0x45, 0xf9, 0x20, 0xa1, 0x8f, 0xc5, 0x19, 0xa0,
|
||||
0x3f, 0xa8, 0xfc, 0xec, 0x38, 0x72, 0xc7, 0x9b, 0xbb, 0xb8, 0x22, 0x2b, 0x8b, 0x4e, 0x6d, 0x67,
|
||||
0x3f, 0x7b, 0x34, 0xf0, 0x90, 0xe6, 0x00, 0x83, 0x1c, 0xbb, 0x0e, 0x80, 0xb6, 0xb6, 0x36, 0x5e,
|
||||
0x5c, 0xb5, 0x8a, 0x0f, 0x76, 0xbf, 0x0f, 0x40, 0xdd, 0x77, 0xdf, 0xf1, 0xe2, 0xaa, 0x55, 0x1c,
|
||||
0xfe, 0xf4, 0xb0, 0x8d, 0x3d, 0x1b, 0x38, 0xd8, 0x75, 0x00, 0x68, 0xb5, 0x5a, 0x34, 0xa5, 0x65,
|
||||
0x9c, 0x3a, 0x75, 0x0a, 0x80, 0xa6, 0xa6, 0xff, 0xa1, 0x29, 0x2d, 0xa3, 0xae, 0xee, 0x3b, 0x1b,
|
||||
0x7b, 0x36, 0x70, 0xb0, 0xeb, 0x39, 0x80, 0xbb, 0xbb, 0x3b, 0x1f, 0x6b, 0xca, 0x74, 0xed, 0xfb,
|
||||
0x03, 0xef, 0xd7, 0xb5, 0x57, 0x64, 0x65, 0xd9, 0xca, 0xad, 0x01, 0x85, 0x5d, 0x07, 0x80, 0xbd,
|
||||
0x70, 0xb9, 0xf5, 0x32, 0x3f, 0x5f, 0xf8, 0x19, 0xb9, 0x83, 0x03, 0x6e, 0xee, 0xee, 0x28, 0x14,
|
||||
0x0a, 0x1c, 0x1c, 0xec, 0x3a, 0x79, 0x9a, 0x8d, 0xd9, 0xcb, 0xc0, 0x8e, 0x8e, 0x0e, 0x56, 0x3e,
|
||||
0xff, 0xbc, 0xae, 0xfd, 0xf1, 0xfe, 0x8f, 0xb8, 0x78, 0xf1, 0xa2, 0xa8, 0xc1, 0x22, 0xa6, 0x4d,
|
||||
0x63, 0xe4, 0xa8, 0x91, 0x7a, 0x7d, 0xa1, 0x61, 0x61, 0x3c, 0x38, 0x7b, 0xb6, 0xae, 0xfd, 0xf7,
|
||||
0x0d, 0x1b, 0x38, 0x73, 0xfa, 0x0c, 0xfb, 0xf7, 0xed, 0xe3, 0xe1, 0xf9, 0xf3, 0xba, 0xfd, 0x43,
|
||||
0x1f, 0xab, 0x3c, 0x86, 0xd0, 0xd5, 0x45, 0x50, 0x48, 0x30, 0x69, 0x8b, 0x17, 0x73, 0xef, 0xbd,
|
||||
0xf7, 0xea, 0xae, 0x7d, 0xb4, 0x7f, 0x3f, 0x07, 0x35, 0x1a, 0x51, 0xbe, 0xad, 0x5c, 0xbd, 0x1a,
|
||||
0xb9, 0x5c, 0x0e, 0x5c, 0x9d, 0x6b, 0x94, 0xec, 0x2d, 0xe1, 0xa0, 0x46, 0x43, 0xf5, 0x89, 0x13,
|
||||
0xb4, 0xb7, 0xb7, 0xeb, 0xc9, 0xba, 0xb9, 0xb9, 0xe1, 0x1f, 0x10, 0x40, 0x4c, 0x6c, 0x0c, 0xf1,
|
||||
0x09, 0x09, 0x0c, 0x1b, 0x36, 0x4c, 0x77, 0xed, 0xc7, 0x1f, 0x7f, 0x64, 0xd3, 0xc6, 0x8d, 0xa2,
|
||||
0xc6, 0x06, 0x70, 0x90, 0x39, 0xf0, 0xec, 0x5f, 0xb3, 0x18, 0xea, 0xe2, 0x22, 0x4a, 0xef, 0xdd,
|
||||
0xa2, 0x77, 0x38, 0x79, 0xf2, 0x0b, 0xbd, 0xbe, 0xe4, 0x94, 0x14, 0xc6, 0xdd, 0x77, 0x9f, 0x59,
|
||||
0xfa, 0x66, 0x07, 0x40, 0x5b, 0x5b, 0x1b, 0xe3, 0xc7, 0x99, 0x67, 0x54, 0x0c, 0x8b, 0xd2, 0x52,
|
||||
0x59, 0xf1, 0xdc, 0x73, 0xba, 0x76, 0x5c, 0x4c, 0x2c, 0x67, 0x6b, 0x6b, 0x45, 0xd9, 0x28, 0x28,
|
||||
0x2a, 0x24, 0x24, 0x34, 0x54, 0xd7, 0x5e, 0xff, 0xf2, 0x2b, 0xbc, 0xf9, 0xc6, 0x1b, 0xa2, 0x6c,
|
||||
0x9c, 0xa9, 0xad, 0xa1, 0xa1, 0xa1, 0x81, 0x7f, 0x6c, 0x78, 0x9d, 0xe2, 0xe2, 0x77, 0xcd, 0x5e,
|
||||
0x62, 0x0e, 0x19, 0x32, 0x84, 0xa5, 0x99, 0x99, 0xa4, 0xa5, 0xa7, 0xe9, 0x96, 0xac, 0x73, 0xe3,
|
||||
0x95, 0x54, 0x57, 0x9b, 0x2e, 0x64, 0x19, 0xf2, 0xf4, 0xb3, 0xcf, 0xf2, 0xd8, 0x13, 0x8f, 0x9b,
|
||||
0x2d, 0xdf, 0xdc, 0xdc, 0x4c, 0x44, 0x68, 0x28, 0x97, 0x5b, 0x2f, 0xeb, 0xfa, 0x14, 0x0a, 0x05,
|
||||
0x87, 0xca, 0x0f, 0x9b, 0x1d, 0x48, 0x03, 0x23, 0x8f, 0x59, 0x81, 0xea, 0x13, 0x27, 0x98, 0x3d,
|
||||
0xeb, 0x0f, 0x14, 0x15, 0x16, 0x8a, 0xaa, 0x2f, 0xb4, 0xb7, 0xb7, 0xb3, 0x76, 0xcd, 0x1a, 0x32,
|
||||
0x96, 0x3c, 0x45, 0xa7, 0x56, 0x0b, 0xc0, 0x53, 0xaa, 0xa5, 0x16, 0xf9, 0x90, 0x97, 0x9b, 0xa3,
|
||||
0x77, 0x33, 0x4d, 0x51, 0xb4, 0xb3, 0xd0, 0x48, 0x3e, 0xe5, 0xd1, 0x05, 0xa2, 0xb2, 0x88, 0x14,
|
||||
0x00, 0xd7, 0x78, 0xe2, 0xb1, 0xc7, 0x69, 0x68, 0x68, 0xb0, 0x58, 0x7f, 0x5f, 0x49, 0x09, 0x6b,
|
||||
0xb3, 0xaf, 0x56, 0x25, 0xa3, 0xa2, 0xa3, 0x09, 0x9c, 0x30, 0x41, 0xb4, 0x8d, 0xc6, 0x86, 0x46,
|
||||
0x76, 0x16, 0x14, 0x98, 0x25, 0xab, 0xd5, 0x6a, 0x29, 0xc8, 0xcf, 0xd7, 0xeb, 0x73, 0x72, 0x72,
|
||||
0x22, 0x29, 0x25, 0x45, 0xd4, 0x98, 0x66, 0x4f, 0x02, 0x9d, 0x9d, 0x9d, 0xd9, 0x71, 0x83, 0x73,
|
||||
0xab, 0x57, 0xae, 0xa4, 0xb6, 0xa6, 0x46, 0xd4, 0x60, 0x19, 0x2a, 0x15, 0x93, 0xa7, 0x4c, 0xd1,
|
||||
0xeb, 0xf3, 0xf1, 0xf5, 0x11, 0x65, 0xa3, 0xaf, 0x68, 0x6a, 0x6c, 0xec, 0xb5, 0x8d, 0x1d, 0xdb,
|
||||
0xb7, 0x91, 0xf8, 0x70, 0x22, 0xa3, 0xc7, 0x8c, 0x61, 0x69, 0xa6, 0x8a, 0xb4, 0x85, 0x8b, 0x44,
|
||||
0xdb, 0xc8, 0xcb, 0xcd, 0x21, 0x39, 0x25, 0x05, 0x17, 0xd7, 0x9e, 0x9f, 0xe2, 0x0f, 0xf7, 0xec,
|
||||
0xe1, 0xfc, 0xf9, 0xf3, 0x7a, 0x7d, 0x73, 0xe2, 0xe3, 0xf1, 0xf6, 0xf6, 0x16, 0x35, 0x9e, 0xd9,
|
||||
0x01, 0x20, 0x97, 0xcb, 0x09, 0x8f, 0x08, 0xd7, 0xb5, 0xdd, 0xdd, 0xdd, 0x45, 0x0d, 0x04, 0x30,
|
||||
0x76, 0xdc, 0x58, 0x3d, 0x1b, 0xf6, 0xc4, 0x5d, 0x77, 0xdd, 0x45, 0x70, 0x48, 0x08, 0x23, 0x47,
|
||||
0x8d, 0xa4, 0xab, 0xab, 0x8b, 0xe3, 0xc7, 0x8e, 0x73, 0xf4, 0xc8, 0x11, 0x51, 0x36, 0x3a, 0xb5,
|
||||
0x9d, 0x14, 0x15, 0x16, 0xf2, 0xdc, 0x0b, 0x2f, 0x30, 0x3d, 0x32, 0x92, 0x29, 0x53, 0xa7, 0x70,
|
||||
0xfc, 0xd8, 0x71, 0x51, 0x36, 0xae, 0x67, 0x01, 0x53, 0x73, 0x81, 0xfc, 0x6d, 0xdb, 0x8d, 0xfa,
|
||||
0x16, 0xa5, 0xa5, 0x8a, 0x1a, 0x0b, 0xa4, 0x57, 0x80, 0x8e, 0x98, 0x99, 0xb1, 0xac, 0x5b, 0xff,
|
||||
0x0a, 0x19, 0x2a, 0x15, 0x2a, 0xb5, 0x9a, 0x82, 0xa2, 0x42, 0xfe, 0xfc, 0xe4, 0x93, 0xa2, 0xed,
|
||||
0x94, 0x95, 0xfe, 0x56, 0xb7, 0x58, 0x92, 0x91, 0x61, 0x91, 0x2f, 0xa6, 0xe6, 0x02, 0x95, 0x15,
|
||||
0x15, 0x46, 0x93, 0xcc, 0xb0, 0xf0, 0x70, 0xb3, 0x67, 0xfe, 0x37, 0x22, 0x05, 0x40, 0x0f, 0x2c,
|
||||
0x4a, 0x4b, 0xd5, 0x2d, 0x0d, 0xcd, 0xe5, 0xfb, 0xba, 0x3a, 0x9a, 0x9a, 0xae, 0x7e, 0x26, 0x8f,
|
||||
0x98, 0x36, 0x8d, 0xa9, 0x41, 0x53, 0x45, 0x8f, 0x6b, 0x6a, 0x2e, 0xb0, 0xe5, 0xad, 0xb7, 0x8c,
|
||||
0xfa, 0x52, 0xd3, 0xd3, 0x44, 0x8f, 0x03, 0x52, 0x00, 0xf4, 0x88, 0x97, 0x97, 0x17, 0x0a, 0x85,
|
||||
0x42, 0xb4, 0x5e, 0x7d, 0x7d, 0xbd, 0xee, 0xe7, 0x25, 0x19, 0xd6, 0x5d, 0x11, 0x7c, 0x7b, 0xee,
|
||||
0x5b, 0xca, 0x0e, 0x94, 0xea, 0xf5, 0xf9, 0xf9, 0xf9, 0x11, 0x19, 0x15, 0x65, 0xd1, 0x38, 0x76,
|
||||
0x1b, 0x00, 0x81, 0x81, 0x81, 0x6c, 0xdc, 0xb4, 0x89, 0xdc, 0xcd, 0x9b, 0x89, 0x57, 0x2a, 0x01,
|
||||
0x58, 0x98, 0xba, 0x88, 0x3d, 0x25, 0x7b, 0xd9, 0xf5, 0xcf, 0x0f, 0x48, 0x4d, 0x4b, 0x43, 0x26,
|
||||
0xeb, 0xfb, 0xed, 0x8c, 0xb7, 0xdf, 0x7e, 0xbb, 0x68, 0x9d, 0xc6, 0x86, 0xdf, 0x26, 0x94, 0xe1,
|
||||
0x11, 0xe1, 0x4c, 0x0d, 0x0a, 0xb2, 0xc8, 0xc6, 0xcd, 0xb2, 0xc0, 0xb6, 0xad, 0x5b, 0xe9, 0xea,
|
||||
0xea, 0xd2, 0xeb, 0x4b, 0x7b, 0x6c, 0xb1, 0xc5, 0x95, 0x49, 0xbb, 0x2c, 0x05, 0xfb, 0xfa, 0xfa,
|
||||
0x52, 0x50, 0x54, 0xa8, 0x5b, 0xcf, 0xce, 0x88, 0x8d, 0x61, 0x7a, 0x64, 0x24, 0xf1, 0x09, 0x4a,
|
||||
0x9d, 0x4c, 0x60, 0x60, 0x20, 0x1d, 0x37, 0x59, 0x0a, 0x59, 0x1b, 0x4b, 0x82, 0xac, 0xab, 0x4b,
|
||||
0xbf, 0x8e, 0x90, 0xa1, 0x5a, 0xca, 0x82, 0xa4, 0x64, 0xd1, 0x76, 0x0c, 0x57, 0x04, 0x4d, 0x4d,
|
||||
0x4d, 0xec, 0xde, 0xb5, 0x4b, 0x4f, 0x46, 0xa1, 0x50, 0xa0, 0x54, 0x2a, 0x6f, 0xa6, 0x6e, 0x16,
|
||||
0x76, 0x99, 0x01, 0xe6, 0x28, 0x95, 0x0c, 0x75, 0x71, 0x61, 0x5d, 0x76, 0x36, 0xe1, 0x21, 0xa1,
|
||||
0xe4, 0x6f, 0xdf, 0x41, 0x7c, 0x82, 0x92, 0xa3, 0x47, 0x8e, 0x70, 0xbf, 0xbf, 0x3f, 0x33, 0x1f,
|
||||
0x98, 0x41, 0x4b, 0x4b, 0x0b, 0xf3, 0x93, 0x1e, 0xb1, 0xb5, 0xab, 0x66, 0x11, 0x1a, 0x16, 0x46,
|
||||
0x50, 0x70, 0xb0, 0x68, 0x3d, 0xc3, 0x2c, 0x50, 0x58, 0x50, 0x40, 0xdb, 0x65, 0xfd, 0xd7, 0x42,
|
||||
0xf2, 0x82, 0x14, 0xd1, 0xe5, 0xe3, 0x1b, 0xb1, 0xcb, 0x00, 0x18, 0x35, 0x6a, 0x14, 0x70, 0x75,
|
||||
0x69, 0xf6, 0xe8, 0xc2, 0x85, 0xb8, 0xb9, 0xbb, 0x01, 0x57, 0x9f, 0xc6, 0x27, 0x97, 0x3c, 0xc5,
|
||||
0xdc, 0xc4, 0x44, 0x5a, 0x2f, 0xb5, 0x72, 0xcf, 0xdd, 0x77, 0xdb, 0xd2, 0x4d, 0x51, 0xa8, 0x97,
|
||||
0x2f, 0xb7, 0x48, 0xef, 0xfa, 0x5c, 0x40, 0xab, 0xd5, 0x52, 0xb8, 0x73, 0xa7, 0xde, 0x35, 0x27,
|
||||
0x27, 0x27, 0x92, 0x17, 0x2c, 0xe8, 0x95, 0x5f, 0x76, 0xf9, 0x0a, 0x70, 0x76, 0x76, 0x06, 0x30,
|
||||
0xfa, 0xe5, 0x82, 0x43, 0x42, 0x08, 0x0e, 0x09, 0xd1, 0xb5, 0xaf, 0x97, 0x5e, 0x6f, 0x05, 0xa6,
|
||||
0x4c, 0x9d, 0x42, 0x70, 0x48, 0x08, 0x15, 0x47, 0x8f, 0x8a, 0xd2, 0xbb, 0x9e, 0x05, 0xbc, 0x86,
|
||||
0x7b, 0xf1, 0xd3, 0xf9, 0x9f, 0xf4, 0xae, 0x59, 0x52, 0xf8, 0x31, 0xc4, 0x2e, 0x03, 0xa0, 0x20,
|
||||
0x3f, 0x9f, 0xd2, 0xd2, 0x03, 0x26, 0xe5, 0x04, 0x41, 0xe8, 0x07, 0x6f, 0xac, 0x87, 0x4a, 0x9d,
|
||||
0xc9, 0x23, 0x0f, 0xcf, 0x13, 0xad, 0xf7, 0x56, 0x5e, 0x1e, 0xc3, 0xef, 0x18, 0x6e, 0xd4, 0x6f,
|
||||
0x49, 0xe1, 0xc7, 0x10, 0xbb, 0x0c, 0x80, 0xea, 0xea, 0xea, 0x9b, 0x7e, 0x4d, 0xf3, 0xf0, 0xf0,
|
||||
0x20, 0x2a, 0x3a, 0x9a, 0xdb, 0x86, 0xdc, 0x46, 0xd5, 0x67, 0x55, 0xa2, 0x4b, 0xd1, 0xb6, 0x66,
|
||||
0x6a, 0x50, 0x10, 0xa1, 0x61, 0x61, 0x1c, 0x29, 0x2f, 0x17, 0xa5, 0x57, 0x5f, 0x5f, 0xaf, 0xb7,
|
||||
0xb4, 0x04, 0xcb, 0x0b, 0x3f, 0x86, 0xd8, 0xe5, 0x1c, 0xe0, 0x99, 0xac, 0x2c, 0x6a, 0xbf, 0x3d,
|
||||
0x47, 0x4c, 0x6c, 0xac, 0xae, 0x2f, 0x6e, 0xd6, 0x2c, 0x0e, 0x68, 0xca, 0x58, 0xbf, 0xe1, 0x35,
|
||||
0x5e, 0xca, 0xce, 0xe6, 0xc3, 0x92, 0xbd, 0x24, 0xce, 0x13, 0xff, 0x34, 0xd9, 0x9a, 0xcc, 0x65,
|
||||
0x6a, 0xab, 0xd8, 0xb1, 0xb4, 0xf0, 0x63, 0x88, 0x5d, 0x06, 0xc0, 0xdd, 0xf7, 0x5c, 0x9d, 0xdc,
|
||||
0xd5, 0xd6, 0xd4, 0x20, 0x93, 0xc9, 0xc8, 0x50, 0xa9, 0xd8, 0xf8, 0xe6, 0x26, 0x14, 0x9e, 0x9e,
|
||||
0x1c, 0xd4, 0x68, 0x78, 0x79, 0xed, 0x5a, 0xae, 0x5c, 0xb9, 0xc2, 0x5f, 0x9e, 0x7e, 0xda, 0xc6,
|
||||
0x9e, 0x8a, 0x67, 0xd2, 0xe4, 0xc9, 0xbd, 0xfe, 0x1e, 0xd2, 0x9b, 0xc2, 0x8f, 0x21, 0x76, 0xf9,
|
||||
0x0a, 0xa8, 0xad, 0xa9, 0x61, 0x66, 0x5c, 0x1c, 0x1b, 0x73, 0xde, 0xa4, 0x53, 0xab, 0xc5, 0x3f,
|
||||
0x20, 0x00, 0xad, 0x56, 0x4b, 0xf6, 0x4b, 0x2f, 0xb1, 0x7d, 0xeb, 0x36, 0x00, 0x66, 0xc4, 0xc4,
|
||||
0x30, 0x61, 0xe2, 0x44, 0x9c, 0x9c, 0x9c, 0x6c, 0xec, 0xad, 0x78, 0x54, 0x6a, 0x75, 0xaf, 0x76,
|
||||
0x36, 0xa7, 0x2e, 0x4e, 0xb7, 0xda, 0x96, 0x34, 0xbb, 0xcc, 0x00, 0x9b, 0x73, 0xf3, 0xa8, 0xac,
|
||||
0xa8, 0x60, 0xec, 0xd8, 0xb1, 0xf8, 0x07, 0x04, 0xf0, 0x7d, 0x5d, 0x1d, 0x49, 0xf3, 0xe6, 0xeb,
|
||||
0x6e, 0xbe, 0xe7, 0x30, 0x4f, 0xc6, 0x8d, 0x1b, 0x47, 0xcd, 0xd7, 0x35, 0x74, 0x74, 0x74, 0xd8,
|
||||
0xd8, 0x5b, 0xf1, 0x4c, 0x9c, 0x34, 0x89, 0x88, 0x69, 0xd3, 0x2c, 0xd2, 0x55, 0x28, 0x14, 0x24,
|
||||
0x24, 0x24, 0x58, 0xcd, 0x17, 0x8b, 0x33, 0x80, 0x25, 0x25, 0x52, 0x73, 0x69, 0x69, 0x69, 0x21,
|
||||
0x69, 0xde, 0x7c, 0x7c, 0x7c, 0x7c, 0x70, 0x75, 0x73, 0xe3, 0xdc, 0x37, 0xdf, 0xd0, 0xd9, 0xf9,
|
||||
0x5b, 0x75, 0xad, 0xa5, 0xb9, 0x85, 0x88, 0xd0, 0x30, 0xae, 0xdc, 0x82, 0x37, 0xff, 0x3a, 0x2a,
|
||||
0x75, 0x26, 0x9f, 0x1e, 0x3a, 0x24, 0x5a, 0xaf, 0xb7, 0x85, 0x1f, 0x43, 0x2c, 0x0e, 0x80, 0x61,
|
||||
0x5e, 0xc3, 0x4c, 0x0b, 0x19, 0xf0, 0xeb, 0xaf, 0xbf, 0x9a, 0x25, 0xf7, 0xc7, 0xd9, 0x0f, 0xe2,
|
||||
0xef, 0x1f, 0xd0, 0xed, 0xf5, 0x96, 0xe6, 0x66, 0xaa, 0xaa, 0xaa, 0xa8, 0xac, 0xa8, 0x10, 0xed,
|
||||
0x83, 0xbd, 0x30, 0x61, 0xe2, 0x44, 0xa6, 0x47, 0x46, 0xf2, 0xc9, 0xc1, 0x83, 0x66, 0xeb, 0x38,
|
||||
0x3a, 0x3a, 0x92, 0x94, 0x2c, 0xbe, 0xa4, 0xdc, 0xa3, 0x4d, 0x4b, 0x15, 0xc7, 0x8c, 0xf9, 0xbd,
|
||||
0x68, 0x1d, 0xc3, 0x42, 0x46, 0x77, 0x44, 0x47, 0x3f, 0x40, 0xc2, 0xdc, 0x87, 0x4c, 0xca, 0xe5,
|
||||
0xe5, 0xe4, 0xb2, 0x2e, 0x3b, 0x5b, 0xb4, 0x1f, 0xf6, 0x82, 0x7a, 0xf9, 0x32, 0x0e, 0x7d, 0xf2,
|
||||
0x89, 0xd9, 0xf5, 0x8c, 0x39, 0xf1, 0xf1, 0x66, 0x9d, 0xae, 0x16, 0x83, 0xc5, 0x01, 0x10, 0x33,
|
||||
0x33, 0x96, 0xb5, 0x6b, 0xd6, 0x88, 0xd2, 0x29, 0x7e, 0xe7, 0x1d, 0x62, 0x66, 0xc6, 0xe2, 0xe7,
|
||||
0xe7, 0xd7, 0xa3, 0x5c, 0x5e, 0x6e, 0x2e, 0x1f, 0xbc, 0xbf, 0xbb, 0xdb, 0xeb, 0x1e, 0x0a, 0x05,
|
||||
0xea, 0x65, 0xcb, 0x49, 0x5f, 0x9c, 0xce, 0xeb, 0xaf, 0xbd, 0x26, 0xca, 0x07, 0x7b, 0x22, 0x60,
|
||||
0xfc, 0x78, 0x22, 0xa3, 0xa2, 0xd0, 0x94, 0x95, 0x99, 0x16, 0xc6, 0x7a, 0x4b, 0xbf, 0x1b, 0xb1,
|
||||
0x38, 0x00, 0xfc, 0xfc, 0xfc, 0x88, 0x9b, 0x35, 0x8b, 0x7d, 0x25, 0x25, 0x66, 0xeb, 0x9c, 0x3b,
|
||||
0x77, 0x8e, 0xb8, 0x19, 0x31, 0x78, 0x8f, 0xf0, 0xc6, 0xd5, 0xc5, 0x95, 0xfa, 0x86, 0x06, 0x94,
|
||||
0x09, 0x4a, 0xbd, 0x6d, 0xe1, 0x00, 0x0d, 0xf5, 0xf5, 0x46, 0x7b, 0xf1, 0x6f, 0x64, 0xc8, 0x85,
|
||||
0x5f, 0x68, 0x6e, 0x6e, 0xc6, 0x41, 0x2e, 0xc7, 0xb1, 0x9b, 0xd3, 0xc3, 0xb7, 0x0a, 0x2a, 0x75,
|
||||
0x26, 0x07, 0x35, 0x1a, 0x93, 0x59, 0xc0, 0x5a, 0x85, 0x1f, 0x43, 0x7a, 0xf5, 0xd7, 0x7b, 0x7e,
|
||||
0xe5, 0x0b, 0x9c, 0xfa, 0xf2, 0x4b, 0x7e, 0xf8, 0xe1, 0x07, 0xb3, 0x75, 0xba, 0xba, 0xba, 0x4c,
|
||||
0xbe, 0x0a, 0x9e, 0xc9, 0xca, 0x32, 0xeb, 0x15, 0xb0, 0xf7, 0xc3, 0xff, 0xd0, 0xda, 0xda, 0x6a,
|
||||
0xf6, 0xd8, 0xf6, 0x48, 0xc0, 0xf8, 0xf1, 0x44, 0x45, 0x47, 0x53, 0x56, 0x5a, 0xda, 0xa3, 0x5c,
|
||||
0x5f, 0x3c, 0xfd, 0xd0, 0xcb, 0x00, 0xf0, 0x1e, 0x31, 0x82, 0xe2, 0xdd, 0xbb, 0x58, 0x9e, 0xa9,
|
||||
0xa6, 0xfc, 0xb0, 0xf5, 0x4e, 0xec, 0xd6, 0xd4, 0x7c, 0xdd, 0xe3, 0x3a, 0xf9, 0xe2, 0xc5, 0x5f,
|
||||
0xf8, 0xec, 0xd8, 0x71, 0xde, 0x2b, 0x2e, 0xb6, 0xda, 0x98, 0xb6, 0x44, 0xa5, 0xce, 0x44, 0x53,
|
||||
0x56, 0xd6, 0x6d, 0x16, 0xb0, 0x66, 0xe1, 0xc7, 0x90, 0x5e, 0xe7, 0x4f, 0x6f, 0x6f, 0x6f, 0xf2,
|
||||
0x77, 0x16, 0x70, 0xac, 0xb2, 0x92, 0x3d, 0xff, 0xfa, 0x37, 0xe5, 0x87, 0x0f, 0x53, 0xf7, 0x7d,
|
||||
0x5d, 0x8f, 0x87, 0x2b, 0xe4, 0x72, 0x39, 0xc3, 0xef, 0xb8, 0x03, 0x1f, 0x1f, 0x1f, 0x46, 0x8f,
|
||||
0x1e, 0x63, 0x74, 0x3d, 0x2f, 0x27, 0x97, 0xbc, 0x9c, 0xdc, 0xde, 0xba, 0x76, 0xcb, 0xe0, 0x1f,
|
||||
0x10, 0x40, 0xf4, 0x8c, 0x07, 0x28, 0xfd, 0xf8, 0xe6, 0x1f, 0xc0, 0xac, 0x59, 0xf8, 0x31, 0xc4,
|
||||
0xe2, 0x7f, 0x11, 0xd3, 0x13, 0x9d, 0x5a, 0x2d, 0x3f, 0x5f, 0xb8, 0x40, 0x73, 0x73, 0x33, 0xda,
|
||||
0x6b, 0x6b, 0xf5, 0xa1, 0x2e, 0x2e, 0x38, 0x3b, 0x39, 0x31, 0xd4, 0xc5, 0x05, 0x4f, 0x4f, 0x4f,
|
||||
0xd1, 0x9b, 0x2d, 0x07, 0x3a, 0xff, 0x3d, 0x75, 0x8a, 0xf8, 0xd9, 0x7f, 0x32, 0xca, 0x02, 0x62,
|
||||
0x8f, 0x7a, 0x89, 0xa5, 0x4f, 0x66, 0x50, 0x72, 0x47, 0x47, 0x7c, 0x7d, 0x7d, 0xf1, 0xf5, 0xf5,
|
||||
0xed, 0x0b, 0xf3, 0x03, 0x92, 0xfb, 0xfc, 0xfd, 0x09, 0x09, 0x0d, 0x35, 0xfa, 0x52, 0xf8, 0x48,
|
||||
0x72, 0x72, 0x9f, 0xdd, 0x7c, 0xb0, 0xd3, 0x52, 0xf0, 0x60, 0xa4, 0xad, 0xad, 0x8d, 0xd3, 0xa7,
|
||||
0x4f, 0xeb, 0xf5, 0x39, 0x3a, 0x3a, 0x92, 0x2c, 0xf2, 0xa8, 0x97, 0x58, 0xa4, 0x00, 0xb0, 0x13,
|
||||
0x76, 0xbd, 0xf7, 0x9e, 0xd1, 0xf1, 0xb4, 0x39, 0xf1, 0xf1, 0xdc, 0xe9, 0x63, 0xdd, 0xc2, 0x8f,
|
||||
0x21, 0x52, 0x00, 0xd8, 0x01, 0x82, 0x20, 0xf0, 0xf6, 0x0e, 0xe3, 0xdd, 0xcd, 0x7d, 0xb5, 0xf4,
|
||||
0xbb, 0x11, 0x29, 0x00, 0xec, 0x80, 0xb2, 0x03, 0xa5, 0x9c, 0x3d, 0x7b, 0x56, 0xaf, 0x2f, 0x34,
|
||||
0x2c, 0xac, 0x4f, 0x0a, 0x3f, 0x86, 0x48, 0x01, 0x60, 0x07, 0x6c, 0xdd, 0xb2, 0xc5, 0xa8, 0x2f,
|
||||
0x35, 0x3d, 0xbd, 0x5f, 0xc6, 0x96, 0x02, 0xc0, 0xc6, 0x7c, 0x75, 0xe6, 0x2b, 0xa3, 0x9d, 0xc2,
|
||||
0x7e, 0x7e, 0x7e, 0x44, 0x45, 0x47, 0xf5, 0xcb, 0xf8, 0x52, 0x00, 0xd8, 0x98, 0x2d, 0x9b, 0x37,
|
||||
0x1b, 0xad, 0xfd, 0xfb, 0xb2, 0xf0, 0x63, 0x48, 0x9f, 0x14, 0x82, 0x24, 0xcc, 0xa3, 0xbe, 0xbe,
|
||||
0x9e, 0xe9, 0x61, 0xe1, 0x7a, 0xfb, 0x24, 0xfa, 0xba, 0xf0, 0x63, 0x88, 0x94, 0x01, 0x6c, 0xc8,
|
||||
0xdb, 0x3b, 0x76, 0x18, 0x6d, 0x92, 0x49, 0x4a, 0xb1, 0xee, 0x8e, 0x1f, 0x53, 0x48, 0x19, 0xc0,
|
||||
0x86, 0xb4, 0xb6, 0xb6, 0xa2, 0x35, 0x38, 0xdd, 0xe4, 0xea, 0xea, 0xda, 0xaf, 0x9f, 0xb8, 0xa5,
|
||||
0x00, 0x18, 0xe4, 0x38, 0x00, 0xb7, 0xd6, 0xf9, 0x2a, 0x09, 0xab, 0xe2, 0x00, 0xf4, 0xfe, 0xdf,
|
||||
0x63, 0x49, 0xdc, 0xaa, 0x34, 0x3a, 0x00, 0xe2, 0x0e, 0xaa, 0x49, 0x0c, 0x24, 0xca, 0x65, 0x82,
|
||||
0x20, 0x44, 0x03, 0x07, 0x90, 0xe6, 0x01, 0x83, 0x0d, 0x01, 0x88, 0x75, 0x90, 0xc9, 0x64, 0x65,
|
||||
0xc0, 0x8b, 0xb6, 0xf6, 0x46, 0xa2, 0xdf, 0xf9, 0x9b, 0x4c, 0x26, 0x3b, 0xa0, 0x7b, 0xea, 0x05,
|
||||
0x41, 0x98, 0x0b, 0xa8, 0x81, 0x89, 0xc0, 0x50, 0x9b, 0xb9, 0x25, 0xd1, 0x97, 0xb4, 0x03, 0x9f,
|
||||
0x03, 0xeb, 0x65, 0x32, 0xd9, 0x2e, 0x80, 0xff, 0x03, 0xff, 0x08, 0x81, 0xdd, 0xa8, 0xcb, 0xf5,
|
||||
0x99, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
|
||||
};
|
||||
139
examples/device/mtp/src/tusb_config.h
Normal file
139
examples/device/mtp/src/tusb_config.h
Normal file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2025 Ennebi Elettronica (https://ennebielettronica.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TUSB_CONFIG_H_
|
||||
#define _TUSB_CONFIG_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Board Specific Configuration
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// RHPort number used for device can be defined by board.mk, default to port 0
|
||||
#ifndef BOARD_TUD_RHPORT
|
||||
#define BOARD_TUD_RHPORT 0
|
||||
#endif
|
||||
|
||||
// RHPort max operational speed can defined by board.mk
|
||||
#ifndef BOARD_TUD_MAX_SPEED
|
||||
#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// COMMON CONFIGURATION
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// defined by compiler flags for flexibility
|
||||
#ifndef CFG_TUSB_MCU
|
||||
#error CFG_TUSB_MCU must be defined
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUSB_OS
|
||||
#define CFG_TUSB_OS OPT_OS_NONE
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUSB_DEBUG
|
||||
#define CFG_TUSB_DEBUG 0
|
||||
#endif
|
||||
|
||||
// Enable Device stack
|
||||
#define CFG_TUD_ENABLED 1
|
||||
|
||||
// Default is max speed that hardware controller could support with on-chip PHY
|
||||
#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
|
||||
|
||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||
* into those specific section.
|
||||
* e.g
|
||||
* - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
|
||||
* - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
|
||||
*/
|
||||
#ifndef CFG_TUSB_MEM_SECTION
|
||||
#define CFG_TUSB_MEM_SECTION
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUSB_MEM_ALIGN
|
||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// DEVICE CONFIGURATION
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
#ifndef CFG_TUD_ENDPOINT0_SIZE
|
||||
#define CFG_TUD_ENDPOINT0_SIZE 64
|
||||
#endif
|
||||
|
||||
//------------- CLASS -------------//
|
||||
#define CFG_TUD_MTP 1
|
||||
#define CFG_TUD_MTP_EP_BUFSIZE 512
|
||||
#define CFG_TUD_MTP_EP_CONTROL_BUFSIZE 16 // should be enough to hold data in MTP control request
|
||||
|
||||
//------------- MTP device info -------------//
|
||||
#define CFG_TUD_MTP_DEVICEINFO_EXTENSIONS "microsoft.com: 1.0; "
|
||||
#define CFG_TUD_MTP_DEVICEINFO_SUPPORTED_OPERATIONS \
|
||||
MTP_OP_GET_DEVICE_INFO, \
|
||||
MTP_OP_OPEN_SESSION, \
|
||||
MTP_OP_CLOSE_SESSION, \
|
||||
MTP_OP_GET_STORAGE_IDS, \
|
||||
MTP_OP_GET_STORAGE_INFO, \
|
||||
MTP_OP_GET_OBJECT_HANDLES, \
|
||||
MTP_OP_GET_OBJECT_INFO, \
|
||||
MTP_OP_GET_OBJECT, \
|
||||
MTP_OP_DELETE_OBJECT, \
|
||||
MTP_OP_SEND_OBJECT_INFO, \
|
||||
MTP_OP_SEND_OBJECT, \
|
||||
MTP_OP_RESET_DEVICE, \
|
||||
MTP_OP_GET_DEVICE_PROP_DESC, \
|
||||
MTP_OP_GET_DEVICE_PROP_VALUE, \
|
||||
MTP_OP_SET_DEVICE_PROP_VALUE
|
||||
|
||||
#define CFG_TUD_MTP_DEVICEINFO_SUPPORTED_EVENTS \
|
||||
MTP_EVENT_OBJECT_ADDED
|
||||
|
||||
#define CFG_TUD_MTP_DEVICEINFO_SUPPORTED_DEVICE_PROPERTIES \
|
||||
MTP_DEV_PROP_DEVICE_FRIENDLY_NAME
|
||||
|
||||
#define CFG_TUD_MTP_DEVICEINFO_CAPTURE_FORMATS \
|
||||
MTP_OBJ_FORMAT_UNDEFINED, \
|
||||
MTP_OBJ_FORMAT_ASSOCIATION, \
|
||||
MTP_OBJ_FORMAT_TEXT, \
|
||||
MTP_OBJ_FORMAT_PNG
|
||||
|
||||
#define CFG_TUD_MTP_DEVICEINFO_PLAYBACK_FORMATS \
|
||||
MTP_OBJ_FORMAT_UNDEFINED, \
|
||||
MTP_OBJ_FORMAT_ASSOCIATION, \
|
||||
MTP_OBJ_FORMAT_TEXT, \
|
||||
MTP_OBJ_FORMAT_PNG
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_CONFIG_H_ */
|
||||
255
examples/device/mtp/src/usb_descriptors.c
Normal file
255
examples/device/mtp/src/usb_descriptors.c
Normal file
@ -0,0 +1,255 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "tusb.h"
|
||||
|
||||
/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
|
||||
* Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC.
|
||||
*
|
||||
* Auto ProductID layout's Bitmap:
|
||||
* [MSB] MTP | VENDOR | MIDI | HID | MSC | CDC [LSB]
|
||||
*/
|
||||
#define _PID_MAP(itf, n) ( (CFG_TUD_##itf) << (n) )
|
||||
#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
|
||||
_PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) | _PID_MAP(MTP, 5))
|
||||
|
||||
#define USB_VID 0xCafe
|
||||
#define USB_BCD 0x0200
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Device Descriptors
|
||||
//--------------------------------------------------------------------+
|
||||
tusb_desc_device_t const desc_device =
|
||||
{
|
||||
.bLength = sizeof(tusb_desc_device_t),
|
||||
.bDescriptorType = TUSB_DESC_DEVICE,
|
||||
.bcdUSB = USB_BCD,
|
||||
.bDeviceClass = TUSB_CLASS_UNSPECIFIED,
|
||||
.bDeviceSubClass = 0x00,
|
||||
.bDeviceProtocol = 0x00,
|
||||
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
|
||||
|
||||
.idVendor = USB_VID,
|
||||
.idProduct = USB_PID,
|
||||
.bcdDevice = 0x0100,
|
||||
|
||||
.iManufacturer = 0x01,
|
||||
.iProduct = 0x02,
|
||||
.iSerialNumber = 0x03,
|
||||
|
||||
.bNumConfigurations = 0x01
|
||||
};
|
||||
|
||||
// Invoked when received GET DEVICE DESCRIPTOR
|
||||
// Application return pointer to descriptor
|
||||
uint8_t const *tud_descriptor_device_cb(void)
|
||||
{
|
||||
return (uint8_t const *) &desc_device;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Configuration Descriptor
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
enum
|
||||
{
|
||||
ITF_NUM_MTP = 0,
|
||||
ITF_NUM_TOTAL
|
||||
};
|
||||
|
||||
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
|
||||
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
|
||||
// 0 control, 1 In, 2 Bulk, 3 Iso, 4 In, 5 Bulk etc ...
|
||||
#define EPNUM_MTP_EVT 0x81
|
||||
#define EPNUM_MTP_OUT 0x02
|
||||
#define EPNUM_MTP_IN 0x82
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_CXD56
|
||||
// CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
|
||||
// 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
|
||||
#define EPNUM_MTP_EVT 0x83
|
||||
#define EPNUM_MTP_OUT 0x02
|
||||
#define EPNUM_MTP_IN 0x81
|
||||
|
||||
#elif defined(TUD_ENDPOINT_ONE_DIRECTION_ONLY)
|
||||
// MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
|
||||
// e.g EP1 OUT & EP1 IN cannot exist together
|
||||
#define EPNUM_MTP_EVT 0x81
|
||||
#define EPNUM_MTP_OUT 0x03
|
||||
#define EPNUM_MTP_IN 0x82
|
||||
|
||||
#else
|
||||
#define EPNUM_MTP_EVT 0x81
|
||||
#define EPNUM_MTP_OUT 0x02
|
||||
#define EPNUM_MTP_IN 0x82
|
||||
#endif
|
||||
|
||||
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_MTP_DESC_LEN)
|
||||
|
||||
// full speed configuration
|
||||
const uint8_t desc_fs_configuration[] = {
|
||||
// Config number, interface count, string index, total length, attribute, power in mA
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
|
||||
// Interface number, string index, EP event, EP event size, EP event polling, EP Out & EP In address, EP size
|
||||
TUD_MTP_DESCRIPTOR(ITF_NUM_MTP, 4, EPNUM_MTP_EVT, 64, 1, EPNUM_MTP_OUT, EPNUM_MTP_IN, 64),
|
||||
};
|
||||
|
||||
#if TUD_OPT_HIGH_SPEED
|
||||
// Per USB specs: high speed capable device must report device_qualifier and other_speed_configuration
|
||||
|
||||
// high speed configuration
|
||||
uint8_t const desc_hs_configuration[] = {
|
||||
// Config number, interface count, string index, total length, attribute, power in mA
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
|
||||
// Interface number, string index, EP event, EP event size, EP event polling, EP Out & EP In address, EP size
|
||||
TUD_MTP_DESCRIPTOR(ITF_NUM_MTP, 4, EPNUM_MTP_EVT, 64, 1, EPNUM_MTP_OUT, EPNUM_MTP_IN, 512),
|
||||
};
|
||||
|
||||
// other speed configuration
|
||||
uint8_t desc_other_speed_config[CONFIG_TOTAL_LEN];
|
||||
|
||||
// device qualifier is mostly similar to device descriptor since we don't change configuration based on speed
|
||||
tusb_desc_device_qualifier_t const desc_device_qualifier = {
|
||||
.bLength = sizeof(tusb_desc_device_qualifier_t),
|
||||
.bDescriptorType = TUSB_DESC_DEVICE_QUALIFIER,
|
||||
.bcdUSB = USB_BCD,
|
||||
|
||||
.bDeviceClass = TUSB_CLASS_MISC,
|
||||
.bDeviceSubClass = MISC_SUBCLASS_COMMON,
|
||||
.bDeviceProtocol = MISC_PROTOCOL_IAD,
|
||||
|
||||
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
|
||||
.bNumConfigurations = 0x01,
|
||||
.bReserved = 0x00
|
||||
};
|
||||
|
||||
// Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete.
|
||||
// device_qualifier descriptor describes information about a high-speed capable device that would
|
||||
// change if the device were operating at the other speed. If not highspeed capable stall this request.
|
||||
uint8_t const *tud_descriptor_device_qualifier_cb(void) {
|
||||
return (uint8_t const *) &desc_device_qualifier;
|
||||
}
|
||||
|
||||
// Invoked when received GET OTHER SEED CONFIGURATION DESCRIPTOR request
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||
// Configuration descriptor in the other speed e.g if high speed then this is for full speed and vice versa
|
||||
uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) {
|
||||
(void) index; // for multiple configurations
|
||||
|
||||
// if link speed is high return fullspeed config, and vice versa
|
||||
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
|
||||
memcpy(desc_other_speed_config,
|
||||
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
|
||||
CONFIG_TOTAL_LEN);
|
||||
desc_other_speed_config[1] = TUSB_DESC_OTHER_SPEED_CONFIG;
|
||||
return desc_other_speed_config;
|
||||
}
|
||||
|
||||
#endif // highspeed
|
||||
|
||||
// Invoked when received GET CONFIGURATION DESCRIPTOR
|
||||
// Application return pointer to descriptor
|
||||
// Descriptor contents must exist long enough for transfer to complete
|
||||
const uint8_t*tud_descriptor_configuration_cb(uint8_t index) {
|
||||
(void) index; // for multiple configurations
|
||||
#if TUD_OPT_HIGH_SPEED
|
||||
// Although we are highspeed, host may be fullspeed.
|
||||
return (tud_speed_get() == TUSB_SPEED_HIGH) ? desc_hs_configuration : desc_fs_configuration;
|
||||
#else
|
||||
return desc_fs_configuration;
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// String Descriptors
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// String Descriptor Index
|
||||
enum {
|
||||
STRID_LANGID = 0,
|
||||
STRID_MANUFACTURER,
|
||||
STRID_PRODUCT,
|
||||
STRID_SERIAL,
|
||||
STRID_MTP,
|
||||
};
|
||||
|
||||
// array of pointer to string descriptors
|
||||
char const *string_desc_arr[] =
|
||||
{
|
||||
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
|
||||
"TinyUsb", // 1: Manufacturer
|
||||
"TinyUsb Device", // 2: Product
|
||||
NULL, // 3: Serials will use unique ID if possible
|
||||
"TinyUSB MTP", // 4: MTP Interface
|
||||
};
|
||||
|
||||
static uint16_t _desc_str[32 + 1];
|
||||
|
||||
// Invoked when received GET STRING DESCRIPTOR request
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||
uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
|
||||
(void) langid;
|
||||
size_t chr_count;
|
||||
|
||||
switch ( index ) {
|
||||
case STRID_LANGID:
|
||||
memcpy(&_desc_str[1], string_desc_arr[0], 2);
|
||||
chr_count = 1;
|
||||
break;
|
||||
|
||||
case STRID_SERIAL:
|
||||
chr_count = board_usb_get_serial(_desc_str + 1, 32);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
|
||||
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors
|
||||
|
||||
if ( !(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *str = string_desc_arr[index];
|
||||
// Cap at max char
|
||||
chr_count = strlen(str);
|
||||
const size_t max_count = sizeof(_desc_str) / sizeof(_desc_str[0]) - 1; // -1 for string type
|
||||
if ( chr_count > max_count ) {
|
||||
chr_count = max_count;
|
||||
}
|
||||
|
||||
// Convert ASCII string into UTF-16
|
||||
for ( size_t i = 0; i < chr_count; i++ ) {
|
||||
_desc_str[1 + i] = str[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// first byte is length (including header), second byte is string type
|
||||
_desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8) | (2 * chr_count + 2));
|
||||
|
||||
return _desc_str;
|
||||
}
|
||||
@ -175,7 +175,7 @@ uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index) {
|
||||
(void) index; // for multiple configurations
|
||||
|
||||
// if link speed is high return fullspeed config, and vice versa
|
||||
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
|
||||
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
|
||||
memcpy(desc_other_speed_config,
|
||||
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
|
||||
CONFIG_TOTAL_LEN);
|
||||
|
||||
@ -175,7 +175,7 @@ uint8_t const* tud_descriptor_other_speed_configuration_cb(uint8_t index) {
|
||||
(void) index; // for multiple configurations
|
||||
|
||||
// if link speed is high return fullspeed config, and vice versa
|
||||
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
|
||||
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
|
||||
memcpy(desc_other_speed_config,
|
||||
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration : desc_hs_configuration,
|
||||
CONFIG_TOTAL_LEN);
|
||||
|
||||
6
examples/host/midi_rx/CMakePresets.json
Normal file
6
examples/host/midi_rx/CMakePresets.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": 6,
|
||||
"include": [
|
||||
"../../../hw/bsp/BoardPresets.json"
|
||||
]
|
||||
}
|
||||
@ -12,31 +12,33 @@
|
||||
"BOARD": "${presetName}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "default single",
|
||||
"hidden": true,
|
||||
"description": "Configure preset for the ${presetName} board",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||
"cacheVariables": {
|
||||
"BOARD": "${presetName}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "adafruit_clue",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_esp32_v2",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_esp32c6",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_esp32s2",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_esp32s3",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_rp2040_usb_host",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_fruit_jam",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_magtag_29gray",
|
||||
@ -44,7 +46,11 @@
|
||||
},
|
||||
{
|
||||
"name": "adafruit_metro_esp32s2",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_metro_rp2350",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "apard32690",
|
||||
@ -54,6 +60,50 @@
|
||||
"name": "arduino_nano33_ble",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at32f403a_weact_blackpill",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f402",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f403a",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f405",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f407",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f413",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f415",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f423",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f425",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f435",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f437",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "atsamd21_xpro",
|
||||
"inherits": "default"
|
||||
@ -140,39 +190,39 @@
|
||||
},
|
||||
{
|
||||
"name": "espressif_addax_1",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "espressif_c3_devkitc",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "espressif_c6_devkitc",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "espressif_kaluga_1",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "espressif_p4_function_ev",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "espressif_s2_devkitc",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "espressif_s3_devkitc",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "espressif_s3_devkitm",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "espressif_saola_1",
|
||||
"inherits": "default single"
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "f1c100s",
|
||||
@ -226,6 +276,10 @@
|
||||
"name": "frdm_mcxa153",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "frdm_mcxa156",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "frdm_mcxn947",
|
||||
"inherits": "default"
|
||||
@ -410,6 +464,10 @@
|
||||
"name": "nanoch32v203",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "nanoch32v305",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "pca10056",
|
||||
"inherits": "default"
|
||||
@ -482,6 +540,10 @@
|
||||
"name": "raspberry_pi_pico2",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "raspberry_pi_pico_w",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "raspberrypi_cm4",
|
||||
"inherits": "default"
|
||||
@ -694,6 +756,18 @@
|
||||
"name": "stm32l4r5nucleo",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "stm32n6570dk",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "stm32n657nucleo",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "stm32u083cdk",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "stm32u545nucleo",
|
||||
"inherits": "default"
|
||||
@ -714,6 +788,10 @@
|
||||
"name": "stm32wb55nucleo",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "stm32wba_nucleo",
|
||||
"inherits": "default"
|
||||
},
|
||||
{
|
||||
"name": "teensy_35",
|
||||
"inherits": "default"
|
||||
@ -758,6 +836,11 @@
|
||||
"description": "Build preset for the adafruit_feather_esp32_v2 board",
|
||||
"configurePreset": "adafruit_feather_esp32_v2"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_esp32c6",
|
||||
"description": "Build preset for the adafruit_feather_esp32c6 board",
|
||||
"configurePreset": "adafruit_feather_esp32c6"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_esp32s2",
|
||||
"description": "Build preset for the adafruit_feather_esp32s2 board",
|
||||
@ -768,6 +851,16 @@
|
||||
"description": "Build preset for the adafruit_feather_esp32s3 board",
|
||||
"configurePreset": "adafruit_feather_esp32s3"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_rp2040_usb_host",
|
||||
"description": "Build preset for the adafruit_feather_rp2040_usb_host board",
|
||||
"configurePreset": "adafruit_feather_rp2040_usb_host"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_fruit_jam",
|
||||
"description": "Build preset for the adafruit_fruit_jam board",
|
||||
"configurePreset": "adafruit_fruit_jam"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_magtag_29gray",
|
||||
"description": "Build preset for the adafruit_magtag_29gray board",
|
||||
@ -778,6 +871,11 @@
|
||||
"description": "Build preset for the adafruit_metro_esp32s2 board",
|
||||
"configurePreset": "adafruit_metro_esp32s2"
|
||||
},
|
||||
{
|
||||
"name": "adafruit_metro_rp2350",
|
||||
"description": "Build preset for the adafruit_metro_rp2350 board",
|
||||
"configurePreset": "adafruit_metro_rp2350"
|
||||
},
|
||||
{
|
||||
"name": "apard32690",
|
||||
"description": "Build preset for the apard32690 board",
|
||||
@ -788,6 +886,61 @@
|
||||
"description": "Build preset for the arduino_nano33_ble board",
|
||||
"configurePreset": "arduino_nano33_ble"
|
||||
},
|
||||
{
|
||||
"name": "at32f403a_weact_blackpill",
|
||||
"description": "Build preset for the at32f403a_weact_blackpill board",
|
||||
"configurePreset": "at32f403a_weact_blackpill"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f402",
|
||||
"description": "Build preset for the at_start_f402 board",
|
||||
"configurePreset": "at_start_f402"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f403a",
|
||||
"description": "Build preset for the at_start_f403a board",
|
||||
"configurePreset": "at_start_f403a"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f405",
|
||||
"description": "Build preset for the at_start_f405 board",
|
||||
"configurePreset": "at_start_f405"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f407",
|
||||
"description": "Build preset for the at_start_f407 board",
|
||||
"configurePreset": "at_start_f407"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f413",
|
||||
"description": "Build preset for the at_start_f413 board",
|
||||
"configurePreset": "at_start_f413"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f415",
|
||||
"description": "Build preset for the at_start_f415 board",
|
||||
"configurePreset": "at_start_f415"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f423",
|
||||
"description": "Build preset for the at_start_f423 board",
|
||||
"configurePreset": "at_start_f423"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f425",
|
||||
"description": "Build preset for the at_start_f425 board",
|
||||
"configurePreset": "at_start_f425"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f435",
|
||||
"description": "Build preset for the at_start_f435 board",
|
||||
"configurePreset": "at_start_f435"
|
||||
},
|
||||
{
|
||||
"name": "at_start_f437",
|
||||
"description": "Build preset for the at_start_f437 board",
|
||||
"configurePreset": "at_start_f437"
|
||||
},
|
||||
{
|
||||
"name": "atsamd21_xpro",
|
||||
"description": "Build preset for the atsamd21_xpro board",
|
||||
@ -1003,6 +1156,11 @@
|
||||
"description": "Build preset for the frdm_mcxa153 board",
|
||||
"configurePreset": "frdm_mcxa153"
|
||||
},
|
||||
{
|
||||
"name": "frdm_mcxa156",
|
||||
"description": "Build preset for the frdm_mcxa156 board",
|
||||
"configurePreset": "frdm_mcxa156"
|
||||
},
|
||||
{
|
||||
"name": "frdm_mcxn947",
|
||||
"description": "Build preset for the frdm_mcxn947 board",
|
||||
@ -1233,6 +1391,11 @@
|
||||
"description": "Build preset for the nanoch32v203 board",
|
||||
"configurePreset": "nanoch32v203"
|
||||
},
|
||||
{
|
||||
"name": "nanoch32v305",
|
||||
"description": "Build preset for the nanoch32v305 board",
|
||||
"configurePreset": "nanoch32v305"
|
||||
},
|
||||
{
|
||||
"name": "pca10056",
|
||||
"description": "Build preset for the pca10056 board",
|
||||
@ -1323,6 +1486,11 @@
|
||||
"description": "Build preset for the raspberry_pi_pico2 board",
|
||||
"configurePreset": "raspberry_pi_pico2"
|
||||
},
|
||||
{
|
||||
"name": "raspberry_pi_pico_w",
|
||||
"description": "Build preset for the raspberry_pi_pico_w board",
|
||||
"configurePreset": "raspberry_pi_pico_w"
|
||||
},
|
||||
{
|
||||
"name": "raspberrypi_cm4",
|
||||
"description": "Build preset for the raspberrypi_cm4 board",
|
||||
@ -1588,6 +1756,21 @@
|
||||
"description": "Build preset for the stm32l4r5nucleo board",
|
||||
"configurePreset": "stm32l4r5nucleo"
|
||||
},
|
||||
{
|
||||
"name": "stm32n6570dk",
|
||||
"description": "Build preset for the stm32n6570dk board",
|
||||
"configurePreset": "stm32n6570dk"
|
||||
},
|
||||
{
|
||||
"name": "stm32n657nucleo",
|
||||
"description": "Build preset for the stm32n657nucleo board",
|
||||
"configurePreset": "stm32n657nucleo"
|
||||
},
|
||||
{
|
||||
"name": "stm32u083cdk",
|
||||
"description": "Build preset for the stm32u083cdk board",
|
||||
"configurePreset": "stm32u083cdk"
|
||||
},
|
||||
{
|
||||
"name": "stm32u545nucleo",
|
||||
"description": "Build preset for the stm32u545nucleo board",
|
||||
@ -1613,6 +1796,11 @@
|
||||
"description": "Build preset for the stm32wb55nucleo board",
|
||||
"configurePreset": "stm32wb55nucleo"
|
||||
},
|
||||
{
|
||||
"name": "stm32wba_nucleo",
|
||||
"description": "Build preset for the stm32wba_nucleo board",
|
||||
"configurePreset": "stm32wba_nucleo"
|
||||
},
|
||||
{
|
||||
"name": "teensy_35",
|
||||
"description": "Build preset for the teensy_35 board",
|
||||
@ -1681,6 +1869,19 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_esp32c6",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "adafruit_feather_esp32c6"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "adafruit_feather_esp32c6"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_esp32s2",
|
||||
"steps": [
|
||||
@ -1707,6 +1908,32 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "adafruit_feather_rp2040_usb_host",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "adafruit_feather_rp2040_usb_host"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "adafruit_feather_rp2040_usb_host"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "adafruit_fruit_jam",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "adafruit_fruit_jam"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "adafruit_fruit_jam"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "adafruit_magtag_29gray",
|
||||
"steps": [
|
||||
@ -1733,6 +1960,19 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "adafruit_metro_rp2350",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "adafruit_metro_rp2350"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "adafruit_metro_rp2350"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "apard32690",
|
||||
"steps": [
|
||||
@ -1759,6 +1999,149 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at32f403a_weact_blackpill",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at32f403a_weact_blackpill"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at32f403a_weact_blackpill"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at_start_f402",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at_start_f402"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at_start_f402"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at_start_f403a",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at_start_f403a"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at_start_f403a"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at_start_f405",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at_start_f405"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at_start_f405"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at_start_f407",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at_start_f407"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at_start_f407"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at_start_f413",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at_start_f413"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at_start_f413"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at_start_f415",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at_start_f415"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at_start_f415"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at_start_f423",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at_start_f423"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at_start_f423"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at_start_f425",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at_start_f425"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at_start_f425"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at_start_f435",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at_start_f435"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at_start_f435"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "at_start_f437",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "at_start_f437"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "at_start_f437"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "atsamd21_xpro",
|
||||
"steps": [
|
||||
@ -2318,6 +2701,19 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "frdm_mcxa156",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "frdm_mcxa156"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "frdm_mcxa156"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "frdm_mcxn947",
|
||||
"steps": [
|
||||
@ -2916,6 +3312,19 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "nanoch32v305",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "nanoch32v305"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "nanoch32v305"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "pca10056",
|
||||
"steps": [
|
||||
@ -3150,6 +3559,19 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "raspberry_pi_pico_w",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "raspberry_pi_pico_w"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "raspberry_pi_pico_w"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "raspberrypi_cm4",
|
||||
"steps": [
|
||||
@ -3839,6 +4261,45 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stm32n6570dk",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "stm32n6570dk"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "stm32n6570dk"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stm32n657nucleo",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "stm32n657nucleo"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "stm32n657nucleo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stm32u083cdk",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "stm32u083cdk"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "stm32u083cdk"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stm32u545nucleo",
|
||||
"steps": [
|
||||
@ -3904,6 +4365,19 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stm32wba_nucleo",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "stm32wba_nucleo"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "stm32wba_nucleo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "teensy_35",
|
||||
"steps": [
|
||||
|
||||
@ -37,6 +37,7 @@ list(APPEND srcs
|
||||
${tusb_src}/class/hid/hid_device.c
|
||||
${tusb_src}/class/midi/midi_device.c
|
||||
${tusb_src}/class/msc/msc_device.c
|
||||
${tusb_src}/class/mtp/mtp_device.c
|
||||
${tusb_src}/class/net/ecm_rndis_device.c
|
||||
${tusb_src}/class/net/ncm_device.c
|
||||
${tusb_src}/class/usbtmc/usbtmc_device.c
|
||||
|
||||
@ -95,6 +95,7 @@ target_sources(tinyusb_device_base INTERFACE
|
||||
${TOP}/src/class/hid/hid_device.c
|
||||
${TOP}/src/class/midi/midi_device.c
|
||||
${TOP}/src/class/msc/msc_device.c
|
||||
${TOP}/src/class/mtp/mtp_device.c
|
||||
${TOP}/src/class/net/ecm_rndis_device.c
|
||||
${TOP}/src/class/net/ncm_device.c
|
||||
${TOP}/src/class/usbtmc/usbtmc_device.c
|
||||
|
||||
@ -54,6 +54,7 @@ function(add_board_target BOARD_TARGET)
|
||||
OSC32K_OVERWRITE_CALIBRATION=0
|
||||
CFG_EXAMPLE_MSC_READONLY
|
||||
CFG_EXAMPLE_VIDEO_READONLY
|
||||
CFG_EXAMPLE_MTP_READONLY
|
||||
)
|
||||
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
149
hw/bsp/stm32u0/FreeRTOSConfig/FreeRTOSConfig.h
Normal file
149
hw/bsp/stm32u0/FreeRTOSConfig/FreeRTOSConfig.h
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.0.0
|
||||
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software. If you wish to use our Amazon
|
||||
* FreeRTOS name, please do so in a fair use way that does not cause confusion.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
// skip if included from IAR assembler
|
||||
#ifndef __IASMARM__
|
||||
#include "stm32u0xx.h"
|
||||
#endif
|
||||
|
||||
/* Cortex M23/M33 port configuration. */
|
||||
#define configENABLE_MPU 0
|
||||
#define configENABLE_FPU 0
|
||||
#define configENABLE_TRUSTZONE 0
|
||||
#define configMINIMAL_SECURE_STACK_SIZE (1024)
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||
#define configCPU_CLOCK_HZ SystemCoreClock
|
||||
#define configTICK_RATE_HZ ( 1000 )
|
||||
#define configMAX_PRIORITIES ( 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( 200 )
|
||||
#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
|
||||
#define configMAX_TASK_NAME_LEN 16
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 4
|
||||
#define configUSE_QUEUE_SETS 0
|
||||
#define configUSE_TIME_SLICING 0
|
||||
#define configUSE_NEWLIB_REENTRANT 0
|
||||
#define configENABLE_BACKWARD_COMPATIBILITY 1
|
||||
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
|
||||
|
||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 0
|
||||
|
||||
/* Hook function related definitions. */
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
#define configCHECK_HANDLER_INSTALLATION 0
|
||||
|
||||
/* Run time and task stats gathering related definitions. */
|
||||
#define configGENERATE_RUN_TIME_STATS 0
|
||||
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||
#define configUSE_TRACE_FACILITY 1 // legacy trace
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
|
||||
|
||||
/* Co-routine definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES 2
|
||||
|
||||
/* Software timer related definitions. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
|
||||
#define configTIMER_QUEUE_LENGTH 32
|
||||
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||
|
||||
/* Optional functions - most linkers will remove unused functions anyway. */
|
||||
#define INCLUDE_vTaskPrioritySet 0
|
||||
#define INCLUDE_uxTaskPriorityGet 0
|
||||
#define INCLUDE_vTaskDelete 0
|
||||
#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
|
||||
#define INCLUDE_xResumeFromISR 0
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 0
|
||||
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 0
|
||||
#define INCLUDE_xTaskGetIdleTaskHandle 0
|
||||
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
|
||||
#define INCLUDE_pcTaskGetTaskName 0
|
||||
#define INCLUDE_eTaskGetState 0
|
||||
#define INCLUDE_xEventGroupSetBitFromISR 0
|
||||
#define INCLUDE_xTimerPendFunctionCall 0
|
||||
|
||||
/* FreeRTOS hooks to NVIC vectors */
|
||||
#define xPortPendSVHandler PendSV_Handler
|
||||
#define xPortSysTickHandler SysTick_Handler
|
||||
#define vPortSVCHandler SVC_Handler
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Interrupt nesting behavior configuration.
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
|
||||
#define configPRIO_BITS 2
|
||||
|
||||
/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
|
||||
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<<configPRIO_BITS) - 1)
|
||||
|
||||
/* The highest interrupt priority that can be used by any interrupt service
|
||||
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
||||
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
||||
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
||||
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
|
||||
|
||||
/* Interrupt priorities used by the kernel port layer itself. These are generic
|
||||
to all Cortex-M ports, and do not rely on any particular library functions. */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
|
||||
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||
|
||||
#endif
|
||||
176
hw/bsp/stm32u0/boards/stm32u083cdk/STM32U083MCTx_FLASH.ld
Normal file
176
hw/bsp/stm32u0/boards/stm32u083cdk/STM32U083MCTx_FLASH.ld
Normal file
@ -0,0 +1,176 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file LinkerScript.ld
|
||||
* @author Auto-generated by STM32CubeIDE
|
||||
* @brief Linker script for STM32U083MCTx Device from STM32U0 series
|
||||
* 256KBytes FLASH
|
||||
* 40KBytes RAM
|
||||
*
|
||||
* Set heap size, stack size and stack location according
|
||||
* to application requirements.
|
||||
*
|
||||
* Set memory bank area and size if external memory is used
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Memories definition */
|
||||
MEMORY
|
||||
{
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K
|
||||
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K
|
||||
}
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
|
||||
|
||||
_Min_Heap_Size = 0x200; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x800; /* required amount of stack */
|
||||
|
||||
/* Sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code into "FLASH" Rom type memory */
|
||||
.isr_vector :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
/* The program code and other data into "FLASH" Rom type memory */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
/* Constant data into "FLASH" Rom type memory */
|
||||
.rodata :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.ARM.extab : {
|
||||
. = ALIGN(4);
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.ARM : {
|
||||
. = ALIGN(4);
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.init_array :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.fini_array :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
/* Used by the startup to initialize data */
|
||||
_sidata = LOADADDR(.data);
|
||||
|
||||
/* Initialized data sections into "RAM" Ram type memory */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
*(.RamFunc) /* .RamFunc sections */
|
||||
*(.RamFunc*) /* .RamFunc* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
|
||||
} >RAM AT> FLASH
|
||||
|
||||
/* Uninitialized data section into "RAM" Ram type memory */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(8);
|
||||
} >RAM
|
||||
|
||||
/* Remove information from the compiler libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
12
hw/bsp/stm32u0/boards/stm32u083cdk/board.cmake
Normal file
12
hw/bsp/stm32u0/boards/stm32u083cdk/board.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
set(MCU_VARIANT stm32u083xx)
|
||||
set(JLINK_DEVICE stm32u083mc)
|
||||
|
||||
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32U083MCTx_FLASH.ld)
|
||||
set(LD_FILE_IAR ${CMAKE_CURRENT_LIST_DIR}/stm32u083xx_flash.icf)
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
STM32U083xx
|
||||
CFG_EXAMPLE_VIDEO_READONLY
|
||||
)
|
||||
endfunction()
|
||||
129
hw/bsp/stm32u0/boards/stm32u083cdk/board.h
Normal file
129
hw/bsp/stm32u0/boards/stm32u083cdk/board.h
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020, Ha Thach (tinyusb.org)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
/* metadata:
|
||||
name: STM32U083C-DK Discovery Kit
|
||||
url: https://www.st.com/en/evaluation-tools/stm32u083c-dk.html
|
||||
*/
|
||||
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// LED - using PA5 (Blue LED from CubeMX)
|
||||
#define LED_PORT GPIOA
|
||||
#define LED_PIN GPIO_PIN_5
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
// Button - using PC2 (from CubeMX generated code)
|
||||
#define BUTTON_PORT GPIOC
|
||||
#define BUTTON_PIN GPIO_PIN_2
|
||||
#define BUTTON_STATE_ACTIVE 0 // Active low (pressed = 0)
|
||||
|
||||
// UART - using USART2 on PA2/PA3 (VCP TX/RX from CubeMX)
|
||||
#define UART_DEV USART2
|
||||
#define UART_CLK_EN __HAL_RCC_USART2_CLK_ENABLE
|
||||
#define UART_GPIO_PORT GPIOA
|
||||
#define UART_GPIO_AF GPIO_AF7_USART2
|
||||
#define UART_TX_PIN GPIO_PIN_2
|
||||
#define UART_RX_PIN GPIO_PIN_3
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// RCC Clock
|
||||
//--------------------------------------------------------------------+
|
||||
static inline void board_stm32u0_clock_init(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
RCC_CRSInitTypeDef RCC_CRSInitStruct = {0};
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||
|
||||
/** Configure the main internal regulator output voltage
|
||||
*/
|
||||
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
|
||||
|
||||
/** Initializes the RCC Oscillators according to the specified parameters
|
||||
* in the RCC_OscInitTypeDef structure.
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI48;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
|
||||
RCC_OscInitStruct.PLL.PLLN = 8;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV4;
|
||||
HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
||||
|
||||
/** Initializes the CPU, AHB and APB buses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||
|
||||
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
|
||||
|
||||
/** Enable the CRS clock
|
||||
*/
|
||||
__HAL_RCC_CRS_CLK_ENABLE();
|
||||
|
||||
/** Configures CRS
|
||||
*/
|
||||
RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
|
||||
RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
|
||||
RCC_CRSInitStruct.Polarity = RCC_CRS_SYNC_POLARITY_RISING;
|
||||
RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000,1000);
|
||||
RCC_CRSInitStruct.ErrorLimitValue = 34;
|
||||
RCC_CRSInitStruct.HSI48CalibrationValue = 32;
|
||||
HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct);
|
||||
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2;
|
||||
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
|
||||
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
|
||||
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
|
||||
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
|
||||
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
|
||||
}
|
||||
|
||||
static inline void board_vbus_sense_init(void)
|
||||
{
|
||||
// USB VBUS sensing not required for device-only operation
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BOARD_H_ */
|
||||
13
hw/bsp/stm32u0/boards/stm32u083cdk/board.mk
Normal file
13
hw/bsp/stm32u0/boards/stm32u083cdk/board.mk
Normal file
@ -0,0 +1,13 @@
|
||||
MCU_VARIANT = stm32u083xx
|
||||
CFLAGS += \
|
||||
-DSTM32U083xx
|
||||
|
||||
# All source paths should be relative to the top level.
|
||||
LD_FILE = $(BOARD_PATH)/STM32U083MCTx_FLASH.ld
|
||||
LD_FILE_IAR = $(BOARD_PATH)/stm32u083xx_flash.icf
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = STM32U083MC
|
||||
|
||||
# flash target using on-board stlink
|
||||
flash: flash-stlink
|
||||
32
hw/bsp/stm32u0/boards/stm32u083cdk/stm32u083xx_flash.icf
Normal file
32
hw/bsp/stm32u0/boards/stm32u083cdk/stm32u083xx_flash.icf
Normal file
@ -0,0 +1,32 @@
|
||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0803FFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
|
||||
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x800;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
block CSTACK, block HEAP };
|
||||
182
hw/bsp/stm32u0/family.c
Normal file
182
hw/bsp/stm32u0/family.c
Normal file
@ -0,0 +1,182 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
/* metadata:
|
||||
manufacturer: STMicroelectronics
|
||||
*/
|
||||
|
||||
#include "stm32u0xx_hal.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "board.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void USB_DRD_FS_IRQHandler(void) {
|
||||
tud_int_handler(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO TYPEDEF CONSTANT ENUM
|
||||
//--------------------------------------------------------------------+
|
||||
#ifdef UART_DEV
|
||||
UART_HandleTypeDef UartHandle;
|
||||
#endif
|
||||
|
||||
void board_init(void) {
|
||||
board_stm32u0_clock_init();
|
||||
|
||||
// Enable All GPIOs clocks
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
#ifdef GPIOD
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
#endif
|
||||
#ifdef GPIOE
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
#endif
|
||||
#ifdef GPIOF
|
||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||
#endif
|
||||
#ifdef GPIOG
|
||||
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||
#endif
|
||||
#ifdef GPIOH
|
||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||
#endif
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
|
||||
// LED
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
GPIO_InitStruct.Pin = LED_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
|
||||
|
||||
// Button
|
||||
GPIO_InitStruct.Pin = BUTTON_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN : GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
|
||||
|
||||
#ifdef UART_DEV
|
||||
// UART
|
||||
GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
GPIO_InitStruct.Alternate = UART_GPIO_AF;
|
||||
HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
|
||||
|
||||
UART_CLK_EN();
|
||||
UartHandle.Instance = UART_DEV;
|
||||
UartHandle.Init.BaudRate = CFG_BOARD_UART_BAUDRATE;
|
||||
UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
UartHandle.Init.StopBits = UART_STOPBITS_1;
|
||||
UartHandle.Init.Parity = UART_PARITY_NONE;
|
||||
UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
UartHandle.Init.Mode = UART_MODE_TX_RX;
|
||||
UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
HAL_UART_Init(&UartHandle);
|
||||
#endif
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_FREERTOS
|
||||
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
|
||||
NVIC_SetPriority(USB_DRD_FS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
|
||||
#endif
|
||||
|
||||
// USB Pins TODO double check USB clock and pin setup
|
||||
// Configure USB DM and DP pins. This is optional, and maintained only for user guidance.
|
||||
GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF10_USB;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
// Enable VDDUSB
|
||||
HAL_PWREx_EnableVddUSB();
|
||||
// USB Clock enable
|
||||
__HAL_RCC_USB_CLK_ENABLE();
|
||||
|
||||
board_vbus_sense_init();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Board porting API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
void board_led_write(bool state) {
|
||||
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1-LED_STATE_ON));
|
||||
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
|
||||
}
|
||||
|
||||
uint32_t board_button_read(void) {
|
||||
return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
|
||||
}
|
||||
|
||||
int board_uart_read(uint8_t* buf, int len) {
|
||||
#ifdef UART_DEV
|
||||
(void) buf; (void) len;
|
||||
return 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int board_uart_write(void const * buf, int len) {
|
||||
#ifdef UART_DEV
|
||||
HAL_UART_Transmit(&UartHandle, (uint8_t*)(uintptr_t) buf, len, 0xffff);
|
||||
return len;
|
||||
#else
|
||||
(void) buf; (void) len;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
volatile uint32_t system_ticks = 0;
|
||||
void SysTick_Handler(void) {
|
||||
system_ticks++;
|
||||
}
|
||||
|
||||
uint32_t board_millis(void) {
|
||||
return system_ticks;
|
||||
}
|
||||
#endif
|
||||
|
||||
void HardFault_Handler(void) {
|
||||
__asm("BKPT #0\n");
|
||||
}
|
||||
|
||||
// Required by __libc_init_array in startup code if we are compiling using
|
||||
// -nostdlib/-nostartfiles.
|
||||
void _init(void) {
|
||||
|
||||
}
|
||||
117
hw/bsp/stm32u0/family.cmake
Normal file
117
hw/bsp/stm32u0/family.cmake
Normal file
@ -0,0 +1,117 @@
|
||||
include_guard()
|
||||
|
||||
set(ST_FAMILY u0)
|
||||
set(ST_PREFIX stm32${ST_FAMILY}xx)
|
||||
|
||||
set(ST_HAL_DRIVER ${TOP}/hw/mcu/st/stm32${ST_FAMILY}xx_hal_driver)
|
||||
set(ST_CMSIS ${TOP}/hw/mcu/st/cmsis-device-${ST_FAMILY})
|
||||
set(CMSIS_5 ${TOP}/lib/CMSIS_5)
|
||||
|
||||
# include board specific
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
|
||||
|
||||
# toolchain set up
|
||||
set(CMAKE_SYSTEM_CPU cortex-m0plus CACHE INTERNAL "System Processor")
|
||||
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
|
||||
|
||||
set(FAMILY_MCUS STM32U0 CACHE INTERNAL "")
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# BOARD_TARGET
|
||||
#------------------------------------
|
||||
# only need to be built ONCE for all examples
|
||||
function(add_board_target BOARD_TARGET)
|
||||
if (TARGET ${BOARD_TARGET})
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Startup & Linker script
|
||||
set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
|
||||
|
||||
string(REPLACE "stm32u" "STM32U" MCU_VARIANT_UPPER ${MCU_VARIANT})
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT_UPPER}_FLASH.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
if (NOT DEFINED LD_FILE_IAR)
|
||||
set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
|
||||
endif ()
|
||||
|
||||
add_library(${BOARD_TARGET} STATIC
|
||||
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_cortex.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_pwr_ex.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
|
||||
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_include_directories(${BOARD_TARGET} PUBLIC
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMSIS_5}/CMSIS/Core/Include
|
||||
${ST_CMSIS}/Include
|
||||
${ST_HAL_DRIVER}/Inc
|
||||
)
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostartfiles
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# Functions
|
||||
#------------------------------------
|
||||
function(family_configure_example TARGET RTOS)
|
||||
family_configure_common(${TARGET} ${RTOS})
|
||||
|
||||
# Board target
|
||||
add_board_target(board_${BOARD})
|
||||
|
||||
#---------- Port Specific ----------
|
||||
# These files are built for each example since it depends on example's tusb_config.h
|
||||
target_sources(${TARGET} PUBLIC
|
||||
# BSP
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
|
||||
)
|
||||
target_include_directories(${TARGET} PUBLIC
|
||||
# family, hw, board
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
|
||||
)
|
||||
|
||||
# Add TinyUSB target and port source
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_STM32U0)
|
||||
target_sources(${TARGET} PUBLIC
|
||||
${TOP}/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
|
||||
)
|
||||
target_link_libraries(${TARGET} PUBLIC board_${BOARD})
|
||||
|
||||
|
||||
|
||||
# Flashing
|
||||
family_add_bin_hex(${TARGET})
|
||||
family_flash_stlink(${TARGET})
|
||||
family_flash_jlink(${TARGET})
|
||||
endfunction()
|
||||
49
hw/bsp/stm32u0/family.mk
Normal file
49
hw/bsp/stm32u0/family.mk
Normal file
@ -0,0 +1,49 @@
|
||||
ST_FAMILY = u0
|
||||
ST_CMSIS = hw/mcu/st/cmsis-device-$(ST_FAMILY)
|
||||
ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
|
||||
|
||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||
CPU_CORE ?= cortex-m0plus
|
||||
|
||||
CFLAGS += \
|
||||
-DCFG_EXAMPLE_MSC_READONLY \
|
||||
-DCFG_EXAMPLE_VIDEO_READONLY \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_STM32U0
|
||||
|
||||
# mcu driver cause following warnings
|
||||
CFLAGS_GCC += \
|
||||
-flto \
|
||||
-Wno-error=unused-parameter \
|
||||
-Wno-error=redundant-decls \
|
||||
-Wno-error=cast-align \
|
||||
-Wno-error=maybe-uninitialized \
|
||||
|
||||
CFLAGS_CLANG += \
|
||||
-Wno-error=parentheses-equality
|
||||
|
||||
LDFLAGS_GCC += \
|
||||
-nostdlib -nostartfiles \
|
||||
--specs=nosys.specs --specs=nano.specs
|
||||
|
||||
SRC_C += \
|
||||
src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \
|
||||
$(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c
|
||||
|
||||
INC += \
|
||||
$(TOP)/$(BOARD_PATH) \
|
||||
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
|
||||
$(TOP)/$(ST_CMSIS)/Include \
|
||||
$(TOP)/$(ST_HAL_DRIVER)/Inc
|
||||
|
||||
# Startup
|
||||
SRC_S_GCC += $(ST_CMSIS)/Source/Templates/gcc/startup_${MCU_VARIANT}.s
|
||||
SRC_S_IAR += $(ST_CMSIS)/Source/Templates/iar/startup_${MCU_VARIANT}.s
|
||||
|
||||
# Linker
|
||||
LD_FILE_IAR ?= $(ST_CMSIS)/Source/Templates/iar/linker/$(MCU_VARIANT)_flash.icf
|
||||
337
hw/bsp/stm32u0/stm32u0xx_hal_conf.h
Normal file
337
hw/bsp/stm32u0/stm32u0xx_hal_conf.h
Normal file
@ -0,0 +1,337 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32u0xx_hal_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief HAL configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32U0xx_HAL_CONF_H
|
||||
#define __STM32U0xx_HAL_CONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* ########################## Module Selection ############################## */
|
||||
/**
|
||||
* @brief This is the list of modules to be used in the HAL driver
|
||||
*/
|
||||
|
||||
#define HAL_MODULE_ENABLED
|
||||
/* #define HAL_ADC_MODULE_ENABLED */
|
||||
/* #define HAL_COMP_MODULE_ENABLED */
|
||||
/* #define HAL_CRC_MODULE_ENABLED */
|
||||
/* #define HAL_CRS_MODULE_ENABLED */
|
||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||
/* #define HAL_DAC_MODULE_ENABLED */
|
||||
/* #define HAL_I2C_MODULE_ENABLED */
|
||||
/* #define HAL_IRDA_MODULE_ENABLED */
|
||||
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||
/* #define HAL_LCD_MODULE_ENABLED */
|
||||
/* #define HAL_LPTIM_MODULE_ENABLED */
|
||||
/* #define HAL_OPAMP_MODULE_ENABLED */
|
||||
#define HAL_PCD_MODULE_ENABLED
|
||||
/* #define HAL_RNG_MODULE_ENABLED */
|
||||
/* #define HAL_RTC_MODULE_ENABLED */
|
||||
/* #define HAL_SPI_MODULE_ENABLED */
|
||||
/* #define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
/* #define HAL_TIM_MODULE_ENABLED */
|
||||
/* #define HAL_TSC_MODULE_ENABLED */
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
/* #define HAL_USART_MODULE_ENABLED */
|
||||
/* #define HAL_WWDG_MODULE_ENABLED */
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
#define HAL_EXTI_MODULE_ENABLED
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
#define HAL_RCC_MODULE_ENABLED
|
||||
#define HAL_FLASH_MODULE_ENABLED
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
|
||||
/* ########################## Oscillator Values adaptation ####################*/
|
||||
/**
|
||||
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSE is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE 4000000U /*!< Value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#if !defined (HSE_STARTUP_TIMEOUT)
|
||||
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
|
||||
#endif /* HSE_STARTUP_TIMEOUT */
|
||||
|
||||
/**
|
||||
* @brief Internal Multiple Speed oscillator (MSI) default value.
|
||||
* This value is the default MSI range value after Reset.
|
||||
*/
|
||||
#if !defined (MSI_VALUE)
|
||||
#define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/
|
||||
#endif /* MSI_VALUE */
|
||||
|
||||
/**
|
||||
* @brief Internal Multiple Speed oscillator (MSI) default value.
|
||||
* This value is the default MSI range value after Reset.
|
||||
*/
|
||||
#if !defined (MSI32_VALUE)
|
||||
#define MSI32_VALUE 32000000U /*!< Value of the Internal oscillator in Hz*/
|
||||
#endif /* MSI32_VALUE */
|
||||
|
||||
/**
|
||||
* @brief Internal High Speed oscillator (HSI) value.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSI is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSI_VALUE)
|
||||
#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/**
|
||||
* @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG.
|
||||
* This internal oscillator is mainly dedicated to provide a high precision clock to
|
||||
* the USB peripheral by means of a special Clock Recovery System (CRS) circuitry.
|
||||
* When the CRS is not used, the HSI48 RC oscillator runs on it default frequency
|
||||
* which is subject to manufacturing process variations.
|
||||
*/
|
||||
#if !defined (HSI48_VALUE)
|
||||
#define HSI48_VALUE 48000000U /*!< Value of the Internal High Speed oscillator for USB FS/RNG in Hz.
|
||||
The real value my vary depending on manufacturing process variations.*/
|
||||
#endif /* HSI48_VALUE */
|
||||
|
||||
/**
|
||||
* @brief Internal Low Speed oscillator (LSI) value.
|
||||
*/
|
||||
#if !defined (LSI_VALUE)
|
||||
#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/
|
||||
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
||||
The real value may vary depending on the variations
|
||||
in voltage and temperature.*/
|
||||
/**
|
||||
* @brief External Low Speed oscillator (LSE) value.
|
||||
* This value is used by the UART, RTC HAL module to compute the system frequency
|
||||
*/
|
||||
#if !defined (LSE_VALUE)
|
||||
#define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/
|
||||
#endif /* LSE_VALUE */
|
||||
|
||||
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
|
||||
#endif /* LSE_STARTUP_TIMEOUT */
|
||||
|
||||
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||
=== you can define the HSE value in your toolchain compiler preprocessor. */
|
||||
|
||||
/* ########################### System Configuration ######################### */
|
||||
/**
|
||||
* @brief This is the HAL system configuration section
|
||||
*/
|
||||
|
||||
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
|
||||
#define TICK_INT_PRIORITY (3U) /*!< tick interrupt priority (lowest by default) */
|
||||
#define USE_RTOS 0U
|
||||
#define PREFETCH_ENABLE 0U
|
||||
#define INSTRUCTION_CACHE_ENABLE 1U
|
||||
|
||||
/* ########################## Assert Selection ############################## */
|
||||
/**
|
||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||
* HAL drivers code
|
||||
*/
|
||||
|
||||
/* #define USE_FULL_ASSERT 1U */
|
||||
|
||||
/* ################## Register callback feature configuration ############### */
|
||||
/**
|
||||
* @brief Set below the peripheral configuration to "1U" to add the support
|
||||
* of HAL callback registration/unregistration feature for the HAL
|
||||
* driver(s). This allows user application to provide specific callback
|
||||
* functions thanks to HAL_PPP_RegisterCallback() rather than overwriting
|
||||
* the default weak callback functions (see each stm32u0xx_hal_ppp.h file
|
||||
* for possible callback identifiers defined in HAL_PPP_CallbackIDTypeDef
|
||||
* for each PPP peripheral).
|
||||
*/
|
||||
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
|
||||
#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
|
||||
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
|
||||
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
|
||||
#define USE_HAL_IWDG_REGISTER_CALLBACKS 0U /* IWDG register callback disabled */
|
||||
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
|
||||
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
|
||||
#define USE_HAL_LCD_REGISTER_CALLBACKS 0U /* LCD register callback disabled */
|
||||
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
|
||||
#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
|
||||
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
|
||||
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
|
||||
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
|
||||
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
|
||||
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
|
||||
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
|
||||
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Include module's header file
|
||||
*/
|
||||
|
||||
#ifdef HAL_RCC_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_rcc.h"
|
||||
#endif /* HAL_RCC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_GPIO_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_gpio.h"
|
||||
#endif /* HAL_GPIO_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DMA_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_dma.h"
|
||||
#endif /* HAL_DMA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CORTEX_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_cortex.h"
|
||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ADC_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_adc.h"
|
||||
#include "stm32u0xx_hal_adc_ex.h"
|
||||
#endif /* HAL_ADC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_COMP_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_comp.h"
|
||||
#endif /* HAL_COMP_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CRC_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_crc.h"
|
||||
#endif /* HAL_CRC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CRS_MODULE_ENABLED
|
||||
#include "stm32u0xx_ll_crs.h"
|
||||
#endif /* HAL_CRS_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CRYP_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_cryp.h"
|
||||
#endif /* HAL_CRYP_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DAC_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_dac.h"
|
||||
#endif /* HAL_DAC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_EXTI_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_exti.h"
|
||||
#endif /* HAL_EXTI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_FLASH_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_flash.h"
|
||||
#endif /* HAL_FLASH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_i2c.h"
|
||||
#endif /* HAL_I2C_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IWDG_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_iwdg.h"
|
||||
#endif /* HAL_IWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_LPTIM_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_lptim.h"
|
||||
#endif /* HAL_LPTIM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_LCD_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_lcd.h"
|
||||
#endif /* HAL_LCD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_OPAMP_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_opamp.h"
|
||||
#endif /* HAL_OPAMP_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PWR_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_pwr.h"
|
||||
#endif /* HAL_PWR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RNG_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_rng.h"
|
||||
#endif /* HAL_RNG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RTC_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_rtc.h"
|
||||
#endif /* HAL_RTC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_spi.h"
|
||||
#endif /* HAL_SPI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_TIM_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_tim.h"
|
||||
#endif /* HAL_TIM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_TSC_MODULE_ENABLED
|
||||
#include "stm32u0xx_ll_system.h"
|
||||
#include "stm32u0xx_hal_tsc.h"
|
||||
#endif /* HAL_TSC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_uart.h"
|
||||
#endif /* HAL_UART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_USART_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_usart.h"
|
||||
#endif /* HAL_USART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IRDA_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_irda.h"
|
||||
#endif /* HAL_IRDA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SMARTCARD_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_smartcard.h"
|
||||
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_WWDG_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_wwdg.h"
|
||||
#endif /* HAL_WWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_LCD_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_lcd.h"
|
||||
#endif /* HAL_LCD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PCD_MODULE_ENABLED
|
||||
#include "stm32u0xx_hal_pcd.h"
|
||||
#endif /* HAL_PCD_MODULE_ENABLED */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr: If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t *file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0U)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32U0xx_HAL_CONF_H */
|
||||
@ -34,6 +34,8 @@ if GetDepend(["PKG_TINYUSB_DEVICE_ENABLE"]):
|
||||
src += ["../../src/class/cdc/cdc_device.c"]
|
||||
if GetDepend(["PKG_TINYUSB_DEVICE_MSC"]):
|
||||
src += ["../../src/class/msc/msc_device.c", "port/msc_device_port.c"]
|
||||
if GetDepend(["PKG_TINYUSB_DEVICE_MTP"]):
|
||||
src += ["../../src/class/mtp/mtp_device.c"]
|
||||
if GetDepend(["PKG_TINYUSB_DEVICE_HID"]):
|
||||
src += ["../../src/class/hid/hid_device.c"]
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ function(tinyusb_target_add TARGET)
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/hid/hid_device.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/midi/midi_device.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/msc/msc_device.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/mtp/mtp_device.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/net/ecm_rndis_device.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/net/ncm_device.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/usbtmc/usbtmc_device.c
|
||||
|
||||
888
src/class/mtp/mtp.h
Normal file
888
src/class/mtp/mtp.h
Normal file
@ -0,0 +1,888 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2025 Ennebi Elettronica (https://ennebielettronica.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#ifndef TUSB_MTP_H_
|
||||
#define TUSB_MTP_H_
|
||||
|
||||
#include "common/tusb_common.h"
|
||||
|
||||
#if (CFG_TUD_ENABLED && CFG_TUD_MTP)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Media Transfer Protocol Class Constant
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Media Transfer Protocol Subclass
|
||||
typedef enum {
|
||||
MTP_SUBCLASS_STILL_IMAGE = 1
|
||||
} mtp_subclass_type_t;
|
||||
|
||||
// MTP Protocol.
|
||||
typedef enum {
|
||||
MTP_PROTOCOL_PIMA_15470 = 1, ///< Picture Transfer Protocol (PIMA 15470)
|
||||
} mtp_protocol_type_t;
|
||||
|
||||
// PTP/MTP protocol phases
|
||||
typedef enum {
|
||||
MTP_PHASE_COMMAND = 0,
|
||||
MTP_PHASE_DATA,
|
||||
MTP_PHASE_RESPONSE,
|
||||
MTP_PHASE_ERROR
|
||||
} mtp_phase_type_t;
|
||||
|
||||
// PTP/MTP Class requests, PIMA 15740-2000: D.5.2
|
||||
typedef enum {
|
||||
MTP_REQ_CANCEL = 0x64,
|
||||
MTP_REQ_GET_EXT_EVENT_DATA = 0x65,
|
||||
MTP_REQ_RESET = 0x66,
|
||||
MTP_REQ_GET_DEVICE_STATUS = 0x67,
|
||||
} mtp_class_request_t;
|
||||
|
||||
// PTP/MTP Container type
|
||||
typedef enum {
|
||||
MTP_CONTAINER_TYPE_UNDEFINED = 0,
|
||||
MTP_CONTAINER_TYPE_COMMAND_BLOCK = 1,
|
||||
MTP_CONTAINER_TYPE_DATA_BLOCK = 2,
|
||||
MTP_CONTAINER_TYPE_RESPONSE_BLOCK = 3,
|
||||
MTP_CONTAINER_TYPE_EVENT_BLOCK = 4,
|
||||
} mtp_container_type_t;
|
||||
|
||||
// MTP 1.1 Appendix A: Object formats
|
||||
typedef enum {
|
||||
// ---- Base formats ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED = 0x3000u, // Undefined object
|
||||
MTP_OBJ_FORMAT_ASSOCIATION = 0x3001u, // Association (for example, a folder)
|
||||
MTP_OBJ_FORMAT_SCRIPT = 0x3002u, // Device model-specific script
|
||||
MTP_OBJ_FORMAT_EXECUTABLE = 0x3003u, // Device model-specific binary executable
|
||||
MTP_OBJ_FORMAT_TEXT = 0x3004u, // Text file
|
||||
MTP_OBJ_FORMAT_HTML = 0x3005u, // Hypertext Markup Language file (text)
|
||||
MTP_OBJ_FORMAT_DPOF = 0x3006u, // Digital Print Order Format file (text)
|
||||
MTP_OBJ_FORMAT_AIFF = 0x3007u, // Audio clip (AIFF)
|
||||
MTP_OBJ_FORMAT_WAV = 0x3008u, // Audio clip (WAV)
|
||||
MTP_OBJ_FORMAT_MP3 = 0x3009u, // MPEG-1 Layer III audio (ISO/IEC 13818-3)
|
||||
MTP_OBJ_FORMAT_AVI = 0x300Au, // Video clip (AVI)
|
||||
MTP_OBJ_FORMAT_MPEG = 0x300Bu, // Video clip (MPEG)
|
||||
MTP_OBJ_FORMAT_ASF = 0x300Cu, // Microsoft Advanced Streaming Format (video)
|
||||
|
||||
// ---- Image formats ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_IMAGE = 0x3800u, // Undefined image object
|
||||
MTP_OBJ_FORMAT_EXIF_JPEG = 0x3801u, // Exchangeable Image Format, JEIDA standard
|
||||
MTP_OBJ_FORMAT_TIFF_EP = 0x3802u, // Tag Image File Format for Electronic Photography
|
||||
MTP_OBJ_FORMAT_FLASHPIX = 0x3803u, // Structured Storage Image Format (FlashPix)
|
||||
MTP_OBJ_FORMAT_BMP = 0x3804u, // Microsoft Windows Bitmap file
|
||||
MTP_OBJ_FORMAT_CIFF = 0x3805u, // Canon Camera Image File Format
|
||||
MTP_OBJ_FORMAT_UNDEFINED_3806 = 0x3806u, // Reserved / Undefined
|
||||
MTP_OBJ_FORMAT_GIF = 0x3807u, // Graphics Interchange Format
|
||||
MTP_OBJ_FORMAT_JFIF = 0x3808u, // JPEG File Interchange Format
|
||||
MTP_OBJ_FORMAT_CD = 0x3809u, // PhotoCD Image Pac
|
||||
MTP_OBJ_FORMAT_PICT = 0x380Au, // Quickdraw Image Format
|
||||
MTP_OBJ_FORMAT_PNG = 0x380Bu, // Portable Network Graphics
|
||||
MTP_OBJ_FORMAT_UNDEFINED_380C = 0x380Cu, // Reserved / Undefined
|
||||
MTP_OBJ_FORMAT_TIFF = 0x380Du, // Tag Image File Format (baseline)
|
||||
MTP_OBJ_FORMAT_TIFF_IT = 0x380Eu, // Tag Image File Format for IT (graphic arts)
|
||||
MTP_OBJ_FORMAT_JP2 = 0x380Fu, // JPEG2000 Baseline File Format
|
||||
MTP_OBJ_FORMAT_JPX = 0x3810u, // JPEG2000 Extended File Format
|
||||
|
||||
// ---- Firmware & misc ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_FIRMWARE = 0xB802u, // Undefined Firmware
|
||||
MTP_OBJ_FORMAT_WBMP = 0xB803u, // Wireless Application Protocol Bitmap Format (.wbmp)
|
||||
MTP_OBJ_FORMAT_WINDOWS_IMAGE = 0xB881u, // Windows Image Format
|
||||
MTP_OBJ_FORMAT_JPEGXR = 0xB804u, // JPEG XR (.hdp, .jxr, .wdp)
|
||||
|
||||
// ---- Audio formats ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_AUDIO = 0xB900u, // Undefined audio object
|
||||
MTP_OBJ_FORMAT_WMA = 0xB901u, // Windows Media Audio
|
||||
MTP_OBJ_FORMAT_OGG = 0xB902u, // OGG container
|
||||
MTP_OBJ_FORMAT_AAC = 0xB903u, // Advanced Audio Coding (.aac)
|
||||
MTP_OBJ_FORMAT_AUDIBLE = 0xB904u, // Audible format
|
||||
MTP_OBJ_FORMAT_FLAC = 0xB906u, // Free Lossless Audio Codec
|
||||
MTP_OBJ_FORMAT_QCELP = 0xB907u, // Qualcomm Code Excited Linear Prediction (.qcp)
|
||||
MTP_OBJ_FORMAT_AMR = 0xB908u, // Adaptive Multi-Rate audio (.amr)
|
||||
|
||||
// ---- Video formats ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_VIDEO = 0xB980u, // Undefined video object
|
||||
MTP_OBJ_FORMAT_WMV = 0xB981u, // Windows Media Video
|
||||
MTP_OBJ_FORMAT_MP4 = 0xB982u, // MP4 Container (ISO 14496-1)
|
||||
MTP_OBJ_FORMAT_MP2 = 0xB983u, // MPEG-1 Layer II audio
|
||||
MTP_OBJ_FORMAT_3GP = 0xB984u, // 3GP Container
|
||||
MTP_OBJ_FORMAT_3G2 = 0xB985u, // 3GPP2 Container
|
||||
MTP_OBJ_FORMAT_AVCHD = 0xB986u, // AVCHD (MPEG-4 AVC + Dolby Digital)
|
||||
MTP_OBJ_FORMAT_ATSC_TS = 0xB987u, // ATSC-compliant MPEG-2 Transport Stream
|
||||
MTP_OBJ_FORMAT_DVB_TS = 0xB988u, // DVB-compliant MPEG-2 Transport Stream
|
||||
|
||||
// ---- Collections ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_COLLECTION = 0xBA00u, // Undefined collection
|
||||
MTP_OBJ_FORMAT_ABSTRACT_MULTIMEDIA_ALBUM = 0xBA01u, // Abstract Multimedia Album
|
||||
MTP_OBJ_FORMAT_ABSTRACT_IMAGE_ALBUM = 0xBA02u, // Abstract Image Album
|
||||
MTP_OBJ_FORMAT_ABSTRACT_AUDIO_ALBUM = 0xBA03u, // Abstract Audio Album
|
||||
MTP_OBJ_FORMAT_ABSTRACT_VIDEO_ALBUM = 0xBA04u, // Abstract Video Album
|
||||
MTP_OBJ_FORMAT_ABSTRACT_AV_PLAYLIST = 0xBA05u, // Abstract Audio & Video Playlist
|
||||
MTP_OBJ_FORMAT_ABSTRACT_CONTACT_GROUP = 0xBA06u, // Abstract Contact Group
|
||||
MTP_OBJ_FORMAT_ABSTRACT_MESSAGE_FOLDER = 0xBA07u, // Abstract Message Folder
|
||||
MTP_OBJ_FORMAT_ABSTRACT_CHAPTERED_PRODUCTION = 0xBA08u, // Abstract Chaptered Production
|
||||
MTP_OBJ_FORMAT_ABSTRACT_AUDIO_PLAYLIST = 0xBA09u, // Abstract Audio Playlist
|
||||
MTP_OBJ_FORMAT_ABSTRACT_VIDEO_PLAYLIST = 0xBA0Au, // Abstract Video Playlist
|
||||
MTP_OBJ_FORMAT_ABSTRACT_MEDIACAST = 0xBA0Bu, // Abstract Mediacast (RSS enclosure)
|
||||
|
||||
// ---- Playlist formats ----
|
||||
MTP_OBJ_FORMAT_WPL_PLAYLIST = 0xBA10u, // Windows Media Player Playlist (.wpl)
|
||||
MTP_OBJ_FORMAT_M3U_PLAYLIST = 0xBA11u, // M3U Playlist
|
||||
MTP_OBJ_FORMAT_MPL_PLAYLIST = 0xBA12u, // MPL Playlist
|
||||
MTP_OBJ_FORMAT_ASX_PLAYLIST = 0xBA13u, // ASX Playlist
|
||||
MTP_OBJ_FORMAT_PLS_PLAYLIST = 0xBA14u, // PLS Playlist
|
||||
|
||||
// ---- Document formats ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_DOC = 0xBA80u, // Undefined Document
|
||||
MTP_OBJ_FORMAT_ABSTRACT_DOC = 0xBA81u, // Abstract Document
|
||||
MTP_OBJ_FORMAT_XML_DOC = 0xBA82u, // XML Document
|
||||
MTP_OBJ_FORMAT_DOC = 0xBA83u, // Microsoft Word Document
|
||||
MTP_OBJ_FORMAT_MHT_DOC = 0xBA84u, // MHT Compiled HTML Document
|
||||
MTP_OBJ_FORMAT_XLS = 0xBA85u, // Microsoft Excel Spreadsheet
|
||||
MTP_OBJ_FORMAT_PPT = 0xBA86u, // Microsoft PowerPoint Presentation
|
||||
|
||||
// ---- Messaging ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_MSG = 0xBB00u, // Undefined Message
|
||||
MTP_OBJ_FORMAT_ABSTRACT_MSG = 0xBB01u, // Abstract Message
|
||||
|
||||
// ---- Bookmarks ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_BOOKMARK = 0xBB10u, // Undefined Bookmark
|
||||
MTP_OBJ_FORMAT_ABSTRACT_BOOKMARK = 0xBB11u, // Abstract Bookmark
|
||||
|
||||
// ---- Appointments ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_APPT = 0xBB20u, // Undefined Appointment
|
||||
MTP_OBJ_FORMAT_ABSTRACT_APPT = 0xBB21u, // Abstract Appointment
|
||||
MTP_OBJ_FORMAT_VCALENDAR1 = 0xBB22u, // vCalendar 1.0
|
||||
|
||||
// ---- Tasks ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_TASK = 0xBB40u, // Undefined Task
|
||||
MTP_OBJ_FORMAT_ABSTRACT_TASK = 0xBB41u, // Abstract Task
|
||||
MTP_OBJ_FORMAT_ICALENDAR = 0xBB42u, // iCalendar
|
||||
|
||||
// ---- Notes ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_NOTE = 0xBB60u, // Undefined Note
|
||||
MTP_OBJ_FORMAT_ABSTRACT_NOTE = 0xBB61u, // Abstract Note
|
||||
|
||||
// ---- Contacts ----
|
||||
MTP_OBJ_FORMAT_UNDEFINED_CONTACT= 0xBB80u, // Undefined Contact
|
||||
MTP_OBJ_FORMAT_ABSTRACT_CONTACT = 0xBB81u, // Abstract Contact
|
||||
MTP_OBJ_FORMAT_VCARD2 = 0xBB82u, // vCard 2.1
|
||||
MTP_OBJ_FORMAT_VCARD3 = 0xBB83u, // vCard 3.0
|
||||
} mtp_object_formats_t;
|
||||
|
||||
// MTP 1.1 Appendix B: Object Properties
|
||||
typedef enum {
|
||||
MTP_OBJ_PROP_STORAGE_ID = 0xDC01u, // StorageID
|
||||
MTP_OBJ_PROP_OBJECT_FORMAT = 0xDC02u, // Object Format
|
||||
MTP_OBJ_PROP_PROTECTION_STATUS = 0xDC03u, // Protection Status
|
||||
MTP_OBJ_PROP_OBJECT_SIZE = 0xDC04u, // Object Size
|
||||
MTP_OBJ_PROP_ASSOCIATION_TYPE = 0xDC05u, // Association Type
|
||||
MTP_OBJ_PROP_ASSOCIATION_DESC = 0xDC06u, // Association Description
|
||||
MTP_OBJ_PROP_OBJECT_FILE_NAME = 0xDC07u, // Object File Name
|
||||
MTP_OBJ_PROP_DATE_CREATED = 0xDC08u, // Date Created
|
||||
MTP_OBJ_PROP_DATE_MODIFIED = 0xDC09u, // Date Modified
|
||||
MTP_OBJ_PROP_KEYWORDS = 0xDC0Au, // Keywords
|
||||
MTP_OBJ_PROP_PARENT_OBJECT = 0xDC0Bu, // Parent Object
|
||||
MTP_OBJ_PROP_ALLOWED_FOLDER_CONTENTS = 0xDC0Cu, // Allowed Folder Contents
|
||||
MTP_OBJ_PROP_HIDDEN = 0xDC0Du, // Hidden
|
||||
MTP_OBJ_PROP_SYSTEM_OBJECT = 0xDC0Eu, // System Object
|
||||
// 0xDC0F-0xDC40 is reserved
|
||||
|
||||
MTP_OBJ_PROP_PERSISTENT_UID = 0xDC41u, // Persistent Unique Object Identifier
|
||||
MTP_OBJ_PROP_SYNC_ID = 0xDC42u, // SyncID
|
||||
MTP_OBJ_PROP_PROPERTY_BAG = 0xDC43u, // Property Bag
|
||||
MTP_OBJ_PROP_NAME = 0xDC44u, // Name
|
||||
MTP_OBJ_PROP_CREATED_BY = 0xDC45u, // Created By
|
||||
MTP_OBJ_PROP_ARTIST = 0xDC46u, // Artist
|
||||
MTP_OBJ_PROP_DATE_AUTHORED = 0xDC47u, // Date Authored
|
||||
MTP_OBJ_PROP_DESCRIPTION = 0xDC48u, // Description
|
||||
MTP_OBJ_PROP_URL_REFERENCE = 0xDC49u, // URL Reference
|
||||
MTP_OBJ_PROP_LANGUAGE_LOCALE = 0xDC4Au, // Language-Locale
|
||||
MTP_OBJ_PROP_COPYRIGHT_INFO = 0xDC4Bu, // Copyright Information
|
||||
MTP_OBJ_PROP_SOURCE = 0xDC4Cu, // Source
|
||||
MTP_OBJ_PROP_ORIGIN_LOCATION = 0xDC4Du, // Origin Location
|
||||
MTP_OBJ_PROP_DATE_ADDED = 0xDC4Eu, // Date Added
|
||||
MTP_OBJ_PROP_NON_CONSUMABLE = 0xDC4Fu, // Non-Consumable
|
||||
MTP_OBJ_PROP_CORRUPT_UNPLAYABLE = 0xDC50u, // Corrupt/Unplayable
|
||||
MTP_OBJ_PROP_PRODUCER_SERIAL_NUMBER = 0xDC51u, // ProducerSerialNumber
|
||||
// 0xDC52-0xDC80 is reserved
|
||||
|
||||
MTP_OBJ_PROP_REP_SAMPLE_FORMAT = 0xDC81u, // Representative Sample Format
|
||||
MTP_OBJ_PROP_REP_SAMPLE_SIZE = 0xDC82u, // Representative Sample Size
|
||||
MTP_OBJ_PROP_REP_SAMPLE_HEIGHT = 0xDC83u, // Representative Sample Height
|
||||
MTP_OBJ_PROP_REP_SAMPLE_WIDTH = 0xDC84u, // Representative Sample Width
|
||||
MTP_OBJ_PROP_REP_SAMPLE_DURATION = 0xDC85u, // Representative Sample Duration
|
||||
MTP_OBJ_PROP_REP_SAMPLE_DATA = 0xDC86u, // Representative Sample Data
|
||||
MTP_OBJ_PROP_WIDTH = 0xDC87u, // Width
|
||||
MTP_OBJ_PROP_HEIGHT = 0xDC88u, // Height
|
||||
MTP_OBJ_PROP_DURATION = 0xDC89u, // Duration
|
||||
MTP_OBJ_PROP_RATING = 0xDC8Au, // Rating
|
||||
MTP_OBJ_PROP_TRACK = 0xDC8Bu, // Track
|
||||
MTP_OBJ_PROP_GENRE = 0xDC8Cu, // Genre
|
||||
MTP_OBJ_PROP_CREDITS = 0xDC8Du, // Credits
|
||||
MTP_OBJ_PROP_LYRICS = 0xDC8Eu, // Lyrics
|
||||
MTP_OBJ_PROP_SUBSCRIPTION_CONTENT_ID = 0xDC8Fu, // Subscription Content ID
|
||||
MTP_OBJ_PROP_PRODUCED_BY = 0xDC90u, // Produced By
|
||||
MTP_OBJ_PROP_USE_COUNT = 0xDC91u, // Use Count
|
||||
MTP_OBJ_PROP_SKIP_COUNT = 0xDC92u, // Skip Count
|
||||
MTP_OBJ_PROP_LAST_ACCESSED = 0xDC93u, // Last Accessed
|
||||
MTP_OBJ_PROP_PARENTAL_RATING = 0xDC94u, // Parental Rating
|
||||
MTP_OBJ_PROP_META_GENRE = 0xDC95u, // Meta Genre
|
||||
MTP_OBJ_PROP_COMPOSER = 0xDC96u, // Composer
|
||||
MTP_OBJ_PROP_EFFECTIVE_RATING = 0xDC97u, // Effective Rating
|
||||
MTP_OBJ_PROP_SUBTITLE = 0xDC98u, // Subtitle
|
||||
MTP_OBJ_PROP_ORIGINAL_RELEASE_DATE = 0xDC99u, // Original Release Date
|
||||
MTP_OBJ_PROP_ALBUM_NAME = 0xDC9Au, // Album Name
|
||||
MTP_OBJ_PROP_ALBUM_ARTIST = 0xDC9Bu, // Album Artist
|
||||
MTP_OBJ_PROP_MOOD = 0xDC9Cu, // Mood
|
||||
MTP_OBJ_PROP_DRM_STATUS = 0xDC9Du, // DRM Status
|
||||
MTP_OBJ_PROP_SUB_DESCRIPTION = 0xDC9Eu, // Sub Description
|
||||
// 0xDC9F-0xDCD0 is reserved
|
||||
|
||||
MTP_OBJ_PROP_IS_CROPPED = 0xDCD1u, // Is Cropped
|
||||
MTP_OBJ_PROP_IS_COLOUR_CORRECTED = 0xDCD2u, // Is Colour Corrected
|
||||
MTP_OBJ_PROP_IMAGE_BIT_DEPTH = 0xDCD3u, // Image Bit Depth
|
||||
MTP_OBJ_PROP_FNUMBER = 0xDCD4u, // Fnumber (aperture ×100)
|
||||
MTP_OBJ_PROP_EXPOSURE_TIME = 0xDCD5u, // Exposure Time (sec ×10,000)
|
||||
MTP_OBJ_PROP_EXPOSURE_INDEX = 0xDCD6u, // Exposure Index (ISO)
|
||||
// 0xDCD7-0xDCDF is reserved
|
||||
|
||||
MTP_OBJ_PROP_DISPLAY_NAME = 0xDCE0u, // Display Name
|
||||
MTP_OBJ_PROP_BODY_TEXT = 0xDCE1u, // Body Text
|
||||
MTP_OBJ_PROP_SUBJECT = 0xDCE2u, // Subject
|
||||
MTP_OBJ_PROP_PRIORITY = 0xDCE3u, // Priority
|
||||
// 0xDCE4-0xDCFF is reserved
|
||||
|
||||
MTP_OBJ_PROP_GIVEN_NAME = 0xDD00u, // Given Name
|
||||
MTP_OBJ_PROP_MIDDLE_NAMES = 0xDD01u, // Middle Names
|
||||
MTP_OBJ_PROP_FAMILY_NAME = 0xDD02u, // Family Name
|
||||
MTP_OBJ_PROP_PREFIX = 0xDD03u, // Prefix
|
||||
MTP_OBJ_PROP_SUFFIX = 0xDD04u, // Suffix
|
||||
MTP_OBJ_PROP_PHONETIC_GIVEN_NAME = 0xDD05u, // Phonetic Given Name
|
||||
MTP_OBJ_PROP_PHONETIC_FAMILY_NAME = 0xDD06u, // Phonetic Family Name
|
||||
MTP_OBJ_PROP_EMAIL_PRIMARY = 0xDD07u, // Email Primary
|
||||
MTP_OBJ_PROP_EMAIL_PERSONAL_1 = 0xDD08u, // Email Personal 1
|
||||
MTP_OBJ_PROP_EMAIL_PERSONAL_2 = 0xDD09u, // Email Personal 2
|
||||
MTP_OBJ_PROP_EMAIL_BUSINESS_1 = 0xDD0Au, // Email Business 1
|
||||
MTP_OBJ_PROP_EMAIL_BUSINESS_2 = 0xDD0Bu, // Email Business 2
|
||||
MTP_OBJ_PROP_EMAIL_OTHERS = 0xDD0Cu, // Email Others
|
||||
MTP_OBJ_PROP_PHONE_PRIMARY = 0xDD0Du, // Phone Number Primary
|
||||
MTP_OBJ_PROP_PHONE_PERSONAL_1 = 0xDD0Eu, // Phone Number Personal
|
||||
MTP_OBJ_PROP_PHONE_PERSONAL_2 = 0xDD0Fu, // Phone Number Personal 2
|
||||
MTP_OBJ_PROP_PHONE_BUSINESS_1 = 0xDD10u, // Phone Number Business
|
||||
MTP_OBJ_PROP_PHONE_BUSINESS_2 = 0xDD11u, // Phone Number Business 2
|
||||
MTP_OBJ_PROP_PHONE_MOBILE_1 = 0xDD12u, // Phone Number Mobile
|
||||
MTP_OBJ_PROP_PHONE_MOBILE_2 = 0xDD13u, // Phone Number Mobile 2
|
||||
MTP_OBJ_PROP_FAX_PRIMARY = 0xDD14u, // Fax Number Primary
|
||||
MTP_OBJ_PROP_FAX_PERSONAL = 0xDD15u, // Fax Number Personal
|
||||
MTP_OBJ_PROP_FAX_BUSINESS = 0xDD16u, // Fax Number Business
|
||||
MTP_OBJ_PROP_PAGER_NUMBER = 0xDD17u, // Pager Number
|
||||
MTP_OBJ_PROP_PHONE_OTHERS = 0xDD18u, // Phone Number Others
|
||||
MTP_OBJ_PROP_WEB_PRIMARY = 0xDD19u, // Primary Web Address
|
||||
MTP_OBJ_PROP_WEB_PERSONAL = 0xDD1Au, // Personal Web Address
|
||||
MTP_OBJ_PROP_WEB_BUSINESS = 0xDD1Bu, // Business Web Address
|
||||
MTP_OBJ_PROP_IM_ADDRESS_1 = 0xDD1Cu, // Instant Messenger Address
|
||||
MTP_OBJ_PROP_IM_ADDRESS_2 = 0xDD1Du, // Instant Messenger Address 2
|
||||
MTP_OBJ_PROP_IM_ADDRESS_3 = 0xDD1Eu, // Instant Messenger Address 3
|
||||
MTP_OBJ_PROP_ADDR_PERSONAL_FULL = 0xDD1Fu, // Postal Address Personal Full
|
||||
MTP_OBJ_PROP_ADDR_PERSONAL_LINE1 = 0xDD20u, // Postal Address Personal Line 1
|
||||
MTP_OBJ_PROP_ADDR_PERSONAL_LINE2 = 0xDD21u, // Postal Address Personal Line 2
|
||||
MTP_OBJ_PROP_ADDR_PERSONAL_CITY = 0xDD22u, // Postal Address Personal City
|
||||
MTP_OBJ_PROP_ADDR_PERSONAL_REGION = 0xDD23u, // Postal Address Personal Region
|
||||
MTP_OBJ_PROP_ADDR_PERSONAL_POSTAL_CODE = 0xDD24u, // Postal Address Personal Postal Code
|
||||
MTP_OBJ_PROP_ADDR_PERSONAL_COUNTRY = 0xDD25u, // Postal Address Personal Country
|
||||
MTP_OBJ_PROP_ADDR_BUSINESS_FULL = 0xDD26u, // Postal Address Business Full
|
||||
MTP_OBJ_PROP_ADDR_BUSINESS_LINE1 = 0xDD27u, // Postal Address Business Line 1
|
||||
MTP_OBJ_PROP_ADDR_BUSINESS_LINE2 = 0xDD28u, // Postal Address Business Line 2
|
||||
MTP_OBJ_PROP_ADDR_BUSINESS_CITY = 0xDD29u, // Postal Address Business City
|
||||
MTP_OBJ_PROP_ADDR_BUSINESS_REGION = 0xDD2Au, // Postal Address Business Region
|
||||
MTP_OBJ_PROP_ADDR_BUSINESS_POSTAL_CODE = 0xDD2Bu, // Postal Address Business Postal Code
|
||||
MTP_OBJ_PROP_ADDR_BUSINESS_COUNTRY = 0xDD2Cu, // Postal Address Business Country
|
||||
MTP_OBJ_PROP_ADDR_OTHER_FULL = 0xDD2Du, // Postal Address Other Full
|
||||
MTP_OBJ_PROP_ADDR_OTHER_LINE1 = 0xDD2Eu, // Postal Address Other Line 1
|
||||
MTP_OBJ_PROP_ADDR_OTHER_LINE2 = 0xDD2Fu, // Postal Address Other Line 2
|
||||
MTP_OBJ_PROP_ADDR_OTHER_CITY = 0xDD30u, // Postal Address Other City
|
||||
MTP_OBJ_PROP_ADDR_OTHER_REGION = 0xDD31u, // Postal Address Other Region
|
||||
MTP_OBJ_PROP_ADDR_OTHER_POSTAL_CODE = 0xDD32u, // Postal Address Other Postal Code
|
||||
MTP_OBJ_PROP_ADDR_OTHER_COUNTRY = 0xDD33u, // Postal Address Other Country
|
||||
MTP_OBJ_PROP_ORGANIZATION_NAME = 0xDD34u, // Organization Name
|
||||
MTP_OBJ_PROP_PHONETIC_ORG_NAME = 0xDD35u, // Phonetic Organization Name
|
||||
MTP_OBJ_PROP_ROLE = 0xDD36u, // Role
|
||||
MTP_OBJ_PROP_BIRTHDATE = 0xDD37u, // Birthdate
|
||||
// 0xDD38-0xDD3F is reserved
|
||||
|
||||
MTP_OBJ_PROP_MESSAGE_TO = 0xDD40u, // Message To
|
||||
MTP_OBJ_PROP_MESSAGE_CC = 0xDD41u, // Message CC
|
||||
MTP_OBJ_PROP_MESSAGE_BCC = 0xDD42u, // Message BCC
|
||||
MTP_OBJ_PROP_MESSAGE_READ = 0xDD43u, // Message Read
|
||||
MTP_OBJ_PROP_MESSAGE_RECEIVED_TIME = 0xDD44u, // Message Received Time
|
||||
MTP_OBJ_PROP_MESSAGE_SENDER = 0xDD45u, // Message Sender
|
||||
// 0xDD46-0xDD4F is reserved
|
||||
|
||||
MTP_OBJ_PROP_ACTIVITY_BEGIN_TIME = 0xDD50u, // Activity Begin Time
|
||||
MTP_OBJ_PROP_ACTIVITY_END_TIME = 0xDD51u, // Activity End Time
|
||||
MTP_OBJ_PROP_ACTIVITY_LOCATION = 0xDD52u, // Activity Location
|
||||
// 0xDD53 is reserved
|
||||
MTP_OBJ_PROP_ACTIVITY_REQUIRED_ATTENDEES= 0xDD54u, // Activity Required Attendees
|
||||
MTP_OBJ_PROP_ACTIVITY_OPTIONAL_ATTENDEES= 0xDD55u, // Activity Optional Attendees
|
||||
MTP_OBJ_PROP_ACTIVITY_RESOURCES = 0xDD56u, // Activity Resources
|
||||
MTP_OBJ_PROP_ACTIVITY_ACCEPTED = 0xDD57u, // Activity Accepted
|
||||
MTP_OBJ_PROP_ACTIVITY_TENTATIVE = 0xDD58u, // Activity Tentative
|
||||
MTP_OBJ_PROP_ACTIVITY_DECLINED = 0xDD59u, // Activity Declined
|
||||
MTP_OBJ_PROP_ACTIVITY_REMINDER_TIME = 0xDD5Au, // Activity Reminder Time
|
||||
MTP_OBJ_PROP_ACTIVITY_OWNER = 0xDD5Bu, // Activity Owner
|
||||
MTP_OBJ_PROP_ACTIVITY_STATUS = 0xDD5Cu, // Activity Status
|
||||
MTP_OBJ_PROP_OWNER = 0xDD5Du, // Owner
|
||||
MTP_OBJ_PROP_EDITOR = 0xDD5Eu, // Editor
|
||||
MTP_OBJ_PROP_WEBMASTER = 0xDD5Fu, // Webmaster
|
||||
|
||||
MTP_OBJ_PROP_URL_SOURCE = 0xDD60u, // URL Source
|
||||
MTP_OBJ_PROP_URL_DESTINATION = 0xDD61u, // URL Destination
|
||||
MTP_OBJ_PROP_TIME_BOOKMARK = 0xDD62u, // Time Bookmark
|
||||
MTP_OBJ_PROP_OBJECT_BOOKMARK = 0xDD63u, // Object Bookmark
|
||||
MTP_OBJ_PROP_BYTE_BOOKMARK = 0xDD64u, // Byte Bookmark
|
||||
// 0xDD65-0xDD6F is reserved
|
||||
|
||||
MTP_OBJ_PROP_LAST_BUILD_DATE = 0xDD70u, // Last Build Date
|
||||
MTP_OBJ_PROP_TIME_TO_LIVE = 0xDD71u, // Time to Live (minutes)
|
||||
MTP_OBJ_PROP_MEDIA_GUID = 0xDD72u, // Media GUID
|
||||
// 0xDD73-0xDDFF is reserved
|
||||
|
||||
// media encoding
|
||||
MTP_OBJ_PROP_TOTAL_BITRATE = 0xDE91u, // Total BitRate
|
||||
MTP_OBJ_PROP_BITRATE_TYPE = 0xDE92u, // Bitrate Type
|
||||
MTP_OBJ_PROP_SAMPLE_RATE = 0xDE93u, // Sample Rate
|
||||
MTP_OBJ_PROP_NUM_CHANNELS = 0xDE94u, // Number Of Channels
|
||||
MTP_OBJ_PROP_AUDIO_BITDEPTH = 0xDE95u, // Audio BitDepth
|
||||
// 0xDE96 is reserved
|
||||
MTP_OBJ_PROP_SCAN_TYPE = 0xDE97u, // Scan Type
|
||||
// 0xDE98 is reserved
|
||||
MTP_OBJ_PROP_AUDIO_WAVE_CODEC = 0xDE99u, // Audio WAVE Codec
|
||||
MTP_OBJ_PROP_AUDIO_BITRATE = 0xDE9Au, // Audio BitRate
|
||||
MTP_OBJ_PROP_VIDEO_FOURCC_CODEC = 0xDE9Bu, // Video FourCC Codec
|
||||
MTP_OBJ_PROP_VIDEO_BITRATE = 0xDE9Cu, // Video BitRate
|
||||
MTP_OBJ_PROP_FRAMES_PER_KSEC = 0xDE9Du, // Frames Per Thousand Seconds
|
||||
MTP_OBJ_PROP_KEYFRAME_DISTANCE = 0xDE9Eu, // KeyFrame Distance (ms)
|
||||
MTP_OBJ_PROP_BUFFER_SIZE = 0xDE9Fu, // Buffer Size
|
||||
MTP_OBJ_PROP_ENCODING_QUALITY = 0xDEA0u, // Encoding Quality
|
||||
MTP_OBJ_PROP_ENCODING_PROFILE = 0xDEA1u // Encoding Profile
|
||||
} mtp_object_properties_t;
|
||||
|
||||
|
||||
// MTP 1.1 Appendeix C: Device Properties
|
||||
typedef enum {
|
||||
MTP_DEV_PROP_UNDEFINED = 0x5000u,
|
||||
MTP_DEV_PROP_BATTERY_LEVEL = 0x5001u,
|
||||
MTP_DEV_PROP_FUNCTIONAL_MODE = 0x5002u,
|
||||
MTP_DEV_PROP_IMAGE_SIZE = 0x5003u,
|
||||
MTP_DEV_PROP_COMPRESSION_SETTING = 0x5004u,
|
||||
MTP_DEV_PROP_WHITE_BALANCE = 0x5005u,
|
||||
MTP_DEV_PROP_RGB_GAIN = 0x5006u,
|
||||
MTP_DEV_PROP_F_NUMBER = 0x5007u,
|
||||
MTP_DEV_PROP_FOCAL_LENGTH = 0x5008u,
|
||||
MTP_DEV_PROP_FOCUS_DISTANCE = 0x5009u,
|
||||
MTP_DEV_PROP_FOCUS_MODE = 0x500Au,
|
||||
MTP_DEV_PROP_EXPOSURE_METERING_MODE = 0x500Bu,
|
||||
MTP_DEV_PROP_FLASH_MODE = 0x500Cu,
|
||||
MTP_DEV_PROP_EXPOSURE_TIME = 0x500Du,
|
||||
MTP_DEV_PROP_EXPOSURE_PROGRAM_MODE = 0x500Eu,
|
||||
MTP_DEV_PROP_EXPOSURE_INDEX = 0x500Fu,
|
||||
MTP_DEV_PROP_EXPOSURE_BIAS_COMPENSATION = 0x5010u,
|
||||
MTP_DEV_PROP_DATE_TIME = 0x5011u,
|
||||
MTP_DEV_PROP_CAPTURE_DELAY = 0x5012u,
|
||||
MTP_DEV_PROP_STILL_CAPTURE_MODE = 0x5013u,
|
||||
MTP_DEV_PROP_CONTRAST = 0x5014u,
|
||||
MTP_DEV_PROP_SHARPNESS = 0x5015u,
|
||||
MTP_DEV_PROP_DIGITAL_ZOOM = 0x5016u,
|
||||
MTP_DEV_PROP_EFFECT_MODE = 0x5017u,
|
||||
MTP_DEV_PROP_BURST_NUMBER = 0x5018u,
|
||||
MTP_DEV_PROP_BURST_INTERVAL = 0x5019u,
|
||||
MTP_DEV_PROP_TIMELAPSE_NUMBER = 0x501Au,
|
||||
MTP_DEV_PROP_TIMELAPSE_INTERVAL = 0x501Bu,
|
||||
MTP_DEV_PROP_FOCUS_METERING_MODE = 0x501Cu,
|
||||
MTP_DEV_PROP_UPLOAD_URL = 0x501Du,
|
||||
MTP_DEV_PROP_ARTIST = 0x501Eu,
|
||||
MTP_DEV_PROP_COPYRIGHT_INFO = 0x501Fu,
|
||||
MTP_DEV_PROP_SYNCHRONIZTION_PARTNER = 0xD401,
|
||||
MTP_DEV_PROP_DEVICE_FRIENDLY_NAME = 0xD402u,
|
||||
MTP_DEV_PROP_VOLUME = 0xD403u,
|
||||
MTP_DEV_PROP_SUPPORTED_FORMATS_ORDERED = 0xD404u,
|
||||
MTP_DEV_PROP_DEVICE_ICON = 0xD405u,
|
||||
MTP_DEV_PROP_SECTION_INITIATOR_VERSION_INFO = 0xD406u,
|
||||
MTP_DEV_PROP_PERCEIVED_DEVICE_TYPE = 0xD407u,
|
||||
MTP_DEV_PROP_PLAYBACK_RATE = 0xD410u,
|
||||
MTP_DEV_PROP_PLAYBACK_OBJECT = 0xD411u,
|
||||
MTP_DEV_PROP_PLAYBACK_CONTAINER_INDEX = 0xD412u,
|
||||
} mtp_event_properties_t;
|
||||
|
||||
// MTP 1.1 Appendix D: Operations
|
||||
typedef enum {
|
||||
MTP_OP_UNDEFINED = 0x1000u,
|
||||
MTP_OP_GET_DEVICE_INFO = 0x1001u,
|
||||
MTP_OP_OPEN_SESSION = 0x1002u,
|
||||
MTP_OP_CLOSE_SESSION = 0x1003u,
|
||||
MTP_OP_GET_STORAGE_IDS = 0x1004u,
|
||||
MTP_OP_GET_STORAGE_INFO = 0x1005u,
|
||||
MTP_OP_GET_NUM_OBJECTS = 0x1006u,
|
||||
MTP_OP_GET_OBJECT_HANDLES = 0x1007u,
|
||||
MTP_OP_GET_OBJECT_INFO = 0x1008u,
|
||||
MTP_OP_GET_OBJECT = 0x1009u,
|
||||
MTP_OP_GET_THUMB = 0x100Au,
|
||||
MTP_OP_DELETE_OBJECT = 0x100Bu,
|
||||
MTP_OP_SEND_OBJECT_INFO = 0x100Cu,
|
||||
MTP_OP_SEND_OBJECT = 0x100Du,
|
||||
MTP_OP_INITIATE_CAPTURE = 0x100Eu,
|
||||
MTP_OP_FORMAT_STORE = 0x100Fu,
|
||||
MTP_OP_RESET_DEVICE = 0x1010u,
|
||||
MTP_OP_SELF_TEST = 0x1011u,
|
||||
MTP_OP_SET_OBJECT_PROTECTION = 0x1012u,
|
||||
MTP_OP_POWER_DOWN = 0x1013u,
|
||||
MTP_OP_GET_DEVICE_PROP_DESC = 0x1014u,
|
||||
MTP_OP_GET_DEVICE_PROP_VALUE = 0x1015u,
|
||||
MTP_OP_SET_DEVICE_PROP_VALUE = 0x1016u,
|
||||
MTP_OP_RESET_DEVICE_PROP_VALUE = 0x1017u,
|
||||
MTP_OP_TERMINATE_OPEN_CAPTURE = 0x1018u,
|
||||
MTP_OP_MOVE_OBJECT = 0x1019u,
|
||||
MTP_OP_COPY_OBJECT = 0x101Au,
|
||||
MTP_OP_GET_PARTIAL_OBJECT = 0x101Bu,
|
||||
MTP_OP_INITIATE_OPEN_CAPTURE = 0x101Bu,
|
||||
MTP_OP_GET_OBJECT_PROPS_SUPPORTED = 0x9801u,
|
||||
MTP_OP_GET_OBJECT_PROP_DESC = 0x9802u,
|
||||
MTP_OP_GET_OBJECT_PROP_VALUE = 0x9803u,
|
||||
MTP_OP_SET_OBJECT_PROP_VALUE = 0x9804u,
|
||||
MTP_OP_GET_OBJECT_PROPLIST = 0x9805u,
|
||||
MTP_OP_GET_OBJECT_PROP_REFERENCES = 0x9810u,
|
||||
|
||||
MTP_OP_GET_SERVICE_IDS = 0x9301u,
|
||||
MTP_OP_GET_SERVICE_INFO = 0x9302u,
|
||||
MTP_OP_GET_SERVICE_CAPABILITIES = 0x9303u,
|
||||
MTP_OP_GET_SERVICE_PROP_DESC = 0x9304u,
|
||||
|
||||
// Appendix E: Enhanced Operations
|
||||
MTP_OP_GET_OBJECT_PROP_LIST = 0x9805u,
|
||||
MTP_OP_SET_OBJECT_PROP_LIST = 0x9806u,
|
||||
MTP_OP_GET_INTERDEPENDENT_PROP_DESC = 0x9807u,
|
||||
MTP_OP_SEND_OBJECT_PROP_LIST = 0x9808u,
|
||||
} mtp_operation_code_t;
|
||||
|
||||
// Appendix F: Responses
|
||||
typedef enum {
|
||||
MTP_RESP_UNDEFINED = 0x2000u,
|
||||
MTP_RESP_OK = 0x2001u,
|
||||
MTP_RESP_GENERAL_ERROR = 0x2002u,
|
||||
MTP_RESP_SESSION_NOT_OPEN = 0x2003u,
|
||||
MTP_RESP_INVALID_TRANSACTION_ID = 0x2004u,
|
||||
MTP_RESP_OPERATION_NOT_SUPPORTED = 0x2005u,
|
||||
MTP_RESP_PARAMETER_NOT_SUPPORTED = 0x2006u,
|
||||
MTP_RESP_INCOMPLETE_TRANSFER = 0x2007u,
|
||||
MTP_RESP_INVALID_STORAGE_ID = 0x2008u,
|
||||
MTP_RESP_INVALID_OBJECT_HANDLE = 0x2009u,
|
||||
MTP_RESP_DEVICE_PROP_NOT_SUPPORTED = 0x200Au,
|
||||
MTP_RESP_INVALID_OBJECT_FORMAT_CODE = 0x200Bu,
|
||||
MTP_RESP_STORE_FULL = 0x200Cu,
|
||||
MTP_RESP_OBJECT_WRITE_PROTECTED = 0x200Du,
|
||||
MPT_RESC_STORE_READ_ONLY = 0x200Eu,
|
||||
MTP_RESP_ACCESS_DENIED = 0x200Fu,
|
||||
MTP_RESP_NO_THUMBNAIL_PRESENT = 0x2010u,
|
||||
MTP_RESP_SELF_TEST_FAILED = 0x2011u,
|
||||
MTP_RESP_PARTIAL_DELETION = 0x2012u,
|
||||
MTP_RESP_STORE_NOT_AVAILABLE = 0x2013u,
|
||||
MTP_RESP_SPECIFICATION_BY_FORMAT_UNSUPPORTED = 0x2014u,
|
||||
MTP_RESP_NO_VALID_OBJECTINFO = 0x2015u,
|
||||
MTP_RESP_INVALID_CODE_FORMAT = 0x2016u,
|
||||
MTP_RESP_UNKNOWN_VENDOR_CODE = 0x2017u,
|
||||
MTP_RESP_CAPTURE_ALREADY_TERMINATED = 0x2018u,
|
||||
MTP_RESP_DEVICE_BUSY = 0x2019u,
|
||||
MTP_RESP_INVALID_PARENT_OBJECT = 0x201Au,
|
||||
MTP_RESP_INVALID_DEVICE_PROP_FORMAT = 0x201Bu,
|
||||
MTP_RESP_INVALID_DEVICE_PROP_VALUE = 0x201Cu,
|
||||
MTP_RESP_INVALID_PARAMETER = 0x201Du,
|
||||
MTP_RESP_SESSION_ALREADY_OPEN = 0x201Eu,
|
||||
MTP_RESP_TRANSACTION_CANCELLED = 0x201Fu,
|
||||
MTP_RESP_SPEC_OF_DESTINATION_UNSUPPORTED = 0x2020u,
|
||||
|
||||
MTP_RESP_INVALID_OBJECT_PROP_CODE = 0xA801u,
|
||||
MTP_RESP_INVALID_OBJECT_PROP_FORMAT = 0xA802u,
|
||||
MTP_RESP_INVALID_OBJECT_PROP_VALUE = 0xA803u,
|
||||
MTP_RESP_INVALID_OBJECT_REFERENCE = 0xA804u,
|
||||
MTP_RESP_GROUP_NOT_SUPPORTED = 0xA805u,
|
||||
MTP_RESP_INVALID_DATASET = 0xA806u,
|
||||
MTP_RESP_SPEC_BY_GROUP_UNSUPPORTED = 0xA807u,
|
||||
MTP_RESP_SPEC_BY_DEPTH_UNSUPPORTED = 0xA808u,
|
||||
MTP_RESP_OBJECT_TOO_LARGE = 0xA809u,
|
||||
MTP_RESP_OBJECT_PROP_NOT_SUPPORTED = 0xA80Au,
|
||||
} mtp_response_t;
|
||||
|
||||
// Appendix G: Events
|
||||
typedef enum {
|
||||
MTP_EVENT_UNDEFINED = 0x4000,
|
||||
MTP_EVENT_CANCEL_TRANSACTION = 0x4001,
|
||||
MTP_EVENT_OBJECT_ADDED = 0x4002,
|
||||
MTP_EVENT_OBJECT_REMOVED = 0x4003,
|
||||
MTP_EVENT_STORE_ADDED = 0x4004,
|
||||
MTP_EVENT_STORE_REMOVED = 0x4005,
|
||||
MTP_EVENT_DEVICE_PROP_CHANGED = 0x4006,
|
||||
MTP_EVENT_OBJECT_INFO_CHANGED = 0x4007,
|
||||
MTP_EVENT_DEVICE_INFO_CHANGED = 0x4008,
|
||||
MTP_EVENT_REQUEST_OBJECT_TRANSFER = 0x4009,
|
||||
MTP_EVENT_STORE_FULL = 0x400Au,
|
||||
MTP_EVENT_DEVICE_RESET = 0x400Bu,
|
||||
MTP_EVENT_STORAGE_INFO_CHANGED = 0x400Cu,
|
||||
MTP_EVENT_CAPTURE_COMPLETE = 0x400Du,
|
||||
MTP_EVENT_UNREPORTED_STATUS = 0x400Eu,
|
||||
MTP_EVENT_OBJECT_PROP_CHANGED = 0xC801u,
|
||||
MTP_EVENT_OBJECT_PROP_DESC_CHANGED = 0xC802u,
|
||||
MTP_EVENT_OBJECT_REFERENCES_CHANGED = 0xC803u,
|
||||
} mtp_event_code_t;
|
||||
|
||||
// Datatypes
|
||||
typedef enum {
|
||||
MTP_DATA_TYPE_UNDEFINED = 0x0000u,
|
||||
// scalars
|
||||
MTP_DATA_TYPE_INT8 = 0x0001u,
|
||||
MTP_DATA_TYPE_UINT8 = 0x0002u,
|
||||
MTP_DATA_TYPE_INT16 = 0x0003u,
|
||||
MTP_DATA_TYPE_UINT16 = 0x0004u,
|
||||
MTP_DATA_TYPE_INT32 = 0x0005u,
|
||||
MTP_DATA_TYPE_UINT32 = 0x0006u,
|
||||
MTP_DATA_TYPE_INT64 = 0x0007u,
|
||||
MTP_DATA_TYPE_UINT64 = 0x0008u,
|
||||
MTP_DATA_TYPE_INT128 = 0x0009u,
|
||||
MTP_DATA_TYPE_UINT128 = 0x000Au,
|
||||
// array
|
||||
MTP_DATA_TYPE_AINT8 = 0x4001u,
|
||||
MTP_DATA_TYPE_AUINT8 = 0x4002u,
|
||||
MTP_DATA_TYPE_AINT16 = 0x4003u,
|
||||
MTP_DATA_TYPE_AUINT16 = 0x4004u,
|
||||
MTP_DATA_TYPE_AINT32 = 0x4005u,
|
||||
MTP_DATA_TYPE_AUINT32 = 0x4006u,
|
||||
MTP_DATA_TYPE_AINT64 = 0x4007u,
|
||||
MTP_DATA_TYPE_AUINT64 = 0x4008u,
|
||||
MTP_DATA_TYPE_AINT128 = 0x4009u,
|
||||
MTP_DATA_TYPE_AUINT128 = 0x400Au,
|
||||
MTP_DATA_TYPE_STR = 0xFFFFu,
|
||||
} mtp_data_type_t;
|
||||
|
||||
// Get/Set
|
||||
typedef enum {
|
||||
MTP_MODE_GET = 0x00u,
|
||||
MTP_MODE_GET_SET = 0x01u,
|
||||
} mtp_mode_get_set_t;
|
||||
|
||||
typedef enum {
|
||||
MTP_STORAGE_TYPE_UNDEFINED = 0x0000u,
|
||||
MTP_STORAGE_TYPE_FIXED_ROM = 0x0001u,
|
||||
MTP_STORAGE_TYPE_REMOVABLE_ROM = 0x0002u,
|
||||
MTP_STORAGE_TYPE_FIXED_RAM = 0x0003u,
|
||||
MTP_STORAGE_TYPE_REMOVABLE_RAM = 0x0004u,
|
||||
} mtp_storage_type_t;
|
||||
|
||||
typedef enum {
|
||||
MTP_FILESYSTEM_TYPE_UNDEFINED = 0x0000u,
|
||||
MTP_FILESYSTEM_TYPE_GENERIC_FLAT = 0x0001u,
|
||||
MTP_FILESYSTEM_TYPE_GENERIC_HIERARCHICAL = 0x0002u,
|
||||
MTP_FILESYSTEM_TYPE_DCF = 0x0003u,
|
||||
} mtp_filesystem_type_t;
|
||||
|
||||
typedef enum {
|
||||
MTP_ACCESS_CAPABILITY_READ_WRITE = 0x0000u,
|
||||
MTP_ACCESS_CAPABILITY_READ_ONLY_WITHOUT_OBJECT_DELETION = 0x0001u,
|
||||
MTP_ACCESS_CAPABILITY_READ_ONLY_WITH_OBJECT_DELETION = 0x0002u,
|
||||
} mtp_access_capability_t;
|
||||
|
||||
typedef enum {
|
||||
MTP_PROTECTION_STATUS_NO_PROTECTION = 0x0000u,
|
||||
MTP_PROTECTION_STATUS_READ_ONLY = 0x0001u,
|
||||
MTP_PROTECTION_STATUS_READ_ONLY_DATA = 0x8002u,
|
||||
MTP_PROTECTION_NON_TRANSFERABLE_DATA = 0x8003u,
|
||||
} mtp_protection_status_t;
|
||||
|
||||
typedef enum {
|
||||
MTP_ASSOCIATION_UNDEFINED = 0x0000u,
|
||||
MTP_ASSOCIATION_GENERIC_FOLDER = 0x0001u,
|
||||
MTP_ASSOCIATION_ALBUM = 0x0002u,
|
||||
MTP_ASSOCIATION_TIME_SEQUENCE = 0x0003u,
|
||||
MTP_ASSOCIATION_HORIZONTAL_PANORAMIC = 0x0004u,
|
||||
MTP_ASSOCIATION_VERTICAL_PANORAMIC = 0x0005u,
|
||||
MTP_ASSOCIATION_2D_PANORAMIC = 0x0006u,
|
||||
MTP_ASSOCIATION_ANCILLARY_DATA = 0x0007u,
|
||||
} mtp_association_t;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Data structures
|
||||
//--------------------------------------------------------------------+
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint32_t len;
|
||||
uint16_t type;
|
||||
uint16_t code;
|
||||
uint32_t transaction_id;
|
||||
} mtp_container_header_t;
|
||||
TU_VERIFY_STATIC(sizeof(mtp_container_header_t) == 12, "size is not correct");
|
||||
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
mtp_container_header_t header;
|
||||
uint32_t params[5];
|
||||
} mtp_container_command_t;
|
||||
TU_VERIFY_STATIC(sizeof(mtp_container_command_t) == 32, "size is not correct");
|
||||
|
||||
// PTP/MTP Generic container
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
mtp_container_header_t header;
|
||||
uint8_t payload[(CFG_TUD_MTP_EP_BUFSIZE - sizeof(mtp_container_header_t))];
|
||||
} mtp_generic_container_t;
|
||||
|
||||
typedef struct {
|
||||
mtp_container_header_t* header;
|
||||
union {
|
||||
uint8_t* payload;
|
||||
uint16_t* payload16;
|
||||
uint32_t* payload32;
|
||||
};
|
||||
uint32_t payload_bytes; // available bytes for read/write
|
||||
} mtp_container_info_t;
|
||||
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint16_t code;
|
||||
uint32_t session_id;
|
||||
uint32_t transaction_id;
|
||||
uint32_t params[3];
|
||||
} mtp_event_t;
|
||||
TU_VERIFY_STATIC(sizeof(mtp_event_t) == 22, "size is not correct");
|
||||
|
||||
#define mtp_string_t(_nchars) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint8_t count; /* in characters including null */ \
|
||||
uint16_t utf16[_nchars]; \
|
||||
}
|
||||
|
||||
#define mtp_array_t(_type, _count) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint32_t count; \
|
||||
_type arr[_count];\
|
||||
}
|
||||
|
||||
#define mtp_aint8_t(_count) mtp_array_t(int8_t, _count)
|
||||
#define mtp_auint16_t(_count) mtp_array_t(uint16_t, _count)
|
||||
#define mtp_auint32_t(_count) mtp_array_t(uint32_t, _count)
|
||||
#define mtp_auint64_t(_count) mtp_array_t(uint64_t, _count)
|
||||
|
||||
#define MTP_STORAGE_INFO_STRUCT(_storage_desc_chars, _volume_id_chars) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint16_t storage_type; \
|
||||
uint16_t filesystem_type; \
|
||||
uint16_t access_capability; \
|
||||
uint64_t max_capacity_in_bytes; \
|
||||
uint64_t free_space_in_bytes; \
|
||||
uint32_t free_space_in_objects; \
|
||||
mtp_string_t(_storage_desc_chars) storage_description; \
|
||||
mtp_string_t(_volume_id_chars) volume_identifier; \
|
||||
}
|
||||
|
||||
// Object Info Dataset without dynamic string: filename, date_created, date_modified, keywords
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint32_t storage_id;
|
||||
uint16_t object_format;
|
||||
uint16_t protection_status;
|
||||
uint32_t object_compressed_size;
|
||||
uint16_t thumb_format;
|
||||
uint32_t thumb_compressed_size;
|
||||
uint32_t thumb_pix_width;
|
||||
uint32_t thumb_pix_height;
|
||||
uint32_t image_pix_width;
|
||||
uint32_t image_pix_height;
|
||||
uint32_t image_bit_depth;
|
||||
uint32_t parent_object; // 0: root
|
||||
uint16_t association_type;
|
||||
uint32_t association_desc;
|
||||
uint32_t sequence_number;
|
||||
// mtp_string_t() filename
|
||||
// mtp_string_t() date_created
|
||||
// mtp_string_t() date_modified
|
||||
// mtp_string_t() keywords
|
||||
} mtp_object_info_header_t;
|
||||
|
||||
// Device property desc up to get/set
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint16_t device_property_code;
|
||||
uint16_t datatype;
|
||||
uint8_t get_set;
|
||||
} mtp_device_prop_desc_header_t;
|
||||
|
||||
// The following fields will be dynamically added to the struct at runtime:
|
||||
// - wstring factory_def_value;
|
||||
// - wstring current_value_len;
|
||||
// - uint8_t form_flag;
|
||||
|
||||
// no form
|
||||
#define MTP_DEVICE_PROPERTIES_STRUCT(_type) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint16_t device_property_code; \
|
||||
uint16_t datatype; \
|
||||
uint8_t get_set; \
|
||||
_type factory_default; \
|
||||
_type current_value; \
|
||||
uint8_t form_flag; /* 0: none, 1: range, 2: enum */ \
|
||||
};
|
||||
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint16_t code;
|
||||
uint32_t transaction_id;
|
||||
} mtp_request_reset_cancel_data_t;
|
||||
TU_VERIFY_STATIC(sizeof(mtp_request_reset_cancel_data_t) == 6, "size is not correct");
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Container helper function
|
||||
// return number of bytes added
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// return payload buffer for next write
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t* mtp_container_payload_ptr(mtp_container_info_t* p_container) {
|
||||
// only 1st packet include header
|
||||
uint32_t pos = p_container->header->len - sizeof(mtp_container_header_t);
|
||||
while (pos > CFG_TUD_MTP_EP_BUFSIZE) {
|
||||
pos -= CFG_TUD_MTP_EP_BUFSIZE;
|
||||
}
|
||||
return p_container->payload + pos;
|
||||
}
|
||||
|
||||
// only add_raw does partial copy
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_raw(mtp_container_info_t* p_container, const void* data, uint32_t len) {
|
||||
uint8_t* buf = mtp_container_payload_ptr(p_container);
|
||||
const uint32_t added_len = tu_min32(len, CFG_TUD_MTP_EP_BUFSIZE - p_container->header->len);
|
||||
if (added_len > 0) {
|
||||
memcpy(buf, data, added_len);
|
||||
}
|
||||
p_container->header->len += len; // always increase len, even partial copy
|
||||
return added_len;
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_array(mtp_container_info_t* p_container, uint8_t scalar_size, uint32_t count, const void* data) {
|
||||
const uint32_t added_len = 4 + count * scalar_size;
|
||||
TU_ASSERT(p_container->header->len + added_len < CFG_TUD_MTP_EP_BUFSIZE, 0);
|
||||
uint8_t* buf = p_container->payload + p_container->header->len - sizeof(mtp_container_header_t);
|
||||
|
||||
tu_unaligned_write32(buf, count);
|
||||
p_container->header->len += 4;
|
||||
buf += 4;
|
||||
|
||||
memcpy(buf, data, count * scalar_size);
|
||||
p_container->header->len += count * scalar_size;
|
||||
|
||||
return added_len;
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_string(mtp_container_info_t* p_container, uint16_t* utf16) {
|
||||
uint8_t count = 0;
|
||||
while (utf16[count]) {
|
||||
count++;
|
||||
}
|
||||
const uint32_t added_len = 1u + 2u * count;
|
||||
TU_ASSERT(p_container->header->len + added_len < CFG_TUD_MTP_EP_BUFSIZE, 0);
|
||||
uint8_t* buf = p_container->payload + p_container->header->len - sizeof(mtp_container_header_t);
|
||||
|
||||
*buf++ = count;
|
||||
p_container->header->len++;
|
||||
|
||||
memcpy(buf, utf16, 2 * count);
|
||||
p_container->header->len += 2 * count;
|
||||
|
||||
return added_len;
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_cstring(mtp_container_info_t* p_container, const char* str) {
|
||||
const uint8_t len = (uint8_t) (strlen(str) + 1); // include null
|
||||
TU_ASSERT(p_container->header->len + 1 + 2 * len < CFG_TUD_MTP_EP_BUFSIZE, 0);
|
||||
uint8_t* buf = p_container->payload + p_container->header->len - sizeof(mtp_container_header_t);
|
||||
|
||||
if (len == 1) {
|
||||
// empty string (null only): single zero byte
|
||||
*buf = 0;
|
||||
p_container->header->len++;
|
||||
return 1;
|
||||
} else {
|
||||
*buf++ = len;
|
||||
p_container->header->len++;
|
||||
|
||||
for (uint8_t i = 0; i < len; i++) {
|
||||
buf[0] = str[i];
|
||||
buf[1] = 0;
|
||||
buf += 2;
|
||||
p_container->header->len += 2;
|
||||
}
|
||||
return 1u + 2u * len;
|
||||
}
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_uint8(mtp_container_info_t* p_container, uint8_t data) {
|
||||
return mtp_container_add_raw(p_container, &data, 1);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_uint16(mtp_container_info_t* p_container, uint16_t data) {
|
||||
return mtp_container_add_raw(p_container, &data, 2);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_uint32(mtp_container_info_t* p_container, uint32_t data) {
|
||||
return mtp_container_add_raw(p_container, &data, 4);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_uint64(mtp_container_info_t* p_container, uint64_t data) {
|
||||
return mtp_container_add_raw(p_container, &data, 8);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_uint128(mtp_container_info_t* p_container, const void* data) {
|
||||
return mtp_container_add_raw(p_container, data, 16);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_auint8(mtp_container_info_t* p_container, uint32_t count, const uint8_t* data) {
|
||||
return mtp_container_add_array(p_container, sizeof(uint8_t), count, data);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_auint16(mtp_container_info_t* p_container, uint32_t count, const uint16_t* data) {
|
||||
return mtp_container_add_array(p_container, sizeof(uint16_t), count, data);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_add_auint32(mtp_container_info_t* p_container, uint32_t count, const uint32_t* data) {
|
||||
return mtp_container_add_array(p_container, sizeof(uint32_t), count, data);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
//
|
||||
//--------------------------------------------------------------------+
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint32_t mtp_container_get_string(uint8_t* buf, uint16_t utf16[]) {
|
||||
uint8_t nchars = *buf++;
|
||||
memcpy(utf16, buf, 2 * nchars);
|
||||
return 1u + 2u * nchars;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
540
src/class/mtp/mtp_device.c
Normal file
540
src/class/mtp/mtp_device.c
Normal file
@ -0,0 +1,540 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2025 Ennebi Elettronica (https://ennebielettronica.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#include "tusb_option.h"
|
||||
|
||||
#if (CFG_TUD_ENABLED && CFG_TUD_MTP)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INCLUDE
|
||||
//--------------------------------------------------------------------+
|
||||
#include "device/dcd.h"
|
||||
#include "device/usbd.h"
|
||||
#include "device/usbd_pvt.h"
|
||||
|
||||
#include "mtp_device.h"
|
||||
|
||||
// Level where CFG_TUSB_DEBUG must be at least for this driver is logged
|
||||
#ifndef CFG_TUD_MTP_LOG_LEVEL
|
||||
#define CFG_TUD_MTP_LOG_LEVEL CFG_TUD_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#define TU_LOG_DRV(...) TU_LOG(CFG_TUD_MTP_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Weak stubs: invoked if no strong implementation is available
|
||||
//--------------------------------------------------------------------+
|
||||
TU_ATTR_WEAK bool tud_mtp_request_cancel_cb(tud_mtp_request_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return false;
|
||||
}
|
||||
TU_ATTR_WEAK bool tud_mtp_request_device_reset_cb(tud_mtp_request_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return false;
|
||||
}
|
||||
TU_ATTR_WEAK int32_t tud_mtp_request_get_extended_event_cb(tud_mtp_request_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return -1;
|
||||
}
|
||||
TU_ATTR_WEAK int32_t tud_mtp_request_get_device_status_cb(tud_mtp_request_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return -1;
|
||||
}
|
||||
TU_ATTR_WEAK bool tud_mtp_request_vendor_cb(tud_mtp_request_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return false;
|
||||
}
|
||||
TU_ATTR_WEAK int32_t tud_mtp_command_received_cb(tud_mtp_cb_data_t * cb_data) {
|
||||
(void) cb_data;
|
||||
return -1;
|
||||
}
|
||||
TU_ATTR_WEAK int32_t tud_mtp_data_xfer_cb(tud_mtp_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return -1;
|
||||
}
|
||||
TU_ATTR_WEAK int32_t tud_mtp_data_complete_cb(tud_mtp_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return -1;
|
||||
}
|
||||
TU_ATTR_WEAK int32_t tud_mtp_response_complete_cb(tud_mtp_cb_data_t* cb_data) {
|
||||
(void) cb_data;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// STRUCT
|
||||
//--------------------------------------------------------------------+
|
||||
typedef struct {
|
||||
uint8_t rhport;
|
||||
uint8_t itf_num;
|
||||
uint8_t ep_in;
|
||||
uint8_t ep_out;
|
||||
uint8_t ep_event;
|
||||
|
||||
// Bulk Only Transfer (BOT) Protocol
|
||||
uint8_t phase;
|
||||
|
||||
uint32_t total_len;
|
||||
uint32_t xferred_len;
|
||||
|
||||
uint32_t session_id;
|
||||
mtp_container_command_t command;
|
||||
mtp_container_header_t io_header;
|
||||
|
||||
TU_ATTR_ALIGNED(4) uint8_t control_buf[CFG_TUD_MTP_EP_CONTROL_BUFSIZE];
|
||||
} mtpd_interface_t;
|
||||
|
||||
typedef struct {
|
||||
TUD_EPBUF_DEF(buf, CFG_TUD_MTP_EP_BUFSIZE);
|
||||
TUD_EPBUF_TYPE_DEF(mtp_event_t, buf_event);
|
||||
} mtpd_epbuf_t;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
static mtpd_interface_t _mtpd_itf;
|
||||
CFG_TUD_MEM_SECTION static mtpd_epbuf_t _mtpd_epbuf;
|
||||
|
||||
static void preprocess_cmd(mtpd_interface_t* p_mtp, tud_mtp_cb_data_t* cb_data);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Debug
|
||||
//--------------------------------------------------------------------+
|
||||
#if CFG_TUSB_DEBUG >= CFG_TUD_MTP_LOG_LEVEL
|
||||
|
||||
TU_ATTR_UNUSED static tu_lookup_entry_t const _mpt_op_lookup[] = {
|
||||
{.key = MTP_OP_UNDEFINED , .data = "Undefined" } ,
|
||||
{.key = MTP_OP_GET_DEVICE_INFO , .data = "GetDeviceInfo" } ,
|
||||
{.key = MTP_OP_OPEN_SESSION , .data = "OpenSession" } ,
|
||||
{.key = MTP_OP_CLOSE_SESSION , .data = "CloseSession" } ,
|
||||
{.key = MTP_OP_GET_STORAGE_IDS , .data = "GetStorageIDs" } ,
|
||||
{.key = MTP_OP_GET_STORAGE_INFO , .data = "GetStorageInfo" } ,
|
||||
{.key = MTP_OP_GET_NUM_OBJECTS , .data = "GetNumObjects" } ,
|
||||
{.key = MTP_OP_GET_OBJECT_HANDLES , .data = "GetObjectHandles" } ,
|
||||
{.key = MTP_OP_GET_OBJECT_INFO , .data = "GetObjectInfo" } ,
|
||||
{.key = MTP_OP_GET_OBJECT , .data = "GetObject" } ,
|
||||
{.key = MTP_OP_GET_THUMB , .data = "GetThumb" } ,
|
||||
{.key = MTP_OP_DELETE_OBJECT , .data = "DeleteObject" } ,
|
||||
{.key = MTP_OP_SEND_OBJECT_INFO , .data = "SendObjectInfo" } ,
|
||||
{.key = MTP_OP_SEND_OBJECT , .data = "SendObject" } ,
|
||||
{.key = MTP_OP_INITIATE_CAPTURE , .data = "InitiateCapture" } ,
|
||||
{.key = MTP_OP_FORMAT_STORE , .data = "FormatStore" } ,
|
||||
{.key = MTP_OP_RESET_DEVICE , .data = "ResetDevice" } ,
|
||||
{.key = MTP_OP_SELF_TEST , .data = "SelfTest" } ,
|
||||
{.key = MTP_OP_SET_OBJECT_PROTECTION , .data = "SetObjectProtection" } ,
|
||||
{.key = MTP_OP_POWER_DOWN , .data = "PowerDown" } ,
|
||||
{.key = MTP_OP_GET_DEVICE_PROP_DESC , .data = "GetDevicePropDesc" } ,
|
||||
{.key = MTP_OP_GET_DEVICE_PROP_VALUE , .data = "GetDevicePropValue" } ,
|
||||
{.key = MTP_OP_SET_DEVICE_PROP_VALUE , .data = "SetDevicePropValue" } ,
|
||||
{.key = MTP_OP_RESET_DEVICE_PROP_VALUE , .data = "ResetDevicePropValue" } ,
|
||||
{.key = MTP_OP_TERMINATE_OPEN_CAPTURE , .data = "TerminateOpenCapture" } ,
|
||||
{.key = MTP_OP_MOVE_OBJECT , .data = "MoveObject" } ,
|
||||
{.key = MTP_OP_COPY_OBJECT , .data = "CopyObject" } ,
|
||||
{.key = MTP_OP_GET_PARTIAL_OBJECT , .data = "GetPartialObject" } ,
|
||||
{.key = MTP_OP_INITIATE_OPEN_CAPTURE , .data = "InitiateOpenCapture" } ,
|
||||
{.key = MTP_OP_GET_OBJECT_PROPS_SUPPORTED , .data = "GetObjectPropsSupported" } ,
|
||||
{.key = MTP_OP_GET_OBJECT_PROP_DESC , .data = "GetObjectPropDesc" } ,
|
||||
{.key = MTP_OP_GET_OBJECT_PROP_VALUE , .data = "GetObjectPropValue" } ,
|
||||
{.key = MTP_OP_SET_OBJECT_PROP_VALUE , .data = "SetObjectPropValue" } ,
|
||||
{.key = MTP_OP_GET_OBJECT_PROPLIST , .data = "GetObjectPropList" } ,
|
||||
{.key = MTP_OP_GET_OBJECT_PROP_REFERENCES , .data = "GetObjectPropReferences" } ,
|
||||
{.key = MTP_OP_GET_SERVICE_IDS , .data = "GetServiceIDs" } ,
|
||||
{.key = MTP_OP_GET_SERVICE_INFO , .data = "GetServiceInfo" } ,
|
||||
{.key = MTP_OP_GET_SERVICE_CAPABILITIES , .data = "GetServiceCapabilities" } ,
|
||||
{.key = MTP_OP_GET_SERVICE_PROP_DESC , .data = "GetServicePropDesc" } ,
|
||||
{.key = MTP_OP_GET_OBJECT_PROP_LIST , .data = "GetObjectPropList" } ,
|
||||
{.key = MTP_OP_SET_OBJECT_PROP_LIST , .data = "SetObjectPropList" } ,
|
||||
{.key = MTP_OP_GET_INTERDEPENDENT_PROP_DESC , .data = "GetInterdependentPropDesc" } ,
|
||||
{.key = MTP_OP_SEND_OBJECT_PROP_LIST , .data = "SendObjectPropList" }
|
||||
};
|
||||
|
||||
TU_ATTR_UNUSED static tu_lookup_table_t const _mtp_op_table = {
|
||||
.count = TU_ARRAY_SIZE(_mpt_op_lookup),
|
||||
.items = _mpt_op_lookup
|
||||
};
|
||||
|
||||
TU_ATTR_UNUSED static const char* _mtp_phase_str[] = {
|
||||
"Command",
|
||||
"Data",
|
||||
"Response",
|
||||
"Error"
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Helper
|
||||
//--------------------------------------------------------------------+
|
||||
static bool prepare_new_command(mtpd_interface_t* p_mtp) {
|
||||
p_mtp->phase = MTP_PHASE_COMMAND;
|
||||
return usbd_edpt_xfer(p_mtp->rhport, p_mtp->ep_out, _mtpd_epbuf.buf, CFG_TUD_MTP_EP_BUFSIZE);
|
||||
}
|
||||
|
||||
static bool mtpd_data_xfer(mtp_container_info_t* p_container, uint8_t ep_addr) {
|
||||
mtpd_interface_t* p_mtp = &_mtpd_itf;
|
||||
if (p_mtp->phase == MTP_PHASE_COMMAND) {
|
||||
// 1st data block: header + payload
|
||||
p_mtp->phase = MTP_PHASE_DATA;
|
||||
p_mtp->xferred_len = 0;
|
||||
|
||||
if (tu_edpt_dir(ep_addr) == TUSB_DIR_IN) {
|
||||
p_mtp->total_len = p_container->header->len;
|
||||
p_container->header->type = MTP_CONTAINER_TYPE_DATA_BLOCK;
|
||||
p_container->header->transaction_id = p_mtp->command.header.transaction_id;
|
||||
p_mtp->io_header = *p_container->header; // save header for subsequent data
|
||||
} else {
|
||||
// OUT transfer: total length is at least max packet size
|
||||
p_mtp->total_len = tu_max32(p_container->header->len, CFG_TUD_MTP_EP_BUFSIZE);
|
||||
}
|
||||
} else {
|
||||
// subsequent data block: payload only
|
||||
TU_ASSERT(p_mtp->phase == MTP_PHASE_DATA);
|
||||
}
|
||||
|
||||
const uint16_t xact_len = tu_min16((uint16_t) (p_mtp->total_len - p_mtp->xferred_len), CFG_TUD_MTP_EP_BUFSIZE);
|
||||
if (xact_len) {
|
||||
// already transferred all bytes in header's length. Application make an unnecessary extra call
|
||||
TU_VERIFY(usbd_edpt_claim(p_mtp->rhport, ep_addr));
|
||||
TU_ASSERT(usbd_edpt_xfer(p_mtp->rhport, ep_addr, _mtpd_epbuf.buf, xact_len));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tud_mtp_data_send(mtp_container_info_t* p_container) {
|
||||
return mtpd_data_xfer(p_container, _mtpd_itf.ep_in);
|
||||
}
|
||||
|
||||
bool tud_mtp_data_receive(mtp_container_info_t* p_container) {
|
||||
return mtpd_data_xfer(p_container, _mtpd_itf.ep_out);
|
||||
}
|
||||
|
||||
bool tud_mtp_response_send(mtp_container_info_t* p_container) {
|
||||
mtpd_interface_t* p_mtp = &_mtpd_itf;
|
||||
p_mtp->phase = MTP_PHASE_RESPONSE;
|
||||
p_container->header->type = MTP_CONTAINER_TYPE_RESPONSE_BLOCK;
|
||||
p_container->header->transaction_id = p_mtp->command.header.transaction_id;
|
||||
TU_VERIFY(usbd_edpt_claim(p_mtp->rhport, p_mtp->ep_in));
|
||||
return usbd_edpt_xfer(p_mtp->rhport, p_mtp->ep_in, _mtpd_epbuf.buf, (uint16_t)p_container->header->len);
|
||||
}
|
||||
|
||||
bool tud_mtp_mounted(void) {
|
||||
mtpd_interface_t* p_mtp = &_mtpd_itf;
|
||||
return p_mtp->ep_out != 0 && p_mtp->ep_in != 0;
|
||||
}
|
||||
|
||||
bool tud_mtp_event_send(mtp_event_t* event) {
|
||||
mtpd_interface_t* p_mtp = &_mtpd_itf;
|
||||
TU_VERIFY(p_mtp->ep_event != 0);
|
||||
_mtpd_epbuf.buf_event = *event;
|
||||
TU_VERIFY(usbd_edpt_claim(p_mtp->rhport, p_mtp->ep_event)); // Claim the endpoint
|
||||
return usbd_edpt_xfer(p_mtp->rhport, p_mtp->ep_event, (uint8_t*) &_mtpd_epbuf.buf_event, sizeof(mtp_event_t));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBD Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void mtpd_init(void) {
|
||||
tu_memclr(&_mtpd_itf, sizeof(mtpd_interface_t));
|
||||
}
|
||||
|
||||
bool mtpd_deinit(void) {
|
||||
return true; // nothing to do
|
||||
}
|
||||
|
||||
void mtpd_reset(uint8_t rhport) {
|
||||
(void) rhport;
|
||||
tu_memclr(&_mtpd_itf, sizeof(mtpd_interface_t));
|
||||
}
|
||||
|
||||
uint16_t mtpd_open(uint8_t rhport, tusb_desc_interface_t const* itf_desc, uint16_t max_len) {
|
||||
// only support PIMA 15470 protocol
|
||||
TU_VERIFY(TUSB_CLASS_IMAGE == itf_desc->bInterfaceClass &&
|
||||
MTP_SUBCLASS_STILL_IMAGE == itf_desc->bInterfaceSubClass &&
|
||||
MTP_PROTOCOL_PIMA_15470 == itf_desc->bInterfaceProtocol, 0);
|
||||
|
||||
// mtp driver length is fixed
|
||||
const uint16_t mtpd_itf_size = sizeof(tusb_desc_interface_t) + 3 * sizeof(tusb_desc_endpoint_t);
|
||||
|
||||
// Max length must be at least 1 interface + 3 endpoints
|
||||
TU_ASSERT(itf_desc->bNumEndpoints == 3 && max_len >= mtpd_itf_size);
|
||||
mtpd_interface_t* p_mtp = &_mtpd_itf;
|
||||
tu_memclr(p_mtp, sizeof(mtpd_interface_t));
|
||||
p_mtp->rhport = rhport;
|
||||
p_mtp->itf_num = itf_desc->bInterfaceNumber;
|
||||
|
||||
// Open interrupt IN endpoint
|
||||
const tusb_desc_endpoint_t* ep_desc = (const tusb_desc_endpoint_t*) tu_desc_next(itf_desc);
|
||||
TU_ASSERT(ep_desc->bDescriptorType == TUSB_DESC_ENDPOINT && ep_desc->bmAttributes.xfer == TUSB_XFER_INTERRUPT, 0);
|
||||
TU_ASSERT(usbd_edpt_open(rhport, ep_desc), 0);
|
||||
p_mtp->ep_event = ep_desc->bEndpointAddress;
|
||||
|
||||
// Open endpoint pair
|
||||
TU_ASSERT(usbd_open_edpt_pair(rhport, tu_desc_next(ep_desc), 2, TUSB_XFER_BULK, &p_mtp->ep_out, &p_mtp->ep_in), 0);
|
||||
TU_ASSERT(prepare_new_command(p_mtp), 0);
|
||||
|
||||
return mtpd_itf_size;
|
||||
}
|
||||
|
||||
// Invoked when a control transfer occurred on an interface of this class
|
||||
// Driver response accordingly to the request and the transfer stage (setup/data/ack)
|
||||
// return false to stall control endpoint (e.g unsupported request)
|
||||
bool mtpd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const* request) {
|
||||
mtpd_interface_t* p_mtp = &_mtpd_itf;
|
||||
tud_mtp_request_cb_data_t cb_data = {
|
||||
.idx = 0,
|
||||
.stage = stage,
|
||||
.session_id = p_mtp->session_id,
|
||||
.request = request,
|
||||
.buf = p_mtp->control_buf,
|
||||
.bufsize = tu_le16toh(request->wLength),
|
||||
};
|
||||
|
||||
switch (request->bRequest) {
|
||||
case MTP_REQ_CANCEL:
|
||||
TU_LOG_DRV(" MTP request: Cancel\n");
|
||||
if (stage == CONTROL_STAGE_SETUP) {
|
||||
return tud_control_xfer(rhport, request, p_mtp->control_buf, CFG_TUD_MTP_EP_CONTROL_BUFSIZE);
|
||||
} else if (stage == CONTROL_STAGE_ACK) {
|
||||
return tud_mtp_request_cancel_cb(&cb_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case MTP_REQ_GET_EXT_EVENT_DATA:
|
||||
TU_LOG_DRV(" MTP request: Get Extended Event Data\n");
|
||||
if (stage == CONTROL_STAGE_SETUP) {
|
||||
const int32_t len = tud_mtp_request_get_extended_event_cb(&cb_data);
|
||||
TU_VERIFY(len > 0);
|
||||
return tud_control_xfer(rhport,request, p_mtp->control_buf, (uint16_t) len);
|
||||
}
|
||||
break;
|
||||
|
||||
case MTP_REQ_RESET:
|
||||
TU_LOG_DRV(" MTP request: Device Reset\n");
|
||||
// used by the host to return the Still Image Capture Device to the Idle state after the Bulk-pipe has stalled
|
||||
if (stage == CONTROL_STAGE_SETUP) {
|
||||
// clear stalled
|
||||
if (usbd_edpt_stalled(rhport, p_mtp->ep_out)) {
|
||||
usbd_edpt_clear_stall(rhport, p_mtp->ep_out);
|
||||
}
|
||||
if (usbd_edpt_stalled(rhport, p_mtp->ep_in)) {
|
||||
usbd_edpt_clear_stall(rhport, p_mtp->ep_in);
|
||||
}
|
||||
} else if (stage == CONTROL_STAGE_ACK) {
|
||||
prepare_new_command(p_mtp);
|
||||
return tud_mtp_request_device_reset_cb(&cb_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case MTP_REQ_GET_DEVICE_STATUS: {
|
||||
TU_LOG_DRV(" MTP request: Get Device Status\n");
|
||||
if (stage == CONTROL_STAGE_SETUP) {
|
||||
const int32_t len = tud_mtp_request_get_device_status_cb(&cb_data);
|
||||
TU_VERIFY(len > 0);
|
||||
return tud_control_xfer(rhport, request, p_mtp->control_buf, (uint16_t) len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return tud_mtp_request_vendor_cb(&cb_data);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Transfer on bulk endpoints
|
||||
bool mtpd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes) {
|
||||
if (ep_addr == _mtpd_itf.ep_event) {
|
||||
// nothing to do
|
||||
return true;
|
||||
}
|
||||
|
||||
mtpd_interface_t* p_mtp = &_mtpd_itf;
|
||||
mtp_generic_container_t* p_container = (mtp_generic_container_t*) _mtpd_epbuf.buf;
|
||||
|
||||
#if CFG_TUSB_DEBUG >= CFG_TUD_MTP_LOG_LEVEL
|
||||
tu_lookup_find(&_mtp_op_table, p_mtp->command.header.code);
|
||||
TU_LOG_DRV(" MTP %s: %s phase\r\n", (const char *) tu_lookup_find(&_mtp_op_table, p_mtp->command.header.code),
|
||||
_mtp_phase_str[p_mtp->phase]);
|
||||
#endif
|
||||
|
||||
const mtp_container_info_t headered_packet = {
|
||||
.header = &p_container->header,
|
||||
.payload = p_container->payload,
|
||||
.payload_bytes = CFG_TUD_MTP_EP_BUFSIZE - sizeof(mtp_container_header_t)
|
||||
};
|
||||
|
||||
const mtp_container_info_t headerless_packet = {
|
||||
.header = &p_mtp->io_header,
|
||||
.payload = _mtpd_epbuf.buf,
|
||||
.payload_bytes = CFG_TUD_MTP_EP_BUFSIZE
|
||||
};
|
||||
|
||||
tud_mtp_cb_data_t cb_data;
|
||||
cb_data.idx = 0;
|
||||
cb_data.phase = p_mtp->phase;
|
||||
cb_data.session_id = p_mtp->session_id;
|
||||
cb_data.command_container = &p_mtp->command;
|
||||
cb_data.io_container = headered_packet;
|
||||
cb_data.total_xferred_bytes = 0;
|
||||
cb_data.xfer_result = event;
|
||||
|
||||
switch (p_mtp->phase) {
|
||||
case MTP_PHASE_COMMAND: {
|
||||
// received new command
|
||||
TU_VERIFY(ep_addr == p_mtp->ep_out && p_container->header.type == MTP_CONTAINER_TYPE_COMMAND_BLOCK);
|
||||
memcpy(&p_mtp->command, p_container, sizeof(mtp_container_command_t)); // save new command
|
||||
p_container->header.len = sizeof(mtp_container_header_t); // default container to header only
|
||||
preprocess_cmd(p_mtp, &cb_data);
|
||||
if (tud_mtp_command_received_cb(&cb_data) < 0) {
|
||||
p_mtp->phase = MTP_PHASE_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MTP_PHASE_DATA: {
|
||||
const uint16_t bulk_mps = (tud_speed_get() == TUSB_SPEED_HIGH) ? 512 : 64;
|
||||
p_mtp->xferred_len += xferred_bytes;
|
||||
cb_data.total_xferred_bytes = p_mtp->xferred_len;
|
||||
|
||||
bool is_complete = false;
|
||||
// complete if ZLP or short packet or overflow
|
||||
if (xferred_bytes == 0 || // ZLP
|
||||
(xferred_bytes & (bulk_mps - 1)) || // short packet
|
||||
p_mtp->xferred_len > p_mtp->total_len) {
|
||||
is_complete = true;
|
||||
}
|
||||
|
||||
if (ep_addr == p_mtp->ep_in) {
|
||||
// Data In
|
||||
if (is_complete) {
|
||||
cb_data.io_container.header->len = sizeof(mtp_container_header_t);
|
||||
tud_mtp_data_complete_cb(&cb_data);
|
||||
} else {
|
||||
// 2nd+ packet: payload only
|
||||
cb_data.io_container = headerless_packet;
|
||||
tud_mtp_data_xfer_cb(&cb_data);
|
||||
}
|
||||
} else {
|
||||
// Data Out
|
||||
if (p_mtp->xferred_len == xferred_bytes) {
|
||||
// 1st OUT packet: header + payload
|
||||
p_mtp->io_header = p_container->header; // save header for subsequent transaction
|
||||
cb_data.io_container.payload_bytes = xferred_bytes - sizeof(mtp_container_header_t);
|
||||
} else {
|
||||
// 2nd+ packet: payload only
|
||||
cb_data.io_container = headerless_packet;
|
||||
cb_data.io_container.payload_bytes = xferred_bytes;
|
||||
}
|
||||
tud_mtp_data_xfer_cb(&cb_data);
|
||||
|
||||
if (is_complete) {
|
||||
// back to header + payload for response
|
||||
cb_data.io_container = headered_packet;
|
||||
cb_data.io_container.header->len = sizeof(mtp_container_header_t);
|
||||
tud_mtp_data_complete_cb(&cb_data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MTP_PHASE_RESPONSE:
|
||||
// response phase is complete -> prepare for new command
|
||||
TU_ASSERT(ep_addr == p_mtp->ep_in);
|
||||
tud_mtp_response_complete_cb(&cb_data);
|
||||
prepare_new_command(p_mtp);
|
||||
break;
|
||||
|
||||
case MTP_PHASE_ERROR:
|
||||
// handled after switch, supposedly to be empty
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
if (p_mtp->phase == MTP_PHASE_ERROR) {
|
||||
// stall both IN & OUT endpoints
|
||||
usbd_edpt_stall(rhport, p_mtp->ep_out);
|
||||
usbd_edpt_stall(rhport, p_mtp->ep_in);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MTPD Internal functionality
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// pre-processed commands
|
||||
void preprocess_cmd(mtpd_interface_t* p_mtp, tud_mtp_cb_data_t* cb_data) {
|
||||
switch (p_mtp->command.header.code) {
|
||||
case MTP_OP_GET_DEVICE_INFO: {
|
||||
tud_mtp_device_info_t dev_info = {
|
||||
.standard_version = 100,
|
||||
.mtp_vendor_extension_id = 6, // MTP specs say 0xFFFFFFFF but libMTP check for value 6
|
||||
.mtp_version = 100,
|
||||
.mtp_extensions = {
|
||||
.count = sizeof(CFG_TUD_MTP_DEVICEINFO_EXTENSIONS),
|
||||
.utf16 = { 0 }
|
||||
},
|
||||
.functional_mode = 0x0000,
|
||||
.supported_operations = {
|
||||
.count = TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_SUPPORTED_OPERATIONS),
|
||||
.arr = { CFG_TUD_MTP_DEVICEINFO_SUPPORTED_OPERATIONS }
|
||||
},
|
||||
.supported_events = {
|
||||
.count = TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_SUPPORTED_EVENTS),
|
||||
.arr = { CFG_TUD_MTP_DEVICEINFO_SUPPORTED_EVENTS }
|
||||
},
|
||||
.supported_device_properties = {
|
||||
.count = TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_SUPPORTED_DEVICE_PROPERTIES),
|
||||
.arr = { CFG_TUD_MTP_DEVICEINFO_SUPPORTED_DEVICE_PROPERTIES }
|
||||
},
|
||||
.capture_formats = {
|
||||
.count = TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_CAPTURE_FORMATS),
|
||||
.arr = { CFG_TUD_MTP_DEVICEINFO_CAPTURE_FORMATS }
|
||||
},
|
||||
.playback_formats = {
|
||||
.count = TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_PLAYBACK_FORMATS),
|
||||
.arr = { CFG_TUD_MTP_DEVICEINFO_PLAYBACK_FORMATS }
|
||||
}
|
||||
};
|
||||
|
||||
for (uint8_t i=0; i < dev_info.mtp_extensions.count; i++) {
|
||||
dev_info.mtp_extensions.utf16[i] = (uint16_t)CFG_TUD_MTP_DEVICEINFO_EXTENSIONS[i];
|
||||
}
|
||||
|
||||
mtp_container_add_raw(&cb_data->io_container, &dev_info, sizeof(tud_mtp_device_info_t));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
167
src/class/mtp/mtp_device.h
Normal file
167
src/class/mtp/mtp_device.h
Normal file
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2025 Ennebi Elettronica (https://ennebielettronica.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN0
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#ifndef TUSB_MTP_DEVICE_H_
|
||||
#define TUSB_MTP_DEVICE_H_
|
||||
|
||||
#include "common/tusb_common.h"
|
||||
#include "mtp.h"
|
||||
|
||||
#if (CFG_TUD_ENABLED && CFG_TUD_MTP)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// callback data for Bulk Only Transfer (BOT) protocol
|
||||
typedef struct {
|
||||
uint8_t idx; // mtp instance
|
||||
uint8_t phase; // current phase
|
||||
uint32_t session_id;
|
||||
|
||||
const mtp_container_command_t* command_container;
|
||||
mtp_container_info_t io_container;
|
||||
|
||||
tusb_xfer_result_t xfer_result;
|
||||
uint32_t total_xferred_bytes; // number of bytes transferred so far in this phase
|
||||
} tud_mtp_cb_data_t;
|
||||
|
||||
// callback data for Control requests
|
||||
typedef struct {
|
||||
uint8_t idx;
|
||||
uint8_t stage; // control stage
|
||||
uint32_t session_id;
|
||||
|
||||
const tusb_control_request_t* request;
|
||||
// buffer for data stage
|
||||
uint8_t* buf;
|
||||
uint16_t bufsize;
|
||||
} tud_mtp_request_cb_data_t;
|
||||
|
||||
// Number of supported operations, events, device properties, capture formats, playback formats
|
||||
// and max number of characters for strings manufacturer, model, device_version, serial_number
|
||||
#define MTP_DEVICE_INFO_STRUCT(_extension_nchars, _op_count, _event_count, _devprop_count, _capture_count, _playback_count) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint16_t standard_version; \
|
||||
uint32_t mtp_vendor_extension_id; \
|
||||
uint16_t mtp_version; \
|
||||
mtp_string_t(_extension_nchars) mtp_extensions; \
|
||||
uint16_t functional_mode; \
|
||||
mtp_auint16_t(_op_count) supported_operations; \
|
||||
mtp_auint16_t(_event_count) supported_events; \
|
||||
mtp_auint16_t(_devprop_count) supported_device_properties; \
|
||||
mtp_auint16_t(_capture_count) capture_formats; \
|
||||
mtp_auint16_t(_playback_count) playback_formats; \
|
||||
/* string fields will be added using append function */ \
|
||||
}
|
||||
|
||||
typedef MTP_DEVICE_INFO_STRUCT(
|
||||
sizeof(CFG_TUD_MTP_DEVICEINFO_EXTENSIONS), TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_SUPPORTED_OPERATIONS),
|
||||
TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_SUPPORTED_EVENTS), TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_SUPPORTED_DEVICE_PROPERTIES),
|
||||
TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_CAPTURE_FORMATS), TU_ARGS_NUM(CFG_TUD_MTP_DEVICEINFO_PLAYBACK_FORMATS)
|
||||
) tud_mtp_device_info_t;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// check if mtp interface is mounted
|
||||
bool tud_mtp_mounted(void);
|
||||
|
||||
// send data phase
|
||||
bool tud_mtp_data_send(mtp_container_info_t* p_container);
|
||||
|
||||
// receive data phase
|
||||
bool tud_mtp_data_receive(mtp_container_info_t* p_container);
|
||||
|
||||
// send response
|
||||
bool tud_mtp_response_send(mtp_container_info_t* p_container);
|
||||
|
||||
// send event notification on event endpoint
|
||||
bool tud_mtp_event_send(mtp_event_t* event);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Control request Callbacks
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invoked when received Cancel request. Data is available in callback data's buffer
|
||||
// return false to stall the request
|
||||
bool tud_mtp_request_cancel_cb(tud_mtp_request_cb_data_t* cb_data);
|
||||
|
||||
// Invoked when received Device Reset request
|
||||
// return false to stall the request
|
||||
bool tud_mtp_request_device_reset_cb(tud_mtp_request_cb_data_t* cb_data);
|
||||
|
||||
// Invoked when received Get Extended Event request. Application fill callback data's buffer for response
|
||||
// return negative to stall the request
|
||||
int32_t tud_mtp_request_get_extended_event_cb(tud_mtp_request_cb_data_t* cb_data);
|
||||
|
||||
// Invoked when received Get DeviceStatus request. Application fill callback data's buffer for response
|
||||
// return negative to stall the request
|
||||
int32_t tud_mtp_request_get_device_status_cb(tud_mtp_request_cb_data_t* cb_data);
|
||||
|
||||
// Invoked when received vendor-specific request not in the above standard MTP requests
|
||||
// return false to stall the request
|
||||
bool tud_mtp_request_vendor_cb(tud_mtp_request_cb_data_t* cb_data);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Bulk only protocol Callbacks
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invoked when new command is received. Application fill the cb_data->io_container and call tud_mtp_data_send() or
|
||||
// tud_mtp_response_send() for Data or Response phase.
|
||||
// Return negative to stall the endpoints
|
||||
int32_t tud_mtp_command_received_cb(tud_mtp_cb_data_t * cb_data);
|
||||
|
||||
// Invoked when a data packet is transferred. If data spans over multiple packets, application can use
|
||||
// total_xferred_bytes and io_container's payload_bytes to determine the offset and remaining bytes to be transferred.
|
||||
// Return negative to stall the endpoints
|
||||
int32_t tud_mtp_data_xfer_cb(tud_mtp_cb_data_t* cb_data);
|
||||
|
||||
// Invoked when all bytes in DATA phase is complete. A response packet is expected
|
||||
// Return negative to stall the endpoints
|
||||
int32_t tud_mtp_data_complete_cb(tud_mtp_cb_data_t* cb_data);
|
||||
|
||||
// Invoked when response phase is complete
|
||||
// Return negative to stall the endpoints
|
||||
int32_t tud_mtp_response_complete_cb(tud_mtp_cb_data_t* cb_data);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void mtpd_init (void);
|
||||
bool mtpd_deinit (void);
|
||||
void mtpd_reset (uint8_t rhport);
|
||||
uint16_t mtpd_open (uint8_t rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len);
|
||||
bool mtpd_control_xfer_cb (uint8_t rhport, uint8_t stage, tusb_control_request_t const *p_request);
|
||||
bool mtpd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -35,6 +35,7 @@
|
||||
// Macros Helper
|
||||
//--------------------------------------------------------------------+
|
||||
#define TU_ARRAY_SIZE(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
|
||||
#define TU_FIELD_SZIE(_type, _field) (sizeof(((_type *)0)->_field))
|
||||
#define TU_MIN(_x, _y) ( ( (_x) < (_y) ) ? (_x) : (_y) )
|
||||
#define TU_MAX(_x, _y) ( ( (_x) > (_y) ) ? (_x) : (_y) )
|
||||
#define TU_DIV_CEIL(n, d) (((n) + (d) - 1) / (d))
|
||||
|
||||
@ -321,6 +321,20 @@ tu_static usbd_class_driver_t const _usbd_driver[] = {
|
||||
.sof = NULL
|
||||
},
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_MTP
|
||||
{
|
||||
.name = DRIVER_NAME("MTP"),
|
||||
.init = mtpd_init,
|
||||
.deinit = mtpd_deinit,
|
||||
.reset = mtpd_reset,
|
||||
.open = mtpd_open,
|
||||
.control_xfer_cb = mtpd_control_xfer_cb,
|
||||
.xfer_cb = mtpd_xfer_cb,
|
||||
.xfer_isr = NULL,
|
||||
.sof = NULL
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
enum { BUILTIN_DRIVER_COUNT = TU_ARRAY_SIZE(_usbd_driver) };
|
||||
|
||||
@ -269,6 +269,25 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
|
||||
7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MTP Descriptor Templates
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Length of template descriptor: 30 bytes
|
||||
#define TUD_MTP_DESC_LEN (9 + 7 + 7 + 7)
|
||||
|
||||
// Interface number, string index, EP event, EP event size, EP event polling, EP Out & EP In address, EP size
|
||||
#define TUD_MTP_DESCRIPTOR(_itfnum, _stridx, _ep_evt, _ep_evt_size, _ep_evt_polling_interval, _epout, _epin, _epsize) \
|
||||
/* Interface */\
|
||||
9, TUSB_DESC_INTERFACE, _itfnum, 0, 3, TUSB_CLASS_IMAGE, MTP_SUBCLASS_STILL_IMAGE, MTP_PROTOCOL_PIMA_15470, _stridx,\
|
||||
/* Endpoint Interrupt */\
|
||||
7, TUSB_DESC_ENDPOINT, _ep_evt, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_ep_evt_size), _ep_evt_polling_interval,\
|
||||
/* Endpoint Out */\
|
||||
7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0,\
|
||||
/* Endpoint In */\
|
||||
7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// HID Descriptor Templates
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@ -678,6 +678,7 @@ bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet
|
||||
btable_set_addr(ep_idx, 1, pma_addr2);
|
||||
#else
|
||||
btable_set_addr(ep_idx, dir == TUSB_DIR_IN ? BTABLE_BUF_TX : BTABLE_BUF_RX, pma_addr);
|
||||
(void) pma_addr2;
|
||||
#endif
|
||||
|
||||
xfer_ctl_t* xfer = xfer_ctl_ptr(ep_num, dir);
|
||||
|
||||
@ -200,8 +200,10 @@
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32U0
|
||||
#include "stm32u0xx.h"
|
||||
#define FSDEV_PMA_SIZE (2048u)
|
||||
#define FSDEV_HAS_SBUF_ISO 1
|
||||
#define FSDEV_PMA_SIZE (1024u)
|
||||
#define FSDEV_BUS_32BIT
|
||||
// Disable SBUF_ISO on U0 for now due to bad performance (audio glitching)
|
||||
#define FSDEV_HAS_SBUF_ISO 0
|
||||
#define USB USB_DRD_FS
|
||||
|
||||
#define USB_EP_CTR_RX USB_EP_VTRX
|
||||
|
||||
@ -12,6 +12,7 @@ TINYUSB_SRC_C += \
|
||||
src/class/hid/hid_device.c \
|
||||
src/class/midi/midi_device.c \
|
||||
src/class/msc/msc_device.c \
|
||||
src/class/mtp/mtp_device.c \
|
||||
src/class/net/ecm_rndis_device.c \
|
||||
src/class/net/ncm_device.c \
|
||||
src/class/usbtmc/usbtmc_device.c \
|
||||
|
||||
@ -88,6 +88,10 @@
|
||||
#include "class/msc/msc_device.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_MTP
|
||||
#include "class/mtp/mtp_device.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO
|
||||
#include "class/audio/audio_device.h"
|
||||
#endif
|
||||
|
||||
@ -517,6 +517,10 @@
|
||||
#define CFG_TUD_MSC 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_MTP
|
||||
#define CFG_TUD_MTP 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_HID
|
||||
#define CFG_TUD_HID 0
|
||||
#endif
|
||||
|
||||
@ -148,7 +148,7 @@ uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) {
|
||||
(void)index; // for multiple configurations
|
||||
|
||||
// if link speed is high return fullspeed config, and vice versa
|
||||
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
|
||||
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
|
||||
memcpy(desc_other_speed_config,
|
||||
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration
|
||||
: desc_hs_configuration,
|
||||
|
||||
@ -142,7 +142,7 @@ uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) {
|
||||
(void)index; // for multiple configurations
|
||||
|
||||
// if link speed is high return fullspeed config, and vice versa
|
||||
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
|
||||
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
|
||||
memcpy(desc_other_speed_config,
|
||||
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration
|
||||
: desc_hs_configuration,
|
||||
|
||||
@ -148,7 +148,7 @@ uint8_t const *tud_descriptor_other_speed_configuration_cb(uint8_t index) {
|
||||
(void)index; // for multiple configurations
|
||||
|
||||
// if link speed is high return fullspeed config, and vice versa
|
||||
// Note: the descriptor type is OHER_SPEED_CONFIG instead of CONFIG
|
||||
// Note: the descriptor type is OTHER_SPEED_CONFIG instead of CONFIG
|
||||
memcpy(desc_other_speed_config,
|
||||
(tud_speed_get() == TUSB_SPEED_HIGH) ? desc_fs_configuration
|
||||
: desc_hs_configuration,
|
||||
|
||||
@ -31,6 +31,7 @@ SRC_C += \
|
||||
src/class/hid/hid_device.c \
|
||||
src/class/midi/midi_device.c \
|
||||
src/class/msc/msc_device.c \
|
||||
src/class/mtp/mtp_device.c \
|
||||
src/class/net/ecm_rndis_device.c \
|
||||
src/class/net/ncm_device.c \
|
||||
src/class/usbtmc/usbtmc_device.c \
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
@ -37,6 +38,9 @@ import json
|
||||
import glob
|
||||
from multiprocessing import Pool
|
||||
import fs
|
||||
import hashlib
|
||||
import ctypes
|
||||
from pymtp import MTP
|
||||
|
||||
ENUM_TIMEOUT = 30
|
||||
|
||||
@ -45,6 +49,7 @@ STATUS_FAILED = "\033[31mFailed\033[0m"
|
||||
STATUS_SKIPPED = "\033[33mSkipped\033[0m"
|
||||
|
||||
verbose = False
|
||||
test_only = []
|
||||
|
||||
WCH_RISCV_CONTENT = """
|
||||
adapter driver wlinke
|
||||
@ -134,6 +139,23 @@ def read_disk_file(uid, lun, fname):
|
||||
return None
|
||||
|
||||
|
||||
def open_mtp_dev(uid):
|
||||
mtp = MTP()
|
||||
timeout = ENUM_TIMEOUT
|
||||
while timeout > 0:
|
||||
# run_cmd(f"gio mount -u mtp://TinyUsb_TinyUsb_Device_{uid}/")
|
||||
for raw in mtp.detect_devices():
|
||||
mtp.device = mtp.mtp.LIBMTP_Open_Raw_Device(ctypes.byref(raw))
|
||||
if mtp.device:
|
||||
sn = mtp.get_serialnumber().decode('utf-8')
|
||||
#print(f'mtp serial = {sn}')
|
||||
if sn == uid:
|
||||
return mtp
|
||||
time.sleep(1)
|
||||
timeout -= 1
|
||||
return None
|
||||
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# Flashing firmware
|
||||
# -------------------------------------------------------------
|
||||
@ -456,7 +478,6 @@ def test_device_dfu(board):
|
||||
|
||||
def test_device_dfu_runtime(board):
|
||||
uid = board['uid']
|
||||
|
||||
# Wait device enum
|
||||
timeout = ENUM_TIMEOUT
|
||||
while timeout > 0:
|
||||
@ -491,6 +512,65 @@ def test_device_hid_composite_freertos(id):
|
||||
pass
|
||||
|
||||
|
||||
def test_device_mtp(board):
|
||||
uid = board['uid']
|
||||
|
||||
# --- BEFORE: mute C-level stderr for libmtp vid/pid warnings ---
|
||||
fd = sys.stderr.fileno()
|
||||
_saved = os.dup(fd)
|
||||
_null = os.open(os.devnull, os.O_WRONLY)
|
||||
os.dup2(_null, fd)
|
||||
|
||||
mtp = open_mtp_dev(uid)
|
||||
|
||||
# --- AFTER: restore stderr ---
|
||||
os.dup2(_saved, fd)
|
||||
os.close(_null)
|
||||
os.close(_saved)
|
||||
|
||||
if mtp is None or mtp.device is None:
|
||||
assert False, 'MTP device not found'
|
||||
|
||||
try:
|
||||
assert b"TinyUSB" == mtp.get_manufacturer(), 'MTP wrong manufacturer'
|
||||
assert b"MTP Example" == mtp.get_modelname(), 'MTP wrong model'
|
||||
assert b'1.0' == mtp.get_deviceversion(), 'MTP wrong version'
|
||||
assert b'TinyUSB MTP' == mtp.get_devicename(), 'MTP wrong device name'
|
||||
|
||||
# read and compare readme.txt and logo.png
|
||||
f1_expect = b'TinyUSB MTP Filesystem example'
|
||||
f2_md5_expect = '40ef23fc2891018d41a05d4a0d5f822f' # md5sum of logo.png
|
||||
f1 = uid.encode("utf-8") + b'_file1'
|
||||
f2 = uid.encode("utf-8") + b'_file2'
|
||||
f3 = uid.encode("utf-8") + b'_file3'
|
||||
mtp.get_file_to_file(1, f1)
|
||||
with open(f1, 'rb') as file:
|
||||
f1_data = file.read()
|
||||
os.remove(f1)
|
||||
assert f1_data == f1_expect, 'MTP file1 wrong data'
|
||||
mtp.get_file_to_file(2, f2)
|
||||
with open(f2, 'rb') as file:
|
||||
f2_data = file.read()
|
||||
os.remove(f2)
|
||||
assert f2_md5_expect == hashlib.md5(f2_data).hexdigest(), 'MTP file2 wrong data'
|
||||
# test send file
|
||||
with open(f3, "wb") as file:
|
||||
f3_data = os.urandom(random.randint(1024, 3*1024))
|
||||
file.write(f3_data)
|
||||
file.close()
|
||||
fid = mtp.send_file_from_file(f3, b'file3')
|
||||
f3_readback = f3 + b'_readback'
|
||||
mtp.get_file_to_file(fid, f3_readback)
|
||||
with open(f3_readback, 'rb') as f:
|
||||
f3_rb_data = f.read()
|
||||
os.remove(f3_readback)
|
||||
assert f3_rb_data == f3_data, 'MTP file3 wrong data'
|
||||
os.remove(f3)
|
||||
mtp.delete_object(fid)
|
||||
finally:
|
||||
mtp.disconnect()
|
||||
|
||||
|
||||
# -------------------------------------------------------------
|
||||
# Main
|
||||
# -------------------------------------------------------------
|
||||
@ -503,6 +583,7 @@ device_tests = [
|
||||
'device/dfu_runtime',
|
||||
'device/cdc_msc_freertos',
|
||||
'device/hid_boot_interface',
|
||||
'device/mtp'
|
||||
]
|
||||
|
||||
dual_tests = [
|
||||
@ -579,21 +660,24 @@ def test_board(board):
|
||||
# default to all tests
|
||||
test_list = []
|
||||
|
||||
if 'tests' in board:
|
||||
board_tests = board['tests']
|
||||
if 'device' in board_tests and board_tests['device'] == True:
|
||||
test_list += list(device_tests)
|
||||
if 'dual' in board_tests and board_tests['dual'] == True:
|
||||
test_list += dual_tests
|
||||
if 'host' in board_tests and board_tests['host'] == True:
|
||||
test_list += host_test
|
||||
if 'only' in board_tests:
|
||||
test_list = board_tests['only']
|
||||
if 'skip' in board_tests:
|
||||
for skip in board_tests['skip']:
|
||||
if skip in test_list:
|
||||
test_list.remove(skip)
|
||||
print(f'{name:25} {skip:30} ... Skip')
|
||||
if len(test_only) > 0:
|
||||
test_list = test_only
|
||||
else:
|
||||
if 'tests' in board:
|
||||
board_tests = board['tests']
|
||||
if 'device' in board_tests and board_tests['device'] == True:
|
||||
test_list += list(device_tests)
|
||||
if 'dual' in board_tests and board_tests['dual'] == True:
|
||||
test_list += dual_tests
|
||||
if 'host' in board_tests and board_tests['host'] == True:
|
||||
test_list += host_test
|
||||
if 'only' in board_tests:
|
||||
test_list = board_tests['only']
|
||||
if 'skip' in board_tests:
|
||||
for skip in board_tests['skip']:
|
||||
if skip in test_list:
|
||||
test_list.remove(skip)
|
||||
print(f'{name:25} {skip:30} ... Skip')
|
||||
|
||||
err_count = 0
|
||||
flags_on_list = [""]
|
||||
@ -615,6 +699,7 @@ def main():
|
||||
Hardware test on specified boards
|
||||
"""
|
||||
global verbose
|
||||
global test_only
|
||||
|
||||
duration = time.time()
|
||||
|
||||
@ -622,6 +707,7 @@ def main():
|
||||
parser.add_argument('config_file', help='Configuration JSON file')
|
||||
parser.add_argument('-b', '--board', action='append', default=[], help='Boards to test, all if not specified')
|
||||
parser.add_argument('-s', '--skip', action='append', default=[], help='Skip boards from test')
|
||||
parser.add_argument('-t', '--test-only', action='append', default=[], help='Tests to run, all if not specified')
|
||||
parser.add_argument('-v', '--verbose', action='store_true', help='Verbose output')
|
||||
args = parser.parse_args()
|
||||
|
||||
@ -629,6 +715,7 @@ def main():
|
||||
boards = args.board
|
||||
skip_boards = args.skip
|
||||
verbose = args.verbose
|
||||
test_only = args.test_only
|
||||
|
||||
# if config file is not found, try to find it in the same directory as this script
|
||||
if not os.path.exists(config_file):
|
||||
|
||||
1290
test/hil/pymtp.py
Normal file
1290
test/hil/pymtp.py
Normal file
File diff suppressed because it is too large
Load Diff
45
tools/file2carray.py
Normal file
45
tools/file2carray.py
Normal file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import random
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from multiprocessing import Pool
|
||||
from weakref import finalize
|
||||
|
||||
|
||||
def print_carray(f, payload):
|
||||
while len(payload) > 0:
|
||||
f.write('\n ')
|
||||
f.write(', '.join('0x{:02x}'.format(x) for x in payload[0:16]))
|
||||
f.write(',')
|
||||
payload = payload[16:]
|
||||
f.write('\n')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Convert binary files to C array format')
|
||||
parser.add_argument('files', nargs='+', help='Binary files to convert')
|
||||
args = parser.parse_args()
|
||||
|
||||
files = args.files
|
||||
for fin_name in files:
|
||||
if not os.path.isfile(fin_name):
|
||||
print(f"File {fin_name} does not exist")
|
||||
continue
|
||||
|
||||
with open(fin_name, 'rb') as fin:
|
||||
contents = fin.read()
|
||||
fout_name = fin_name + '.h'
|
||||
with open(fout_name, 'w') as fout:
|
||||
print(f"Converting {fin_name} to {fout_name}")
|
||||
fout.write(f'const size_t bindata_len = {len(contents)};\n')
|
||||
fout.write(f'const uint8_t bindata[] __attribute__((aligned(16))) = {{')
|
||||
print_carray(fout, contents)
|
||||
fout.write('};\n')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@ -124,6 +124,9 @@ deps_optional = {
|
||||
'hw/mcu/st/cmsis_device_n6': ['https://github.com/STMicroelectronics/cmsis-device-n6.git',
|
||||
'7bcdc944fbf7cf5928d3c1d14054ca13261d33ec',
|
||||
'stm32n6'],
|
||||
'hw/mcu/st/cmsis-device-u0': ['https://github.com/STMicroelectronics/cmsis-device-u0.git',
|
||||
'e3a627c6a5bc4eb2388e1885a95cc155e1672253',
|
||||
'stm32u0'],
|
||||
'hw/mcu/st/cmsis_device_u5': ['https://github.com/STMicroelectronics/cmsis_device_u5.git',
|
||||
'6e67187dec98035893692ab2923914cb5f4e0117',
|
||||
'stm32u5'],
|
||||
@ -190,6 +193,9 @@ deps_optional = {
|
||||
'hw/mcu/st/stm32n6xx_hal_driver': ['https://github.com/STMicroelectronics/stm32n6xx-hal-driver.git',
|
||||
'bc6c41f8f67d61b47af26695d0bf67762a000666',
|
||||
'stm32n6'],
|
||||
'hw/mcu/st/stm32u0xx_hal_driver': ['https://github.com/STMicroelectronics/stm32u0xx-hal-driver.git',
|
||||
'cbfb5ac654256445237fd32b3587ac6a238d24f1',
|
||||
'stm32u0'],
|
||||
'hw/mcu/st/stm32u5xx_hal_driver': ['https://github.com/STMicroelectronics/stm32u5xx_hal_driver.git',
|
||||
'2c5e2568fbdb1900a13ca3b2901fdd302cac3444',
|
||||
'stm32u5'],
|
||||
@ -240,7 +246,7 @@ deps_optional = {
|
||||
'imxrt kinetis_k32l2 kinetis_kl lpc51 lpc54 lpc55 mcx mm32 msp432e4 nrf saml2x '
|
||||
'lpc11 lpc13 lpc15 lpc17 lpc18 lpc40 lpc43 '
|
||||
'stm32c0 stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32g0 stm32g4 stm32h5 '
|
||||
'stm32h7 stm32h7rs stm32l0 stm32l1 stm32l4 stm32l5 stm32n6 stm32u5 stm32wb stm32wba'
|
||||
'stm32h7 stm32h7rs stm32l0 stm32l1 stm32l4 stm32l5 stm32n6 stm32u0 stm32u5 stm32wb stm32wba'
|
||||
'sam3x samd11 samd21 samd51 samd5x_e5x same5x same7x saml2x samg '
|
||||
'tm4c '],
|
||||
'lib/CMSIS_6': ['https://github.com/ARM-software/CMSIS_6.git',
|
||||
|
||||
@ -58,6 +58,11 @@
|
||||
<path>$TUSB_DIR$/src/class/msc/msc_device.h</path>
|
||||
<path>$TUSB_DIR$/src/class/msc/msc_host.h</path>
|
||||
</group>
|
||||
<group name="src/class/mtp">
|
||||
<path>$TUSB_DIR$/src/class/mtp/mtp_device.c</path>
|
||||
<path>$TUSB_DIR$/src/class/mtp/mtp.h</path>
|
||||
<path>$TUSB_DIR$/src/class/mtp/mtp_device.h</path>
|
||||
</group>
|
||||
<group name="src/class/net">
|
||||
<path>$TUSB_DIR$/src/class/net/ecm_rndis_device.c</path>
|
||||
<path>$TUSB_DIR$/src/class/net/ncm_device.c</path>
|
||||
|
||||
Reference in New Issue
Block a user