summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-05-08 00:24:48 +0700
committerhathach <[email protected]>2023-05-08 00:24:48 +0700
commit654f1821769f50c44f786032bedfe417a9ad4d0f (patch)
tree58f73d40188131af6d7686c966a3fd80bfc80ac6
parent6945c594d53ca6a35f1f0bb120b5a652c6ce9e84 (diff)
build host examples with imx
-rw-r--r--examples/host/cdc_msc_hid/CMakeLists.txt14
-rw-r--r--examples/host/hid_controller/CMakeLists.txt10
-rw-r--r--examples/host/msc_file_explorer/CMakeLists.txt20
-rw-r--r--hw/bsp/board.c49
-rw-r--r--hw/bsp/imxrt/family.cmake7
-rw-r--r--src/CMakeLists.txt9
6 files changed, 38 insertions, 71 deletions
diff --git a/examples/host/cdc_msc_hid/CMakeLists.txt b/examples/host/cdc_msc_hid/CMakeLists.txt
index 42dac5be7..68b52e274 100644
--- a/examples/host/cdc_msc_hid/CMakeLists.txt
+++ b/examples/host/cdc_msc_hid/CMakeLists.txt
@@ -14,16 +14,16 @@ add_executable(${PROJECT})
# Example source
target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/cdc_app.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/hid_app.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_app.c
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/cdc_app.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/hid_app.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/msc_app.c
+ )
# Example include
target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
diff --git a/examples/host/hid_controller/CMakeLists.txt b/examples/host/hid_controller/CMakeLists.txt
index e1d2f1642..e27f83c53 100644
--- a/examples/host/hid_controller/CMakeLists.txt
+++ b/examples/host/hid_controller/CMakeLists.txt
@@ -14,14 +14,14 @@ add_executable(${PROJECT})
# Example source
target_sources(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src/hid_app.c
- ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/hid_app.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
+ )
# Example include
target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ )
# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
diff --git a/examples/host/msc_file_explorer/CMakeLists.txt b/examples/host/msc_file_explorer/CMakeLists.txt
index 2ab0aa881..2d5600059 100644
--- a/examples/host/msc_file_explorer/CMakeLists.txt
+++ b/examples/host/msc_file_explorer/CMakeLists.txt
@@ -14,19 +14,19 @@ 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
- )
+ ${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
+ )
# Example include
target_include_directories(${PROJECT} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- ${TOP}/lib/fatfs/source
- ${TOP}/lib/embedded-cli
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ ${TOP}/lib/fatfs/source
+ ${TOP}/lib/embedded-cli
+ )
# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
diff --git a/hw/bsp/board.c b/hw/bsp/board.c
index e715bdf2e..66ffcb199 100644
--- a/hw/bsp/board.c
+++ b/hw/bsp/board.c
@@ -25,55 +25,6 @@
#include "board.h"
-#if 0
-#define LED_PHASE_MAX 8
-
-static struct
-{
- uint32_t phase[LED_PHASE_MAX];
- uint8_t phase_count;
-
- bool led_state;
- uint8_t current_phase;
- uint32_t current_ms;
-}led_pattern;
-
-void board_led_pattern(uint32_t const phase_ms[], uint8_t count)
-{
- memcpy(led_pattern.phase, phase_ms, 4*count);
- led_pattern.phase_count = count;
-
- // reset with 1st phase is on
- led_pattern.current_ms = board_millis();
- led_pattern.current_phase = 0;
- led_pattern.led_state = true;
- board_led_on();
-}
-
-void board_led_task(void)
-{
- if ( led_pattern.phase_count == 0 ) return;
-
- uint32_t const duration = led_pattern.phase[led_pattern.current_phase];
-
- // return if not enough time
- if (board_millis() - led_pattern.current_ms < duration) return;
-
- led_pattern.led_state = !led_pattern.led_state;
- board_led_write(led_pattern.led_state);
-
- led_pattern.current_ms += duration;
- led_pattern.current_phase++;
-
- if (led_pattern.current_phase == led_pattern.phase_count)
- {
- led_pattern.current_phase = 0;
- led_pattern.led_state = true;
- board_led_on();
- }
-}
-#endif
-
//--------------------------------------------------------------------+
// newlib read()/write() retarget
//--------------------------------------------------------------------+
diff --git a/hw/bsp/imxrt/family.cmake b/hw/bsp/imxrt/family.cmake
index 653885bb2..b180f725e 100644
--- a/hw/bsp/imxrt/family.cmake
+++ b/hw/bsp/imxrt/family.cmake
@@ -12,6 +12,8 @@ endif ()
set(CMAKE_SYSTEM_PROCESSOR cortex-m7 CACHE INTERNAL "System Processor")
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../examples/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+set(FAMILY_MCUS MIMXRT CACHE INTERNAL "")
+
# include board specific
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
@@ -89,6 +91,7 @@ function(family_configure_target TARGET)
${TOP}/src/portable/ehci/ehci.c
# BSP
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
)
target_include_directories(${BSP_TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
@@ -152,3 +155,7 @@ endfunction()
function(family_configure_device_example TARGET)
family_configure_target(${TARGET})
endfunction()
+
+function(family_configure_host_example TARGET)
+ family_configure_target(${TARGET})
+endfunction()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 02f962f44..0b99d8919 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,8 +6,10 @@ cmake_minimum_required(VERSION 3.17)
# Add tinyusb to a target
function(add_tinyusb TARGET)
target_sources(${TARGET} PUBLIC
+ # common
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/tusb.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/common/tusb_fifo.c
+ # device
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/device/usbd.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/device/usbd_control.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/audio/audio_device.c
@@ -22,6 +24,13 @@ function(add_tinyusb TARGET)
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/usbtmc/usbtmc_device.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/vendor/vendor_device.c
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/video/video_device.c
+ # host
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/host/usbh.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/host/hub.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/cdc/cdc_host.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/hid/hid_host.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/msc/msc_host.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/class/vendor/vendor_host.c
)
target_include_directories(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}