diff options
Diffstat (limited to 'examples/device/board_test/src')
| -rw-r--r-- | examples/device/board_test/src/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | examples/device/board_test/src/main.c | 11 | ||||
| -rw-r--r-- | examples/device/board_test/src/tusb_config.h | 5 |
3 files changed, 15 insertions, 3 deletions
diff --git a/examples/device/board_test/src/CMakeLists.txt b/examples/device/board_test/src/CMakeLists.txt index e4e1f4e9a..37625f441 100644 --- a/examples/device/board_test/src/CMakeLists.txt +++ b/examples/device/board_test/src/CMakeLists.txt @@ -2,7 +2,7 @@ idf_component_register(SRCS "main.c" INCLUDE_DIRS "." REQUIRES freertos soc) - + file(TO_NATIVE_PATH "${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}/board.cmake" board_cmake) if(EXISTS ${board_cmake}) diff --git a/examples/device/board_test/src/main.c b/examples/device/board_test/src/main.c index 207ca6294..3f8d55c52 100644 --- a/examples/device/board_test/src/main.c +++ b/examples/device/board_test/src/main.c @@ -1,4 +1,4 @@ -/* +/* * The MIT License (MIT) * * Copyright (c) 2019 Ha Thach (tinyusb.org) @@ -56,7 +56,7 @@ int main(void) { uint32_t interval_ms = board_button_read() ? BLINK_PRESSED : BLINK_UNPRESSED; - // Blink every interval ms + // Blink and print every interval ms if ( !(board_millis() - start_ms < interval_ms) ) { board_uart_write(HELLO_STR, strlen(HELLO_STR)); @@ -66,6 +66,13 @@ int main(void) board_led_write(led_state); led_state = 1 - led_state; // toggle } + + // echo + uint8_t ch; + if ( board_uart_read(&ch, 1) > 0 ) + { + board_uart_write(&ch, 1); + } } } diff --git a/examples/device/board_test/src/tusb_config.h b/examples/device/board_test/src/tusb_config.h index 5aea4fd2c..2c2eb5280 100644 --- a/examples/device/board_test/src/tusb_config.h +++ b/examples/device/board_test/src/tusb_config.h @@ -30,6 +30,11 @@ extern "C" { #endif +// board_test example is special example that doesn't enable device or host stack +// This can cause some TinyUSB API missing, this define hack to allow us to fill those API +// to pass the compilation process +#define tud_int_handler(x) + //-------------------------------------------------------------------- // COMMON CONFIGURATION //-------------------------------------------------------------------- |
