From 5f16a8c304a00488d3e86b40dd025195b3c98740 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 25 Sep 2013 18:50:14 -0600 Subject: [PATCH] Mov apps/examples/composite to apps/system/composite; convert configs/stm3210e-eval/composite to use kconfig-frontend tools -- untested --- ChangeLog.txt | 2 + examples/Kconfig | 1 - examples/Make.defs | 4 - examples/Makefile | 12 +- examples/README.txt | 78 --------- examples/composite/Kconfig | 64 ------- system/Kconfig | 8 +- system/Make.defs | 4 + system/Makefile | 5 +- {examples => system}/composite/.gitignore | 0 system/composite/Kconfig | 156 ++++++++++++++++++ {examples => system}/composite/Makefile | 4 +- system/composite/README.txt | 76 +++++++++ {examples => system}/composite/composite.h | 100 ++++++----- .../composite/composite_main.c | 52 +++--- 15 files changed, 329 insertions(+), 237 deletions(-) delete mode 100644 examples/composite/Kconfig rename {examples => system}/composite/.gitignore (100%) create mode 100644 system/composite/Kconfig rename {examples => system}/composite/Makefile (97%) create mode 100755 system/composite/README.txt rename {examples => system}/composite/composite.h (72%) rename {examples => system}/composite/composite_main.c (93%) diff --git a/ChangeLog.txt b/ChangeLog.txt index 02130e225..238496022 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -665,3 +665,5 @@ monitor stack usage by all threads (2013-9-24). * system/usbmsc: Move examples/usbmsc to system/usbmsc (2013-9-25). * system/cdcacm: Move examples/cdcacm to system/cdcacm (2013-9-25). + * system/composite: Move examples/composite to system/composite + (2013-9-25). diff --git a/examples/Kconfig b/examples/Kconfig index 3f699148d..505ba5670 100644 --- a/examples/Kconfig +++ b/examples/Kconfig @@ -7,7 +7,6 @@ source "$APPSDIR/examples/adc/Kconfig" source "$APPSDIR/examples/buttons/Kconfig" source "$APPSDIR/examples/can/Kconfig" source "$APPSDIR/examples/cc3000/Kconfig" -source "$APPSDIR/examples/composite/Kconfig" source "$APPSDIR/examples/cxxtest/Kconfig" source "$APPSDIR/examples/dhcpd/Kconfig" source "$APPSDIR/examples/elf/Kconfig" diff --git a/examples/Make.defs b/examples/Make.defs index 944739a12..d4615e2f7 100644 --- a/examples/Make.defs +++ b/examples/Make.defs @@ -50,10 +50,6 @@ ifeq ($(CONFIG_EXAMPLES_CC3000BASIC),y) CONFIGURED_APPS += examples/cc3000 endif -ifeq ($(CONFIG_EXAMPLES_COMPOSITE),y) -CONFIGURED_APPS += examples/composite -endif - ifeq ($(CONFIG_EXAMPLES_CXXTEST),y) CONFIGURED_APPS += examples/cxxtest endif diff --git a/examples/Makefile b/examples/Makefile index daa944e89..b629efa77 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -37,10 +37,10 @@ # Sub-directories -SUBDIRS = adc buttons can cc3000 composite cxxtest dhcpd discover elf -SUBDIRS += flash_test ftpc ftpd hello helloxx hidkbd igmp json keypadtest -SUBDIRS += lcdrw mm modbus mount mtdpart nettest nrf24l01_term nsh null -SUBDIRS += nx nxconsole nxffs nxflat nxhello nximage nxlines nxtext ostest +SUBDIRS = adc buttons can cc3000 cxxtest dhcpd discover elf flash_test +SUBDIRS += ftpc ftpd hello helloxx hidkbd igmp json keypadtest lcdrw +SUBDIRS += mm modbus mount mtdpart nettest nrf24l01_term nsh null nx +SUBDIRS += nxconsole nxffs nxflat nxhello nximage nxlines nxtext ostest SUBDIRS += pashello pipe poll posix_spawn pwm qencoder relays rgmp romfs SUBDIRS += sendmail serloop slcd smart smart_test tcpecho telnetd thttpd tiff SUBDIRS += touchscreen udp uip usbserial usbterm watchdog wget wgetjson @@ -53,8 +53,8 @@ SUBDIRS += xmlrpc CNTXTDIRS = pwm ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -CNTXTDIRS += adc can cc3000 composite cxxtest dhcpd discover flash_test -CNTXTDIRS += ftpd hello helloxx json keypadtestmodbus lcdrw mtdpart nettest +CNTXTDIRS += adc can cc3000 cxxtest dhcpd discover flash_test ftpd +CNTXTDIRS += hello helloxx json keypadtestmodbus lcdrw mtdpart nettest CNTXTDIRS += nx nxhello nximage nxlines nxtext nrf24l01_term ostest relays CNTXTDIRS += qencoder slcd smart_test tcpecho telnetd tiff touchscreen CNTXTDIRS += usbterm watchdog wgetjson diff --git a/examples/README.txt b/examples/README.txt index 29dd6fa7d..85b0e60fc 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -131,84 +131,6 @@ examples/cc3000 This is a test for the TI CC3000 wireless networking module. -examples/composite -^^^^^^^^^^^^^^^^^^ - - This example test a USB composite device. The only supported composite is - CDC/ACM serial with a USB mass storage device. - - Required overall configuration: - - CONFIG_USBDEV=y - USB device support - CONFIG_USBDEV_COMPOSITE=y - USB composite device support - CONFIG_COMPOSITE_IAD=y - Interface associate descriptor needed - - CONFIG_CDCACM=y - USB CDC/ACM serial device support - CONFIG_CDCACM_COMPOSITE=y - USB CDC/ACM serial composite device support - CONFIG_CDCACM_IFNOBASE=0 - CDC/ACM interfaces start with number 0 - CONFIG_CDCACM_STRBASE=4 - Base of string numbers (not really needed) - CONFIG_CDCACM_EPINTIN=1 - Endpoint numbers must be unique - CONFIG_CDCACM_EPBULKIN=2 - CONFIG_CDCACM_EPBULKOUT=3 - - CONFIG_USBMSC - USB mass storage device support - CONFIG_USBMSC_COMPOSITE=y - USB mass storage composite device support - CONFIG_USBMSC_IFNOBASE=2 - USB mass storage interfaces start with number 2 - CONFIG_USBMSC_STRBASE=4 - Base of string numbers (needed) - CONFIG_USBMSC_EPBULKOUT=4 - Endpoint numbers must be unique - CONFIG_USBMSC_EPBULKIN=5 - - CONFIG_NSH_BUILTIN_APPS - This example can be built as two NSH "built-in" commands if this option - is selected: 'conn' will connect the USB composite device; 'msdis' - will disconnect the USB composite device. - - Configuration options unique to this example: - - CONFIG_EXAMPLES_COMPOSITE_DEBUGMM - Enables some debug tests to check for memory usage and memory leaks. - - CONFIG_EXAMPLES_COMPOSITE_NLUNS - Defines the number of logical units (LUNs) exported by the USB storage - driver. Each LUN corresponds to one exported block driver (or partition - of a block driver). May be 1, 2, or 3. Default is 1. - CONFIG_EXAMPLES_COMPOSITE_DEVMINOR1 - The minor device number of the block driver for the first LUN. For - example, N in /dev/mmcsdN. Used for registering the block driver. Default - is zero. - CONFIG_EXAMPLES_COMPOSITE_DEVPATH1 - The full path to the registered block driver. Default is "/dev/mmcsd0" - CONFIG_EXAMPLES_COMPOSITE_DEVMINOR2 and CONFIG_EXAMPLES_COMPOSITE_DEVPATH2 - Similar parameters that would have to be provided if CONFIG_EXAMPLES_COMPOSITE_NLUNS - is 2 or 3. No defaults. - CONFIG_EXAMPLES_COMPOSITE_DEVMINOR3 and CONFIG_EXAMPLES_COMPOSITE_DEVPATH2 - Similar parameters that would have to be provided if CONFIG_EXAMPLES_COMPOSITE_NLUNS - is 3. No defaults. - CONFIG_EXAMPLES_COMPOSITE_BUFLEN. Default 256. - - CONFIG_EXAMPLES_COMPOSITE_TTYUSB - The minor number of the USB serial device. - Default is zero (corresponding to /dev/ttyUSB0 or /dev/ttyACM0). Default is zero. - CCONFIG_EXAMPLES_COMPOSITE_SERDEV - The string corresponding to - CONFIG_EXAMPLES_COMPOSITE_TTYUSB. The default is "/dev/ttyUSB0" (for the PL2303 - emulation) or "/dev/ttyACM0" (for the CDC/ACM serial device). - CONFIG_EXAMPLES_COMPOSITE_BUFSIZE - The size of the serial I/O buffer in - bytes. Default 256 bytes. - - If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB), then - the example code will also manage the USB trace output. The amount of trace output - can be controlled using: - - CONFIG_EXAMPLES_COMPOSITE_TRACEINIT - Show initialization events - CONFIG_EXAMPLES_COMPOSITE_TRACECLASS - Show class driver events - CONFIG_EXAMPLES_COMPOSITE_TRACETRANSFERS - Show data transfer events - CONFIG_EXAMPLES_COMPOSITE_TRACECONTROLLER - Show controller events - CONFIG_EXAMPLES_COMPOSITE_TRACEINTERRUPTS - Show interrupt-related events. - examples/cxxtest ^^^^^^^^^^^^^^^^ diff --git a/examples/composite/Kconfig b/examples/composite/Kconfig deleted file mode 100644 index 4d55d5548..000000000 --- a/examples/composite/Kconfig +++ /dev/null @@ -1,64 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see misc/tools/kconfig-language.txt. -# - -config EXAMPLES_COMPOSITE - bool "USB composite class driver example" - default n - ---help--- - Enable the USB compsite class driver example - -if EXAMPLES_COMPOSITE -config EXAMPLES_COMPOSITE_TRACEINIT - bool "USB Trace Initialization" - default n - depends on USBDEV_TRACE || DEBUG_USB - ---help--- - If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), - then the example code will also manage the USB trace output. The - amount of trace output can be controlled this configuration value: - This setting will show USB initialization events - -config EXAMPLES_COMPOSITE_TRACECLASS - bool "USB Trace Class" - default n - depends on USBDEV_TRACE || DEBUG_USB - ---help--- - If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), - then the example code will also manage the USB trace output. The - amount of trace output can be controlled this configuration value: - This setting will show USB class driver events - -config EXAMPLES_COMPOSITE_TRACETRANSFERS - bool "USB Trace Transfers" - default n - depends on USBDEV_TRACE || DEBUG_USB - ---help--- - If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), - then the example code will also manage the USB trace output. The - amount of trace output can be controlled this configuration value: - This setting will show USB data transfer events - -config EXAMPLES_COMPOSITE_TRACECONTROLLER - bool "USB Trace Device Controller Events" - default n - depends on USBDEV_TRACE || DEBUG_USB - ---help--- - If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), - then the example code will also manage the USB trace output. The - amount of trace output can be controlled this configuration value: - This setting will show USB device controller events - -config EXAMPLES_COMPOSITE_TRACEINTERRUPTS - bool "USB Trace Device Controller Interrupt Events" - default n - depends on USBDEV_TRACE || DEBUG_USB - ---help--- - If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), - then the example code will also manage the USB trace output. The - amount of trace output can be controlled this configuration value: - This setting will show USB device controller interrupt-related events. - -endif - diff --git a/system/Kconfig b/system/Kconfig index c2eec877b..82741e572 100644 --- a/system/Kconfig +++ b/system/Kconfig @@ -3,10 +3,14 @@ # see misc/tools/kconfig-language.txt. # -menu "USB CDC/ACM Class Commands" +menu "USB CDC/ACM Device Commands" source "$APPSDIR/system/cdcacm/Kconfig" endmenu +menu "USB Composite Device Commands" +source "$APPSDIR/system/composite/Kconfig" +endmenu + menu "Custom Free Memory Command" source "$APPSDIR/system/free/Kconfig" endmenu @@ -55,7 +59,7 @@ menu "Stack Monitor" source "$APPSDIR/system/stackmonitor/Kconfig" endmenu -menu "USB Mass Storage Class Commands" +menu "USB Mass Storage Device Commands" source "$APPSDIR/system/usbmsc/Kconfig" endmenu diff --git a/system/Make.defs b/system/Make.defs index a314220aa..7c7b886fe 100644 --- a/system/Make.defs +++ b/system/Make.defs @@ -38,6 +38,10 @@ ifeq ($(CONFIG_SYSTEM_CDCACM),y) CONFIGURED_APPS += system/cdcacm endif +ifeq ($(CONFIG_SYSTEM_COMPOSITE),y) +CONFIGURED_APPS += system/composite +endif + ifeq ($(CONFIG_SYSTEM_FREE),y) CONFIGURED_APPS += system/free endif diff --git a/system/Makefile b/system/Makefile index 46ceccdda..d3438793b 100644 --- a/system/Makefile +++ b/system/Makefile @@ -37,8 +37,9 @@ # Sub-directories containing system task -SUBDIRS = cdcacm flash_eraseall free i2c install poweroff ramtest ramtron -SUBDIRS += readline sdcard stackmonitor sysinfo usbmonitor usbmsc zmodem +SUBDIRS = cdcacm composite flash_eraseall free i2c install poweroff +SUBDIRS += ramtest ramtron readline sdcard stackmonitor sysinfo usbmonitor +SUBDIRS += usbmsc zmodem # Create the list of installed runtime modules (INSTALLED_DIRS) diff --git a/examples/composite/.gitignore b/system/composite/.gitignore similarity index 100% rename from examples/composite/.gitignore rename to system/composite/.gitignore diff --git a/system/composite/Kconfig b/system/composite/Kconfig new file mode 100644 index 000000000..c2850637d --- /dev/null +++ b/system/composite/Kconfig @@ -0,0 +1,156 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config SYSTEM_COMPOSITE + bool "USB composite class controls" + default n + depends on USBDEV_COMPOSITE && !KERNEL_BUILD + ---help--- + Enable the USB composite class controls. These controls include: + + conn: Connect the mass storage device to the host + disconn: Disconnect the mass storage device to the host + +if SYSTEM_COMPOSITE +if USBMSC_COMPOSITE + +config SYSTEM_COMPOSITE_NLUNS + int "Number of LUNs" + default 1 + ---help--- + Defines the number of logical units (LUNs) exported by the USB + storage driver. Each LUN corresponds to one exported block driver + (or partition of a block driver). May be 1, 2, or 3. Default is 1. + +config SYSTEM_COMPOSITE_DEVMINOR1 + int "LUN1 Minor Device Number" + default 0 + ---help--- + The minor device number of the block driver for the first LUN. For + example, N in /dev/mmcsdN. Used for registering the block driver. + Default is zero. + +config SYSTEM_COMPOSITE_DEVPATH1 + string "LUN1 Device Path" + default "/dev/mmcsd0" + ---help--- + The full path to the registered block driver. Default is + "/dev/mmcsd0" + +config SYSTEM_COMPOSITE_DEVMINOR2 + int "LUN2 Minor Device Number" + default 1 + ---help--- + The minor device number of the block driver for the second LUN. For + example, N in /dev/mmcsdN. Used for registering the block driver. + Ignored if SYSTEM_COMPOSITE_NLUNS < 2. Default is one. + +config SYSTEM_COMPOSITE_DEVPATH2 + string "LUN2 Device Path" + default "/dev/mmcsd1" + ---help--- + The full path to the registered block driver. Ignored if + SYSTEM_COMPOSITE_NLUNS < 2. Default is "/dev/mmcsd1" + +config SYSTEM_COMPOSITE_DEVMINOR3 + int "LUN3 Minor Device Number" + default 2 + ---help--- + The minor device number of the block driver for the third LUN. For + example, N in /dev/mmcsdN. Used for registering the block driver. + Ignored if SYSTEM_COMPOSITE_NLUNS < 2. Default is two. + +config SYSTEM_COMPOSITE_DEVPATH3 + string "LUN3 Device Path" + default "/dev/mmcsd2" + ---help--- + The full path to the registered block driver. Ignored if + SYSTEM_COMPOSITE_NLUNS < 2. Default is "/dev/mmcsd2" + +endif # USBMSC_COMPOSITE + +if CDCACM_COMPOSITE + +config SYSTEM_COMPOSITE_TTYUSB + int "USB serial device minor number + default 0 + ---help--- + The minor number of the USB serial device. Default is zero + (corresponding to /dev/ttyUSB0 or /dev/ttyACM0). + +config SYSTEM_COMPOSITE_SERDEV + string "USB serial device path" + default "/dev/ttyACM0" + ---help--- + The string corresponding to SYSTEM_COMPOSITE_TTYUSB. If + SYSTEM_COMPOSITE_TTYUSB is zero, then this would be "/dev/ttyUSB0" + (for the PL2303 emulation) or "/dev/ttyACM0" (for the CDC/ACM serial + device). + +config SYSTEM_COMPOSITE_BUFSIZE + int "Serial I/O buffer size" + default 256 + ---help--- + The size of the serial I/O buffer in bytes. Default 256 bytes. + +endif # CDCACM_COMPOSITE + +if USBDEV_TRACE || DEBUG_USB + +config SYSTEM_COMPOSITE_TRACEINIT + bool "USB Trace Initialization" + default n + ---help--- + If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), + then the add-on code will also manage the USB trace output. The + amount of trace output can be controlled this configuration value: + This setting will show USB initialization events + +config SYSTEM_COMPOSITE_TRACECLASS + bool "USB Trace Class" + default n + ---help--- + If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), + then the add-on code will also manage the USB trace output. The + amount of trace output can be controlled this configuration value: + This setting will show USB class driver events + +config SYSTEM_COMPOSITE_TRACETRANSFERS + bool "USB Trace Transfers" + default n + ---help--- + If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), + then the add-on code will also manage the USB trace output. The + amount of trace output can be controlled this configuration value: + This setting will show USB data transfer events + +config SYSTEM_COMPOSITE_TRACECONTROLLER + bool "USB Trace Device Controller Events" + default n + ---help--- + If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), + then the add-on code will also manage the USB trace output. The + amount of trace output can be controlled this configuration value: + This setting will show USB device controller events + +config SYSTEM_COMPOSITE_TRACEINTERRUPTS + bool "USB Trace Device Controller Interrupt Events" + default n + ---help--- + If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), + then the add-on code will also manage the USB trace output. The + amount of trace output can be controlled this configuration value: + This setting will show USB device controller interrupt-related events. + +endif # USBDEV_TRACE || DEBUG_USB + +config SYSTEM_COMPOSITE_DEBUGMM + bool "Memory usage debug" + default n + ---help--- + Enables some debug tests to check for memory usage and memory leaks. + +endif + diff --git a/examples/composite/Makefile b/system/composite/Makefile similarity index 97% rename from examples/composite/Makefile rename to system/composite/Makefile index 1f05d9c64..83d36d5e8 100644 --- a/examples/composite/Makefile +++ b/system/composite/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# apps/examples/composite/Makefile +# apps/system/composite/Makefile # # Copyright (C) 2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt @@ -37,7 +37,7 @@ -include $(TOPDIR)/Make.defs include $(APPDIR)/Make.defs -# USB device mass storage example +# USB device mass storage add-on ASRCS = CSRCS = composite_main.c diff --git a/system/composite/README.txt b/system/composite/README.txt new file mode 100755 index 000000000..14d912f1c --- /dev/null +++ b/system/composite/README.txt @@ -0,0 +1,76 @@ +system/composite +^^^^^^^^^^^^^^^^^^ + + This logic adds a NXH command to control a USB composite device. The only + supported composite is CDC/ACM serial with a USB mass storage device. + + Required overall configuration: + + CONFIG_USBDEV=y - USB device support + CONFIG_USBDEV_COMPOSITE=y - USB composite device support + CONFIG_COMPOSITE_IAD=y - Interface associate descriptor needed + + CONFIG_CDCACM=y - USB CDC/ACM serial device support + CONFIG_CDCACM_COMPOSITE=y - USB CDC/ACM serial composite device support + CONFIG_CDCACM_IFNOBASE=0 - CDC/ACM interfaces start with number 0 + CONFIG_CDCACM_STRBASE=4 - Base of string numbers (not really needed) + CONFIG_CDCACM_EPINTIN=1 - Endpoint numbers must be unique + CONFIG_CDCACM_EPBULKIN=2 + CONFIG_CDCACM_EPBULKOUT=3 + + CONFIG_USBMSC - USB mass storage device support + CONFIG_USBMSC_COMPOSITE=y - USB mass storage composite device support + CONFIG_USBMSC_IFNOBASE=2 - USB mass storage interfaces start with number 2 + CONFIG_USBMSC_STRBASE=4 - Base of string numbers (needed) + CONFIG_USBMSC_EPBULKOUT=4 - Endpoint numbers must be unique + CONFIG_USBMSC_EPBULKIN=5 + + CONFIG_NSH_BUILTIN_APPS + This add-on can be built as two NSH "built-in" commands if this option + is selected: 'conn' will connect the USB composite device; 'msdis' + will disconnect the USB composite device. + + Configuration options unique to this add-on: + + CONFIG_SYSTEM_COMPOSITE_DEBUGMM + Enables some debug tests to check for memory usage and memory leaks. + + CONFIG_SYSTEM_COMPOSITE_NLUNS + Defines the number of logical units (LUNs) exported by the USB storage + driver. Each LUN corresponds to one exported block driver (or partition + of a block driver). May be 1, 2, or 3. Default is 1. + CONFIG_SYSTEM_COMPOSITE_DEVMINOR1 + The minor device number of the block driver for the first LUN. For + example, N in /dev/mmcsdN. Used for registering the block driver. Default + is zero. + CONFIG_SYSTEM_COMPOSITE_DEVPATH1 + The full path to the registered block driver. Default is "/dev/mmcsd0" + CONFIG_SYSTEM_COMPOSITE_DEVMINOR2 and CONFIG_SYSTEM_COMPOSITE_DEVPATH2 + Similar parameters that would have to be provided if CONFIG_SYSTEM_COMPOSITE_NLUNS + is 2 or 3. No defaults. + CONFIG_SYSTEM_COMPOSITE_DEVMINOR3 and CONFIG_SYSTEM_COMPOSITE_DEVPATH2 + Similar parameters that would have to be provided if CONFIG_SYSTEM_COMPOSITE_NLUNS + is 3. No defaults. + + CONFIG_SYSTEM_COMPOSITE_TTYUSB - The minor number of the USB serial device. + Default is zero (corresponding to /dev/ttyUSB0 or /dev/ttyACM0). Default is zero. + CCONFIG_SYSTEM_COMPOSITE_SERDEV - The string corresponding to + CONFIG_SYSTEM_COMPOSITE_TTYUSB. The default is "/dev/ttyUSB0" (for the PL2303 + emulation) or "/dev/ttyACM0" (for the CDC/ACM serial device). + CONFIG_SYSTEM_COMPOSITE_BUFSIZE - The size of the serial I/O buffer in + bytes. Default 256 bytes. + + If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB), then + the add-on code will also manage the USB trace output. The amount of trace output + can be controlled using: + + CONFIG_SYSTEM_COMPOSITE_TRACEINIT + Show initialization events + CONFIG_SYSTEM_COMPOSITE_TRACECLASS + Show class driver events + CONFIG_SYSTEM_COMPOSITE_TRACETRANSFERS + Show data transfer events + CONFIG_SYSTEM_COMPOSITE_TRACECONTROLLER + Show controller events + CONFIG_SYSTEM_COMPOSITE_TRACEINTERRUPTS + Show interrupt-related events. diff --git a/examples/composite/composite.h b/system/composite/composite.h similarity index 72% rename from examples/composite/composite.h rename to system/composite/composite.h index 3f7f7ebad..699dcf05e 100644 --- a/examples/composite/composite.h +++ b/system/composite/composite.h @@ -1,7 +1,7 @@ /**************************************************************************** - * examples/composite/composite.h + * system/composite/composite.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __EXAMPLES_COMPOSITE_COMPOSITE_H -#define __EXAMPLES_COMPOSITE_COMPOSITE_H +#ifndef __SYSTEM_COMPOSITE_COMPOSITE_H +#define __SYSTEM_COMPOSITE_COMPOSITE_H /**************************************************************************** * Included Files @@ -73,67 +73,63 @@ # error "USB mass storage composite device support is not enabled (CONFIG_USBMSC_COMPOSITE)" #endif -/* Example MSC default values */ +/* Add-on Mass Storagte Class default values */ -#ifndef CONFIG_EXAMPLES_COMPOSITE_NLUNS -# define CONFIG_EXAMPLES_COMPOSITE_NLUNS 1 +#ifndef CONFIG_SYSTEM_COMPOSITE_NLUNS +# define CONFIG_SYSTEM_COMPOSITE_NLUNS 1 #endif -#ifndef CONFIG_EXAMPLES_COMPOSITE_DEVMINOR1 -# define CONFIG_EXAMPLES_COMPOSITE_DEVMINOR1 0 +#ifndef CONFIG_SYSTEM_COMPOSITE_DEVMINOR1 +# define CONFIG_SYSTEM_COMPOSITE_DEVMINOR1 0 #endif -#ifndef CONFIG_EXAMPLES_COMPOSITE_DEVPATH1 -# define CONFIG_EXAMPLES_COMPOSITE_DEVPATH1 "/dev/mmcsd0" +#ifndef CONFIG_SYSTEM_COMPOSITE_DEVPATH1 +# define CONFIG_SYSTEM_COMPOSITE_DEVPATH1 "/dev/mmcsd0" #endif -#if CONFIG_EXAMPLES_COMPOSITE_NLUNS > 1 -# ifndef CONFIG_EXAMPLES_COMPOSITE_DEVMINOR2 -# error "CONFIG_EXAMPLES_COMPOSITE_DEVMINOR2 for LUN=2" +#if CONFIG_SYSTEM_COMPOSITE_NLUNS > 1 +# ifndef CONFIG_SYSTEM_COMPOSITE_DEVMINOR2 +# error "CONFIG_SYSTEM_COMPOSITE_DEVMINOR2 for LUN=2" # endif -# ifndef CONFIG_EXAMPLES_COMPOSITE_DEVPATH2 -# error "CONFIG_EXAMPLES_COMPOSITE_DEVPATH2 for LUN=2" +# ifndef CONFIG_SYSTEM_COMPOSITE_DEVPATH2 +# error "CONFIG_SYSTEM_COMPOSITE_DEVPATH2 for LUN=2" # endif -# if CONFIG_EXAMPLES_COMPOSITE_NLUNS > 2 -# ifndef CONFIG_EXAMPLES_COMPOSITE_DEVMINOR3 -# error "CONFIG_EXAMPLES_COMPOSITE_DEVMINOR2 for LUN=3" +# if CONFIG_SYSTEM_COMPOSITE_NLUNS > 2 +# ifndef CONFIG_SYSTEM_COMPOSITE_DEVMINOR3 +# error "CONFIG_SYSTEM_COMPOSITE_DEVMINOR2 for LUN=3" # endif -# ifndef CONFIG_EXAMPLES_COMPOSITE_DEVPATH2 -# error "CONFIG_EXAMPLES_COMPOSITE_DEVPATH2 for LUN=3" +# ifndef CONFIG_SYSTEM_COMPOSITE_DEVPATH2 +# error "CONFIG_SYSTEM_COMPOSITE_DEVPATH2 for LUN=3" # endif -# if CONFIG_EXAMPLES_COMPOSITE_NLUNS > 3 -# error "CONFIG_EXAMPLES_COMPOSITE_NLUNS must be {1,2,3}" +# if CONFIG_SYSTEM_COMPOSITE_NLUNS > 3 +# error "CONFIG_SYSTEM_COMPOSITE_NLUNS must be {1,2,3}" # endif # endif #endif -#ifndef CONFIG_EXAMPLES_COMPOSITE_BUFLEN -# define CONFIG_EXAMPLES_COMPOSITE_BUFLEN 256 +/* Add-on CDC/ACM default values */ + +#ifndef CONFIG_SYSTEM_COMPOSITE_TTYUSB +# define CONFIG_SYSTEM_COMPOSITE_TTYUSB 0 #endif -/* Example MSC default values */ - -#ifndef CONFIG_EXAMPLES_COMPOSITE_TTYUSB -# define CONFIG_EXAMPLES_COMPOSITE_TTYUSB 0 -#endif - -#ifndef CONFIG_EXAMPLES_COMPOSITE_SERDEV -# if CONFIG_EXAMPLES_COMPOSITE_TTYUSB != 0 -# error "Serial device unknown (CONFIG_EXAMPLES_COMPOSITE_SERDEV)" +#ifndef CONFIG_SYSTEM_COMPOSITE_SERDEV +# if CONFIG_SYSTEM_COMPOSITE_TTYUSB != 0 +# error "Serial device unknown (CONFIG_SYSTEM_COMPOSITE_SERDEV)" # elif defined(CONFIG_CDCACM) -# define CONFIG_EXAMPLES_COMPOSITE_SERDEV "/dev/ttyACM0" +# define CONFIG_SYSTEM_COMPOSITE_SERDEV "/dev/ttyACM0" # else -# define CONFIG_EXAMPLES_COMPOSITE_SERDEV "/dev/ttyUSB0" +# define CONFIG_SYSTEM_COMPOSITE_SERDEV "/dev/ttyUSB0" # endif #endif -#ifndef CONFIG_EXAMPLES_COMPOSITE_BUFSIZE -# define CONFIG_EXAMPLES_COMPOSITE_BUFSIZE 256 +#ifndef CONFIG_SYSTEM_COMPOSITE_BUFSIZE +# define CONFIG_SYSTEM_COMPOSITE_BUFSIZE 256 #endif /* Trace initialization *****************************************************/ -#ifdef CONFIG_EXAMPLES_COMPOSITE_TRACEINIT +#ifdef CONFIG_SYSTEM_COMPOSITE_TRACEINIT # define TRACE_INIT_BITS (TRACE_INIT_BIT) #else # define TRACE_INIT_BITS (0) @@ -141,26 +137,26 @@ #define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT) -#ifdef CONFIG_EXAMPLES_COMPOSITE_TRACECLASS +#ifdef CONFIG_SYSTEM_COMPOSITE_TRACECLASS # define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|TRACE_CLASSSTATE_BIT) #else # define TRACE_CLASS_BITS (0) #endif -#ifdef CONFIG_EXAMPLES_COMPOSITE_TRACETRANSFERS +#ifdef CONFIG_SYSTEM_COMPOSITE_TRACETRANSFERS # define TRACE_TRANSFER_BITS (TRACE_OUTREQQUEUED_BIT|TRACE_INREQQUEUED_BIT|TRACE_READ_BIT|\ TRACE_WRITE_BIT|TRACE_COMPLETE_BIT) #else # define TRACE_TRANSFER_BITS (0) #endif -#ifdef CONFIG_EXAMPLES_COMPOSITE_TRACECONTROLLER +#ifdef CONFIG_SYSTEM_COMPOSITE_TRACECONTROLLER # define TRACE_CONTROLLER_BITS (TRACE_EP_BIT|TRACE_DEV_BIT) #else # define TRACE_CONTROLLER_BITS (0) #endif -#ifdef CONFIG_EXAMPLES_COMPOSITE_TRACEINTERRUPTS +#ifdef CONFIG_SYSTEM_COMPOSITE_TRACEINTERRUPTS # define TRACE_INTERRUPT_BITS (TRACE_INTENTRY_BIT|TRACE_INTDECODE_BIT|TRACE_INTEXIT_BIT) #else # define TRACE_INTERRUPT_BITS (0) @@ -193,16 +189,16 @@ * Public Types ****************************************************************************/ -/* All global variables used by this example are packed into a structure in +/* All global variables used by this add-on are packed into a structure in * order to avoid name collisions. */ struct composite_state_s { - /* This is the handle that references to this particular USB composite driver - * instance. It is only needed if the example is built using - * CONFIG_NSH_BUILTIN_APPS. In this case, the value of the driver handle - * must be remembered between the 'conn' and 'disconn' commands. + /* This is the handle that references to this particular USB composite + * driver instance. It is only needed if the add-on is built using + * CONFIG_NSH_BUILTIN_APPS. In this case, the value of the driver handle + * must be remembered between the 'conn' and 'disconn' commands. */ FAR void *cmphandle; /* Composite device handle */ @@ -219,7 +215,7 @@ struct composite_state_s * usage and for tracking down memoryh leaks. */ -#ifdef CONFIG_EXAMPLES_COMPOSITE_DEBUGMM +#ifdef CONFIG_SYSTEM_COMPOSITE_DEBUGMM struct mallinfo mmstart; /* Memory usage before the connection */ struct mallinfo mmprevious; /* The last memory usage sample */ struct mallinfo mmcurrent; /* The current memory usage sample */ @@ -228,7 +224,7 @@ struct composite_state_s /* Serial I/O buffer */ #if !defined(CONFIG_NSH_BUILTIN_APPS) || defined(CONFIG_DISABLE_SIGNALS) - uint8_t serbuf[CONFIG_EXAMPLES_COMPOSITE_BUFSIZE]; + uint8_t serbuf[CONFIG_SYSTEM_COMPOSITE_BUFSIZE]; #endif }; @@ -236,7 +232,7 @@ struct composite_state_s * Public Data ****************************************************************************/ -/* All global variables used by this example are packed into a structure in +/* All global variables used by this add-on are packed into a structure in * order to avoid name collisions. */ @@ -256,4 +252,4 @@ extern struct composite_state_s g_composite; extern int composite_archinitialize(void); -#endif /* __EXAMPLES_COMPOSITE_COMPOSITE_H */ +#endif /* __SYSTEM_COMPOSITE_COMPOSITE_H */ diff --git a/examples/composite/composite_main.c b/system/composite/composite_main.c similarity index 93% rename from examples/composite/composite_main.c rename to system/composite/composite_main.c index 744c64096..b34d38b99 100644 --- a/examples/composite/composite_main.c +++ b/system/composite/composite_main.c @@ -1,7 +1,7 @@ /**************************************************************************** - * examples/composite/composite_main.c + * system/composite/composite_main.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -63,7 +63,7 @@ * Private Data ****************************************************************************/ -/* All global variables used by this example are packed into a structure in +/* All global variables used by this add-on are packed into a structure in * order to avoid name collisions. */ @@ -77,7 +77,7 @@ struct composite_state_s g_composite; * Name: show_memory_usage ****************************************************************************/ -#ifdef CONFIG_EXAMPLES_COMPOSITE_DEBUGMM +#ifdef CONFIG_SYSTEM_COMPOSITE_DEBUGMM static void show_memory_usage(struct mallinfo *mmbefore, struct mallinfo *mmafter) { @@ -107,7 +107,7 @@ static void show_memory_usage(struct mallinfo *mmbefore, * Name: check_test_memory_usage ****************************************************************************/ -#ifdef CONFIG_EXAMPLES_COMPOSITE_DEBUGMM +#ifdef CONFIG_SYSTEM_COMPOSITE_DEBUGMM static void check_test_memory_usage(FAR const char *msg) { /* Get the current memory usage */ @@ -139,7 +139,7 @@ static void check_test_memory_usage(FAR const char *msg) * Name: check_test_memory_usage ****************************************************************************/ -#ifdef CONFIG_EXAMPLES_COMPOSITE_DEBUGMM +#ifdef CONFIG_SYSTEM_COMPOSITE_DEBUGMM static void final_memory_usage(FAR const char *msg) { /* Get the current memory usage */ @@ -382,12 +382,12 @@ static int open_serial(void) do { message("open_serial: Opening USB serial driver\n"); - g_composite.outfd = open(CONFIG_EXAMPLES_COMPOSITE_SERDEV, O_WRONLY); + g_composite.outfd = open(CONFIG_SYSTEM_COMPOSITE_SERDEV, O_WRONLY); if (g_composite.outfd < 0) { errcode = errno; message("open_serial: ERROR: Failed to open %s for writing: %d\n", - CONFIG_EXAMPLES_COMPOSITE_SERDEV, errcode); + CONFIG_SYSTEM_COMPOSITE_SERDEV, errcode); /* ENOTCONN means that the USB device is not yet connected */ @@ -421,12 +421,12 @@ static int open_serial(void) /* Open the USB serial device for reading (non-blocking) */ - g_composite.infd = open(CONFIG_EXAMPLES_COMPOSITE_SERDEV, O_RDONLY|O_NONBLOCK); + g_composite.infd = open(CONFIG_SYSTEM_COMPOSITE_SERDEV, O_RDONLY|O_NONBLOCK); if (g_composite.infd < 0) { errcode = errno; message("open_serial: ERROR: Failed to open%s for reading: %d\n", - CONFIG_EXAMPLES_COMPOSITE_SERDEV, errcode); + CONFIG_SYSTEM_COMPOSITE_SERDEV, errcode); close(g_composite.outfd); return -errcode; } @@ -448,7 +448,7 @@ static int echo_serial(void) /* Read data */ - bytesread = read(g_composite.infd, g_composite.serbuf, CONFIG_EXAMPLES_COMPOSITE_BUFSIZE); + bytesread = read(g_composite.infd, g_composite.serbuf, CONFIG_SYSTEM_COMPOSITE_BUFSIZE); if (bytesread < 0) { errcode = errno; @@ -517,8 +517,8 @@ int board_mscclassobject(FAR struct usbdevclass_driver_s **classdev) /* Configure the mass storage device */ - message("board_mscclassobject: Configuring with NLUNS=%d\n", CONFIG_EXAMPLES_COMPOSITE_NLUNS); - ret = usbmsc_configure(CONFIG_EXAMPLES_COMPOSITE_NLUNS, &g_composite.mschandle); + message("board_mscclassobject: Configuring with NLUNS=%d\n", CONFIG_SYSTEM_COMPOSITE_NLUNS); + ret = usbmsc_configure(CONFIG_SYSTEM_COMPOSITE_NLUNS, &g_composite.mschandle); if (ret < 0) { message("board_mscclassobject: usbmsc_configure failed: %d\n", -ret); @@ -529,38 +529,38 @@ int board_mscclassobject(FAR struct usbdevclass_driver_s **classdev) /* Bind the LUN(s) */ - message("board_mscclassobject: Bind LUN=0 to %s\n", CONFIG_EXAMPLES_COMPOSITE_DEVPATH1); - ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_EXAMPLES_COMPOSITE_DEVPATH1, 0, 0, 0, false); + message("board_mscclassobject: Bind LUN=0 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH1); + ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH1, 0, 0, 0, false); if (ret < 0) { message("board_mscclassobject: usbmsc_bindlun failed for LUN 1 using %s: %d\n", - CONFIG_EXAMPLES_COMPOSITE_DEVPATH1, -ret); + CONFIG_SYSTEM_COMPOSITE_DEVPATH1, -ret); usbmsc_uninitialize(g_composite.mschandle); return ret; } check_test_memory_usage("After usbmsc_bindlun()"); -#if CONFIG_EXAMPLES_COMPOSITE_NLUNS > 1 +#if CONFIG_SYSTEM_COMPOSITE_NLUNS > 1 - message("board_mscclassobject: Bind LUN=1 to %s\n", CONFIG_EXAMPLES_COMPOSITE_DEVPATH2); - ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_EXAMPLES_COMPOSITE_DEVPATH2, 1, 0, 0, false); + message("board_mscclassobject: Bind LUN=1 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH2); + ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH2, 1, 0, 0, false); if (ret < 0) { message("board_mscclassobject: usbmsc_bindlun failed for LUN 2 using %s: %d\n", - CONFIG_EXAMPLES_COMPOSITE_DEVPATH2, -ret); + CONFIG_SYSTEM_COMPOSITE_DEVPATH2, -ret); usbmsc_uninitialize(g_composite.mschandle); return ret; } check_test_memory_usage("After usbmsc_bindlun() #2"); -#if CONFIG_EXAMPLES_COMPOSITE_NLUNS > 2 +#if CONFIG_SYSTEM_COMPOSITE_NLUNS > 2 - message("board_mscclassobject: Bind LUN=2 to %s\n", CONFIG_EXAMPLES_COMPOSITE_DEVPATH3); - ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_EXAMPLES_COMPOSITE_DEVPATH3, 2, 0, 0, false); + message("board_mscclassobject: Bind LUN=2 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH3); + ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH3, 2, 0, 0, false); if (ret < 0) { message("board_mscclassobject: usbmsc_bindlun failed for LUN 3 using %s: %d\n", - CONFIG_EXAMPLES_COMPOSITE_DEVPATH3, -ret); + CONFIG_SYSTEM_COMPOSITE_DEVPATH3, -ret); usbmsc_uninitialize(g_composite.mschandle); return ret; } @@ -629,7 +629,7 @@ int board_cdcclassobject(FAR struct usbdevclass_driver_s **classdev) /* Initialize the USB serial driver */ message("board_cdcclassobject: Initializing USB serial driver\n"); - ret = cdcacm_classobject(CONFIG_EXAMPLES_COMPOSITE_TTYUSB, classdev); + ret = cdcacm_classobject(CONFIG_SYSTEM_COMPOSITE_TTYUSB, classdev); if (ret < 0) { message("board_cdcclassobject: ERROR: Failed to create the USB serial device: %d\n", -ret); @@ -692,7 +692,7 @@ int conn_main(int argc, char *argv[]) } #endif -#ifdef CONFIG_EXAMPLES_COMPOSITE_DEBUGMM +#ifdef CONFIG_SYSTEM_COMPOSITE_DEBUGMM # ifdef CONFIG_CAN_PASS_STRUCTS g_composite.mmstart = mallinfo(); g_composite.mmprevious = g_composite.mmstart;