Repository navigation
Update/dwc3 restructure v0.19.0 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v0.19.0
Are you sure you want to change the base?
Changes from all commits
2a2661b
427a955
e4f5dcd
88b447f
89dea35
4232e1b
7b7bea9
bbef669
e52f993
8a62b16
50b3860
3b6e877
602a92c
dedd5ed
4c00ee0
8f72c8c
cbbca35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this file make sense in TinyUSB (if we are trying to mainline this) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,14 @@ | |
| #define USB3_HS_PORT (1) | ||
| #define USB3_SS_PORT (2) | ||
|
|
||
| /* Host controllers in this build, set by hw/bsp/socfpga/family.cmake (SOCFPGA_HCD) */ | ||
| #ifndef SOCFPGA_HCD_DWC2 | ||
| #define SOCFPGA_HCD_DWC2 1 | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need either DWC2 , DWC3 or both defined, Lets error if that is not the case |
||
| #endif | ||
| #ifndef SOCFPGA_HCD_DWC3 | ||
| #define SOCFPGA_HCD_DWC3 1 | ||
| #endif | ||
|
|
||
| int usb_wait_to_mount(int timeout) | ||
| { | ||
| while (timeout >= 0) | ||
|
|
@@ -69,6 +77,7 @@ void usb_task(void *arg) | |
| PRINT("USB3.1 port initialized successfully"); | ||
| } | ||
| } | ||
|
|
||
| while (1) | ||
| { | ||
| tuh_task(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,3 +20,5 @@ mcu:STM32H7RS | |
| mcu:STM32N6 | ||
| family:samd21 | ||
| family:samd5x_e5x | ||
| family:agilex5 | ||
| family:socfpga | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| 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() | ||
|
|
||
| add_executable(${PROJECT}) | ||
|
|
||
| # Example source | ||
| target_sources(${PROJECT} PUBLIC | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_app.c | ||
| ${TOP}/lib/fatfs/source/ff.c | ||
| ${TOP}/lib/fatfs/source/ffsystem.c | ||
| ${TOP}/lib/fatfs/source/ffunicode.c | ||
| ) | ||
|
|
||
| # Suppress warnings on fatfs | ||
| if (CMAKE_C_COMPILER_ID STREQUAL "GNU") | ||
| set_source_files_properties( | ||
| ${TOP}/lib/fatfs/source/ff.c | ||
| PROPERTIES | ||
| COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual" | ||
| ) | ||
| endif () | ||
|
|
||
| # Example include | ||
| target_include_directories(${PROJECT} PUBLIC | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src | ||
| ${TOP}/lib/fatfs/source | ||
| ${TOP}/lib/embedded-cli | ||
| ) | ||
|
|
||
| # Configure compilation flags and libraries for the example without RTOS. | ||
| # See the corresponding function in hw/bsp/FAMILY/family.cmake for details. | ||
| family_configure_host_example(${PROJECT} freertos) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "version": 6, | ||
| "include": [ | ||
| "../../../hw/bsp/BoardPresets.json" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| include ../../build_system/make/make.mk | ||
|
|
||
| FATFS_PATH = lib/fatfs/source | ||
|
|
||
| INC += \ | ||
| src \ | ||
| $(TOP)/hw \ | ||
| $(TOP)/$(FATFS_PATH) \ | ||
| $(TOP)/lib/embedded-cli \ | ||
|
|
||
| # Example source | ||
| EXAMPLE_SOURCE = \ | ||
| src/main.c \ | ||
| src/msc_app.c \ | ||
|
|
||
| SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE)) | ||
|
|
||
| # FatFS source | ||
| SRC_C += \ | ||
| $(FATFS_PATH)/ff.c \ | ||
| $(FATFS_PATH)/ffsystem.c \ | ||
| $(FATFS_PATH)/ffunicode.c \ | ||
|
|
||
| # suppress warning caused by fatfs | ||
| CFLAGS_GCC += -Wno-error=cast-qual | ||
|
|
||
| include ../../build_system/make/rules.mk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| mcu:CH32V20X | ||
| mcu:KINETIS_KL | ||
| mcu:LPC175X_6X | ||
| mcu:LPC177X_8X | ||
| mcu:LPC18XX | ||
| mcu:LPC40XX | ||
| mcu:LPC43XX | ||
| mcu:MIMXRT1XXX | ||
| mcu:MIMXRT10XX | ||
| mcu:MIMXRT11XX | ||
| mcu:RP2040 | ||
| mcu:MSP432E4 | ||
| mcu:RX65X | ||
| mcu:RAXXX | ||
| mcu:MAX3421 | ||
| mcu:STM32F4 | ||
| mcu:STM32F7 | ||
| mcu:STM32H7 | ||
| mcu:STM32H7RS | ||
| mcu:STM32N6 | ||
| family:samd21 | ||
| family:samd5x_e5x | ||
| family:agilex5 | ||
| family:socfpga |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| /* | ||
| * 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. | ||
| * | ||
| */ | ||
|
|
||
| /* Example to show how to navigate mass storage device with built-in command line. | ||
| * Type help for list of supported commands and syntax (mostly linux commands) | ||
|
|
||
| > help | ||
| * help | ||
| Print list of commands | ||
| * cat | ||
| Usage: cat [FILE]... | ||
| Concatenate FILE(s) to standard output.. | ||
| * cd | ||
| Usage: cd [DIR]... | ||
| Change the current directory to DIR. | ||
| * cp | ||
| Usage: cp SOURCE DEST | ||
| Copy SOURCE to DEST. | ||
| * ls | ||
| Usage: ls [DIR]... | ||
| List information about the FILEs (the current directory by default). | ||
| * pwd | ||
| Usage: pwd | ||
| Print the name of the current working directory. | ||
| * mkdir | ||
| Usage: mkdir DIR... | ||
| Create the DIRECTORY(ies), if they do not already exist.. | ||
| * mv | ||
| Usage: mv SOURCE DEST... | ||
| Rename SOURCE to DEST. | ||
| * rm | ||
| Usage: rm [FILE]... | ||
| Remove (unlink) the FILE(s). | ||
| */ | ||
|
|
||
| #include <stdlib.h> | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
|
|
||
| #include "bsp/board_api.h" | ||
| #include "tusb.h" | ||
|
|
||
| #include "msc_app.h" | ||
|
|
||
| //--------------------------------------------------------------------+ | ||
| // MACRO CONSTANT TYPEDEF PROTYPES | ||
| //--------------------------------------------------------------------+ | ||
|
|
||
| #define USBH_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2) * (CFG_TUSB_DEBUG ? 2 : 1) | ||
|
|
||
| void led_blinking_task(void); | ||
|
|
||
| static void usb_host_task(void *param); | ||
|
|
||
| /*------------- MAIN -------------*/ | ||
| int main(void) { | ||
| board_init(); | ||
|
|
||
| printf("TinyUSB Host MassStorage Explorer Example\r\n"); | ||
|
|
||
| xTaskCreate(usb_host_task, "usbd", USBH_STACK_SIZE, NULL, configMAX_PRIORITIES-1, NULL); | ||
|
|
||
| vTaskStartScheduler(); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| // USB Host task | ||
| // This top level thread process all usb events and invoke callbacks | ||
| static void usb_host_task(void *param) { | ||
| (void) param; | ||
|
|
||
| // init host stack on configured roothub port | ||
| tusb_rhport_init_t host_init = { | ||
| .role = TUSB_ROLE_HOST, | ||
| .speed = TUSB_SPEED_AUTO | ||
| }; | ||
|
|
||
| if (!tusb_init(BOARD_TUH_RHPORT, &host_init)) { | ||
| printf("Failed to init USB Host Stack\r\n"); | ||
| vTaskSuspend(NULL); | ||
| } | ||
|
|
||
| board_init_after_tusb(); | ||
|
|
||
| msc_app_init(); | ||
|
|
||
| // RTOS forever loop | ||
| while (1) { | ||
| // put this thread to waiting state until there is new events | ||
| tuh_task(); | ||
|
|
||
| msc_app_task(); | ||
|
|
||
| osal_task_delay(10); | ||
| } | ||
| } | ||
|
|
||
| //--------------------------------------------------------------------+ | ||
| // TinyUSB Callbacks | ||
| //--------------------------------------------------------------------+ | ||
|
|
||
| void tuh_mount_cb(uint8_t dev_addr) { | ||
| (void) dev_addr; | ||
| } | ||
|
|
||
| void tuh_umount_cb(uint8_t dev_addr) { | ||
| (void) dev_addr; | ||
| } | ||
|
|
||
| //--------------------------------------------------------------------+ | ||
| // Blinking Task | ||
| //--------------------------------------------------------------------+ | ||
| void led_blinking_task(void) { | ||
| const uint32_t interval_ms = 1000; | ||
| static uint32_t start_ms = 0; | ||
|
|
||
| static bool led_state = false; | ||
|
|
||
| // Blink every interval ms | ||
| if (board_millis() - start_ms < interval_ms) return; // not enough time | ||
| start_ms += interval_ms; | ||
|
|
||
| board_led_write(led_state); | ||
| led_state = 1 - led_state; // toggle | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not include "host/hcd.h" ?
Then we need not have this prototype redefined here