Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
75cf296
Bring in tinyusb as a submodule and get it to compile and link
maximevince Apr 2, 2025
adce61d
tinyusb: get vid,pid,manuf,product strings
maximevince Apr 3, 2025
fc66006
tinyusb: fully integrated - but still ~ 40us slower than the ST stack…
maximevince Apr 3, 2025
0b41c74
tinyusb: remove ST usb stack files
maximevince Apr 3, 2025
c14baff
tinyusb: upload submodule to include several dwc2 fixes
maximevince Apr 7, 2025
2eb2f37
tinyusb: use custom assert macro that reboots on assert
maximevince Apr 7, 2025
758c63f
tinyusb: connect hid event to xlat handler
maximevince Apr 7, 2025
98fde3b
gui: add KEY mode (in addition to CLICK and MOTION)
maximevince Apr 7, 2025
ae608ec
gui: change layout
maximevince Apr 8, 2025
497fea0
lvgl: add test app for Linux for easier GUI design changes
maximevince Apr 8, 2025
8f82325
hid: parse only descriptor for selected XLAT mode + small gui and cod…
maximevince Apr 8, 2025
95d9c0d
tinyusb: update to own fork with patches not yet merged upstream
maximevince Apr 10, 2025
057aca3
gui: properly clear measurements on disconnect and boot
maximevince Apr 10, 2025
c9d01fe
gpio: init D2 pin as an extra logic analyzer debugging channel
maximevince Apr 10, 2025
832ab68
xlat: move usb timestamp to USB HS IRQ handler + various small refact…
maximevince Apr 10, 2025
0b6cefc
GHA: fix build
maximevince Apr 10, 2025
ba47e3a
GUI: rework settings page (1)
maximevince Apr 14, 2025
300cf47
Create xlat_config module, update memory pools
maximevince Apr 14, 2025
35d6241
Update auto trigger interval according to GUI setting + refactor func…
maximevince Apr 15, 2025
83fa948
tinyusb: update to new commits in custom fork
maximevince Apr 15, 2025
35fd9b5
keyboard: support for modifier keys
maximevince Apr 15, 2025
d1b636c
trigger output: default pin + text update
maximevince Apr 15, 2025
784569f
extract version into into version.cmake
maximevince Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install arm-none-eabi-gcc toolchain
run: |
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "libs/tinyusb"]
path = libs/tinyusb
url = https://github.com/hathach/tinyusb.git
[submodule "libs/lv_drivers"]
path = libs/lv_drivers
url = https://github.com/lvgl/lv_drivers.git
60 changes: 28 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ set(CMAKE_C_FLAGS_RELEASE "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s)

# Define the application version
set(APP_VERSION_MAJOR 1)
set(APP_VERSION_MINOR 4)
set(APP_VERSION_PATCH 0) # patch level 99 = work-in-progress for next release
set(APP_VERSION_STRING "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}")
# Include version definitions
include(version.cmake)

add_compile_options(
${CPU_OPTIONS}
Expand Down Expand Up @@ -55,6 +52,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/libs/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1
${CMAKE_SOURCE_DIR}/libs/lufa
${CMAKE_SOURCE_DIR}/libs/lvgl
${CMAKE_SOURCE_DIR}/libs/tinyusb/include
${CMAKE_SOURCE_DIR}/libs/RTT/RTT
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/config
Expand Down Expand Up @@ -133,17 +131,6 @@ set(LUFA_Sources
libs/lufa/Drivers/USB/Class/Common/HIDParser.c
)

set(USB_Sources
src/usb/usbh_conf.c
src/usb/usb_host.c
src/usb/usbh_core.c
src/usb/usbh_ctlreq.c
src/usb/usbh_ioreq.c
src/usb/usbh_pipes.c
src/usb/usbh_hid.c
src/usb/usbh_hid_mouse.c
)

add_definitions(
-DSTM32
-DSTM32F7
Expand All @@ -157,6 +144,15 @@ add_definitions(
)

add_subdirectory(libs/lvgl)
add_subdirectory(libs/tinyusb/src)

set(TINYUSB_Sources
src/usb_task.c
src/tinyusb_hid_app.c
libs/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c
libs/tinyusb/src/portable/synopsys/dwc2/hcd_dwc2.c
libs/tinyusb/src/portable/synopsys/dwc2/dwc2_common.c
)

target_compile_options(lvgl PRIVATE -DSTM32F7)

Expand All @@ -175,6 +171,7 @@ add_executable(${PROJECT_NAME}
src/syscalls.c
src/system_stm32f7xx.c
src/xlat.c
src/xlat_config.c
src/theme/xlat_fm_logo_130px.c
drivers/tft/tft.c
drivers/touchpad/touchpad.c
Expand All @@ -183,23 +180,10 @@ add_executable(${PROJECT_NAME}
${LUFA_Sources}
${FREERTOS_Sources}
${RTT_Sources}
${USB_Sources}
${TINYUSB_Sources}
)

# Get the GIT SHA
execute_process(
COMMAND git rev-parse --short HEAD
OUTPUT_VARIABLE GIT_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE
)

target_compile_definitions(${PROJECT_NAME} PRIVATE -DGIT_SHA="${GIT_SHA}")

target_compile_definitions(${PROJECT_NAME} PRIVATE -DAPP_VERSION_MAJOR=${APP_VERSION_MAJOR})
target_compile_definitions(${PROJECT_NAME} PRIVATE -DAPP_VERSION_MINOR=${APP_VERSION_MINOR})
target_compile_definitions(${PROJECT_NAME} PRIVATE -DAPP_VERSION_PATCH=${APP_VERSION_PATCH})
target_compile_definitions(${PROJECT_NAME} PRIVATE -DAPP_VERSION="${APP_VERSION_STRING}")
target_compile_definitions(${PROJECT_NAME} PRIVATE -DAPP_VERSION_FULL="${APP_VERSION_STRING}-${GIT_SHA}")
tinyusb_target_add(${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME}
${CPU_OPTIONS}
Expand All @@ -219,7 +203,19 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
)

add_custom_target(${PROJECT_NAME}.bin ALL DEPENDS ${PROJECT_NAME})
add_custom_command(TARGET ${PROJECT_NAME}.bin
add_custom_command(TARGET ${PROJECT_NAME}.bin POST_BUILD
COMMAND ${CMAKE_C_OBJCOPY} ARGS -O binary ${PROJECT_NAME}.elf ${PROJECT_NAME}.bin)

# Test target configuration
add_custom_target(test
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/test
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/test ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR}/test
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/test
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building and running tests"
)

# Add test target as a dependency to the main target
# add_dependencies(${PROJECT_NAME} test)

set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT})
1 change: 1 addition & 0 deletions libs/lv_drivers
Submodule lv_drivers added at 49c4b1
1 change: 1 addition & 0 deletions libs/tinyusb
Submodule tinyusb added at 0c5818
2 changes: 1 addition & 1 deletion src/config/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 7 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
#define configTOTAL_HEAP_SIZE ((size_t)32768 / 2)
#define configTOTAL_HEAP_SIZE ((size_t)32768)
#define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_16_BIT_TICKS 0
#define configUSE_MUTEXES 1
Expand Down
2 changes: 1 addition & 1 deletion src/config/lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
# define LV_MEM_SIZE (16U * 1024U) /*[bytes]*/
# define LV_MEM_SIZE (32U * 1024U) /*[bytes]*/

/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
# define LV_MEM_ADR 0 /*0: unused*/
Expand Down
144 changes: 144 additions & 0 deletions src/config/tusb_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*
* 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.
*
*/

#ifndef _TUSB_CONFIG_H_
#define _TUSB_CONFIG_H_

#ifdef __cplusplus
extern "C" {
#endif

//--------------------------------------------------------------------
// Override Assert Handler
//--------------------------------------------------------------------
#include "stm32f7xx_hal.h"
#include <stdio.h>

#define CUSTOM_TU_ASSERT_DEFINE(_cond, _ret) \
do { \
if ( !(_cond) ) { \
printf("ASSERT FAILED in %s at line %d\r\n", __func__, __LINE__); \
TU_BREAKPOINT(); /* break if in debugger */ \
HAL_Delay(1000); /* 1 second delay before reboot */ \
NVIC_SystemReset(); /* Reboot the system */ \
} \
} while(0)

#define CUSTOM_TU_ASSERT_1ARGS(_cond) CUSTOM_TU_ASSERT_DEFINE(_cond, false)
#define CUSTOM_TU_ASSERT_2ARGS(_cond, _ret) CUSTOM_TU_ASSERT_DEFINE(_cond, _ret)
#define CUSTOM_TU_GET_3RD_ARG(arg1, arg2, arg3, ...) arg3

// Override the default TU_ASSERT macro to print the assert message and reboot
#undef TU_ASSERT
#define TU_ASSERT(...) CUSTOM_TU_GET_3RD_ARG(__VA_ARGS__, CUSTOM_TU_ASSERT_2ARGS, CUSTOM_TU_ASSERT_1ARGS, _dummy)(__VA_ARGS__)


//--------------------------------------------------------------------
// Common Configuration
//--------------------------------------------------------------------

// defined by compiler flags for flexibility
#ifndef CFG_TUSB_MCU
#define CFG_TUSB_MCU OPT_MCU_STM32F7
#endif

/* -DCFG_TUSB_MCU=OPT_MCU_STM32H7 \
* -DBOARD_TUD_RHPORT=${RHPORT_DEVICE} \
* -DBOARD_TUD_MAX_SPEED=${RHPORT_DEVICE_SPEED} \
* -DBOARD_TUH_RHPORT=${RHPORT_HOST} \
* -DBOARD_TUH_MAX_SPEED=${RHPORT_HOST_SPEED} \
*/

#ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_FREERTOS
#endif

#ifndef CFG_TUSB_DEBUG
#define CFG_TUSB_DEBUG 0
#endif

/* 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_TUH_MEM_SECTION
#define CFG_TUH_MEM_SECTION
#endif

#ifndef CFG_TUH_MEM_ALIGN
#define CFG_TUH_MEM_ALIGN __attribute__ ((aligned(4)))
#endif

//--------------------------------------------------------------------
// Host Configuration
//--------------------------------------------------------------------

// Enable Host stack
#define CFG_TUH_ENABLED 1

// Default is max speed that hardware controller could support with on-chip PHY
#define CFG_TUH_MAX_SPEED OPT_MODE_HIGH_SPEED

//------------------------- Board Specific --------------------------

// RHPort number used for host can be defined by board.mk, default to port 1 (HS port)
#ifndef BOARD_TUH_RHPORT
#define BOARD_TUH_RHPORT 1
#endif

// RHPort max operational speed can defined by board.mk
#ifndef BOARD_TUH_MAX_SPEED
#define BOARD_TUH_MAX_SPEED OPT_MODE_HIGH_SPEED
#endif

//--------------------------------------------------------------------
// Driver Configuration
//--------------------------------------------------------------------

// Size of buffer to hold descriptors and other data used for enumeration
#define CFG_TUH_ENUMERATION_BUFSIZE 512

#define CFG_TUH_HUB 1 // number of supported hubs
#define CFG_TUH_CDC 0 // CDC ACM
#define CFG_TUH_HID (3*CFG_TUH_DEVICE_MAX) // typical keyboard + mouse device can have 3-4 HID interfaces
#define CFG_TUH_MSC 0
#define CFG_TUH_VENDOR 0

// max device support (excluding hub device): 1 hub typically has 4 ports
#define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)

//------------- HID -------------//
#define CFG_TUH_HID_EPIN_BUFSIZE 64
#define CFG_TUH_HID_EPOUT_BUFSIZE 64


#ifdef __cplusplus
}
#endif

#endif /* _TUSB_CONFIG_H_ */
Loading