apps/system/composite: Fix configuration selecting.. was setting the port number, not the configure ID. Also add a configuration option to select the default configuration.

This commit is contained in:
Gregory Nutt 2017-07-15 12:13:17 -06:00
parent 99b41a291b
commit c7f8540169
2 changed files with 22 additions and 13 deletions
system/composite

@ -15,6 +15,15 @@ menuconfig SYSTEM_COMPOSITE
disconn: Disconnect the mass storage device to the host
if SYSTEM_COMPOSITE
config SYSTEM_COMPOSITE_DEFCONFIG
int "Default composite configuration"
default 0
---help---
Boards may support multiple composite configurations. If so, then
this is the default configuration that the conn command will use if
no configuration ID is provided on the command line.
if CDCACM_COMPOSITE
config SYSTEM_COMPOSITE_SERDEV

@ -518,7 +518,7 @@ int conn_main(int argc, char *argv[])
#endif
{
struct boardioc_usbdev_ctrl_s ctrl;
int instance = 0;
int config = CONFIG_SYSTEM_COMPOSITE_DEFCONFIG;
int ret;
/* If this program is implemented as the NSH 'conn' command, then we need to
@ -537,11 +537,11 @@ int conn_main(int argc, char *argv[])
}
#endif
/* There is one optional argument.. the interface instance number */
/* There is one optional argument.. the interface configuration ID */
if (argc == 2)
{
instance = atoi(argv[1]);
config = atoi(argv[1]);
}
else if (argc > 2)
{
@ -569,8 +569,8 @@ int conn_main(int argc, char *argv[])
ctrl.usbdev = BOARDIOC_USBDEV_COMPOSITE;
ctrl.action = BOARDIOC_USBDEV_INITIALIZE;
ctrl.instance = instance;
ctrl.config = 0;
ctrl.instance = 0;
ctrl.config = config;
ctrl.handle = NULL;
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
@ -586,8 +586,8 @@ int conn_main(int argc, char *argv[])
ctrl.usbdev = BOARDIOC_USBDEV_COMPOSITE;
ctrl.action = BOARDIOC_USBDEV_CONNECT;
ctrl.instance = instance;
ctrl.config = 0;
ctrl.instance = 0;
ctrl.config = config;
ctrl.handle = &g_composite.cmphandle;
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
@ -691,8 +691,8 @@ errout:
ctrl.usbdev = BOARDIOC_USBDEV_COMPOSITE;
ctrl.action = BOARDIOC_USBDEV_DISCONNECT;
ctrl.instance = instance;
ctrl.config = 0;
ctrl.instance = 0;
ctrl.config = config;
ctrl.handle = &g_composite.cmphandle;
(void)boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
@ -719,7 +719,7 @@ int disconn_main(int argc, char *argv[])
#endif
{
struct boardioc_usbdev_ctrl_s ctrl;
int instance = instance;
int config = CONFIG_SYSTEM_COMPOSITE_DEFCONFIG;
/* First check if the USB mass storage device is already connected */
@ -731,7 +731,7 @@ int disconn_main(int argc, char *argv[])
check_test_memory_usage("Since MS connection");
/* There is one optional argument.. the interface instance number */
/* There is one optional argument.. the interface configuration ID */
if (argc == 2)
{
@ -747,8 +747,8 @@ int disconn_main(int argc, char *argv[])
ctrl.usbdev = BOARDIOC_USBDEV_COMPOSITE;
ctrl.action = BOARDIOC_USBDEV_DISCONNECT;
ctrl.instance = instance;
ctrl.config = 0;
ctrl.instance = 0;
ctrl.config = config;
ctrl.handle = &g_composite.cmphandle;
(void)boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);