summaryrefslogtreecommitdiff
path: root/examples/device/board_test
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-03-17 23:53:38 +0700
committerhathach <[email protected]>2023-03-17 23:53:38 +0700
commitbdfcd50b1b601f85389a09cdaf183b2f27c1d470 (patch)
tree0ed9312b74a74c875fd17b86353ac02559ac7081 /examples/device/board_test
parent73f22e31c7a31e9b974e27407b906bbc8cb05a7a (diff)
parent65ee11ff630169c01a33860fbf8507d2d8f29a71 (diff)
Merge branch 'master' into portability
Diffstat (limited to 'examples/device/board_test')
-rw-r--r--examples/device/board_test/Makefile7
-rw-r--r--examples/device/board_test/src/CMakeLists.txt2
-rw-r--r--examples/device/board_test/src/main.c11
-rw-r--r--examples/device/board_test/src/tusb_config.h5
4 files changed, 15 insertions, 10 deletions
diff --git a/examples/device/board_test/Makefile b/examples/device/board_test/Makefile
index b65575ce6..2a3d854fb 100644
--- a/examples/device/board_test/Makefile
+++ b/examples/device/board_test/Makefile
@@ -1,4 +1,3 @@
-include ../../../tools/top.mk
include ../../make.mk
INC += \
@@ -9,10 +8,4 @@ INC += \
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
-# board_test example is special example that doesn't enable device or host stack
-# This can cause some TinyUSB API missing, this hack to allow us to fill those API
-# to pass the compilation process
-CFLAGS += \
- -D"tud_int_handler(x)= " \
-
include ../../rules.mk
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
//--------------------------------------------------------------------