Skip to content

Commit 23bf7fb

Browse files
Kevin-Zhou11xiaoxiang781216
authored andcommitted
usbserial: Add config for customize direction, message and wait time
1 parent b20f023 commit 23bf7fb

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

examples/usbserial/Kconfig

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,58 @@ config EXAMPLES_USBSERIAL_BUFSIZE
2020
The size of the array that is used as an I/O buffer for USB serial
2121
data transfers.
2222

23+
choice
24+
prompt "USB serial transfer"
25+
default EXAMPLES_USBSERIAL_INANDOUT
26+
---help---
27+
Select usb serial transfer in or out
28+
29+
config EXAMPLES_USBSERIAL_INANDOUT
30+
bool "in and out"
31+
32+
config EXAMPLES_USBSERIAL_INONLY
33+
bool "in only"
34+
35+
config EXAMPLES_USBSERIAL_OUTONLY
36+
bool "out only"
37+
38+
endchoice # USBSERIAL in or out
39+
40+
config EXAMPLES_USBSERIAL_CONFIG_WAIT
41+
bool "Config waiting time"
42+
default n
43+
---help---
44+
Config waiting time after transfer
45+
46+
if EXAMPLES_USBSERIAL_CONFIG_WAIT
47+
48+
config EXAMPLES_USBSERIAL_IN_WAITING_TIME
49+
int "In waiting time (ms)"
50+
default 100
51+
52+
config EXAMPLES_USBSERIAL_OUT_WAITING_TIME
53+
int "Out waiting time (ms)"
54+
default 100
55+
56+
endif # USERSERIAL config wait
57+
58+
choice
59+
prompt "USB serial message"
60+
default EXAMPLES_USBSERIAL_SMALLANDBIG
61+
---help---
62+
Select usb serial small or big message
63+
64+
config EXAMPLES_USBSERIAL_SMALLANDBIG
65+
bool "small and big"
66+
67+
config EXAMPLES_USBSERIAL_ONLYSMALL
68+
bool "only small"
69+
70+
config EXAMPLES_USBSERIAL_ONLYBIG
71+
bool "only big"
72+
73+
endchoice # USBSERIAL small or big message
74+
2375
config EXAMPLES_USBSERIAL_TRACEINIT
2476
bool "USB Trace Initialization"
2577
default n

examples/usbserial/usbserial_main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,20 @@ int main(int argc, FAR char *argv[])
456456
}
457457
}
458458

459+
#ifdef CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT
460+
usleep(CONFIG_EXAMPLES_USBSERIAL_OUT_WAITING_TIME * 1000);
461+
#else
459462
sleep(1);
463+
#endif /* CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT */
460464
}
461465

462466
#else /* CONFIG_EXAMPLES_USBSERIAL_INONLY */
463467
printf("usbserial_main: Waiting\n");
468+
#ifdef CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT
469+
usleep(CONFIG_EXAMPLES_USBSERIAL_IN_WAITING_TIME * 1000);
470+
#else
464471
sleep(5);
472+
#endif /* CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT */
465473
#endif /* CONFIG_EXAMPLES_USBSERIAL_INONLY */
466474

467475
/* If USB tracing is enabled, then dump all collected trace data

0 commit comments

Comments
 (0)