usbserial: Add config for customize direction, message and wait time

This commit is contained in:
Kevin Zhou 2024-09-30 15:39:49 +08:00 committed by Xiang Xiao
parent b20f023ab7
commit 23bf7fb449
2 changed files with 60 additions and 0 deletions

View file

@ -20,6 +20,58 @@ config EXAMPLES_USBSERIAL_BUFSIZE
The size of the array that is used as an I/O buffer for USB serial
data transfers.
choice
prompt "USB serial transfer"
default EXAMPLES_USBSERIAL_INANDOUT
---help---
Select usb serial transfer in or out
config EXAMPLES_USBSERIAL_INANDOUT
bool "in and out"
config EXAMPLES_USBSERIAL_INONLY
bool "in only"
config EXAMPLES_USBSERIAL_OUTONLY
bool "out only"
endchoice # USBSERIAL in or out
config EXAMPLES_USBSERIAL_CONFIG_WAIT
bool "Config waiting time"
default n
---help---
Config waiting time after transfer
if EXAMPLES_USBSERIAL_CONFIG_WAIT
config EXAMPLES_USBSERIAL_IN_WAITING_TIME
int "In waiting time (ms)"
default 100
config EXAMPLES_USBSERIAL_OUT_WAITING_TIME
int "Out waiting time (ms)"
default 100
endif # USERSERIAL config wait
choice
prompt "USB serial message"
default EXAMPLES_USBSERIAL_SMALLANDBIG
---help---
Select usb serial small or big message
config EXAMPLES_USBSERIAL_SMALLANDBIG
bool "small and big"
config EXAMPLES_USBSERIAL_ONLYSMALL
bool "only small"
config EXAMPLES_USBSERIAL_ONLYBIG
bool "only big"
endchoice # USBSERIAL small or big message
config EXAMPLES_USBSERIAL_TRACEINIT
bool "USB Trace Initialization"
default n

View file

@ -456,12 +456,20 @@ int main(int argc, FAR char *argv[])
}
}
#ifdef CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT
usleep(CONFIG_EXAMPLES_USBSERIAL_OUT_WAITING_TIME * 1000);
#else
sleep(1);
#endif /* CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT */
}
#else /* CONFIG_EXAMPLES_USBSERIAL_INONLY */
printf("usbserial_main: Waiting\n");
#ifdef CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT
usleep(CONFIG_EXAMPLES_USBSERIAL_IN_WAITING_TIME * 1000);
#else
sleep(5);
#endif /* CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT */
#endif /* CONFIG_EXAMPLES_USBSERIAL_INONLY */
/* If USB tracing is enabled, then dump all collected trace data