From 09c8278b8677125f5160be9593fccfd53286bbfc Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 14 Apr 2014 12:26:49 -0600 Subject: examples/touchscreen: Add a configuration option to indicate that there is or is not an architecture-specific initialization function --- apps/ChangeLog.txt | 3 ++- apps/examples/touchscreen/Kconfig | 21 +++++++++++++++++++++ apps/examples/touchscreen/tc_main.c | 6 ++++++ nuttx/arch/arm/src/stm32/stm32_otgfshost.c | 10 +++++----- nuttx/configs/hymini-stm32v/nsh2/defconfig | 1 + nuttx/configs/mikroe-stm32f4/fulldemo/defconfig | 1 + nuttx/configs/olimex-lpc1766stk/hidmouse/defconfig | 1 + nuttx/configs/sim/nsh2/defconfig | 1 + nuttx/configs/sim/touchscreen/defconfig | 1 + nuttx/drivers/usbhost/usbhost_enumerate.c | 2 +- 10 files changed, 40 insertions(+), 7 deletions(-) diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index b6c06124d..a413f580f 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -884,4 +884,5 @@ three smaller files (2014-4-11). * apps/netutils/ntpclient/ntpclient.c: Corrections to the NTP client from Manuel Stuehn (2014-4-12). - + * apps/examples/touchscreen: Add a configuration option to indicate if + architecture-specific initialized is required, yes or no (2014-4-14). diff --git a/apps/examples/touchscreen/Kconfig b/apps/examples/touchscreen/Kconfig index 5e7739c35..b75546c8b 100644 --- a/apps/examples/touchscreen/Kconfig +++ b/apps/examples/touchscreen/Kconfig @@ -43,4 +43,25 @@ config EXAMPLES_TOUCHSCREEN_MOUSE The touchscreen test can also be configured to work with a mouse driver by setting this option. +config EXAMPLES_TOUCHSCREEN_ARCHINIT + bool "Architecture-specific initialization" + default y + ---help--- + By default, the touchscreen example will call arch_tcinitialize() to + register the touchscreen device before it attempts to open it. + Similarly, it will call arch_tcuninitialize() to unregister the + touchscreen device when it is finished. + + This works well for the typical touchscreen controller but there are + other devices that cannot be initialized and uninitialized in this + fashion. Consider a USB mouse, fo example. The USB mouse will be + registered when the mouse is connected and unregistered when the + mouse is disconnected. + + So, in cases like this, there are two options: (1) provide dummy + arch_tcinitialize() and arch_tcuninitialize() just to satisfy the + linking requirements or, (2) select this option. if this option is + de-selected, then the arch_tcinitialize() and arch_tcuninitialize() will + never be called. + endif diff --git a/apps/examples/touchscreen/tc_main.c b/apps/examples/touchscreen/tc_main.c index 0eb83ca4e..1c20712a3 100644 --- a/apps/examples/touchscreen/tc_main.c +++ b/apps/examples/touchscreen/tc_main.c @@ -118,6 +118,7 @@ int tc_main(int argc, char *argv[]) message("tc_main: nsamples: %d\n", CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES); #endif +#ifdef CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT /* Initialization of the touchscreen hardware is performed by logic * external to this test. */ @@ -130,6 +131,7 @@ int tc_main(int argc, char *argv[]) errval = 1; goto errout; } +#endif /* Open the touchscreen device for reading */ @@ -249,8 +251,12 @@ int tc_main(int argc, char *argv[]) errout_with_dev: close(fd); + errout_with_tc: +#ifdef CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT arch_tcuninitialize(); +#endif + errout: message("Terminating!\n"); msgflush(); diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfshost.c b/nuttx/arch/arm/src/stm32/stm32_otgfshost.c index b7d39f93f..e43e246a0 100644 --- a/nuttx/arch/arm/src/stm32/stm32_otgfshost.c +++ b/nuttx/arch/arm/src/stm32/stm32_otgfshost.c @@ -640,7 +640,7 @@ static int stm32_chan_alloc(FAR struct stm32_usbhost_s *priv) /* Search the table of channels */ - for (chidx = 0 ; chidx < STM32_NHOST_CHANNELS ; chidx++) + for (chidx = 0; chidx < STM32_NHOST_CHANNELS; chidx++) { /* Is this channel available? */ @@ -693,7 +693,7 @@ static inline void stm32_chan_freeall(FAR struct stm32_usbhost_s *priv) /* Free all host channels */ - for (chidx = 2; chidx < STM32_NHOST_CHANNELS ; chidx ++) + for (chidx = 2; chidx < STM32_NHOST_CHANNELS; chidx ++) { stm32_chan_free(priv, chidx); } @@ -3232,8 +3232,8 @@ static int stm32_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx) /* Configure control channels */ - stm32_chan_configure(priv, priv->ep0out) ; - stm32_chan_configure(priv, priv->ep0in) ; + stm32_chan_configure(priv, priv->ep0out); + stm32_chan_configure(priv, priv->ep0in); /* Let the common usbhost_enumerate do all of the real work. Note that the * FunctionAddress (USB address) is hardcoded to one. @@ -3412,7 +3412,7 @@ static int stm32_epalloc(FAR struct usbhost_driver_s *drvr, /* Then configure the endpoint */ - stm32_chan_configure(priv, chidx) ; + stm32_chan_configure(priv, chidx); /* Return the index to the allocated channel as the endpoint "handle" */ diff --git a/nuttx/configs/hymini-stm32v/nsh2/defconfig b/nuttx/configs/hymini-stm32v/nsh2/defconfig index c95f1618c..b76f27cf2 100644 --- a/nuttx/configs/hymini-stm32v/nsh2/defconfig +++ b/nuttx/configs/hymini-stm32v/nsh2/defconfig @@ -720,6 +720,7 @@ CONFIG_EXAMPLES_NXIMAGE=y CONFIG_EXAMPLES_TOUCHSCREEN=y CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0 CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0" +CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT=y # CONFIG_EXAMPLES_UDP is not set # CONFIG_EXAMPLES_UIP is not set # CONFIG_EXAMPLES_USBSERIAL is not set diff --git a/nuttx/configs/mikroe-stm32f4/fulldemo/defconfig b/nuttx/configs/mikroe-stm32f4/fulldemo/defconfig index 84be85eb6..e51238b92 100644 --- a/nuttx/configs/mikroe-stm32f4/fulldemo/defconfig +++ b/nuttx/configs/mikroe-stm32f4/fulldemo/defconfig @@ -1009,6 +1009,7 @@ CONFIG_EXAMPLES_NX_NOTIFYSIGNO=4 CONFIG_EXAMPLES_TOUCHSCREEN=y CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0 CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0" +CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT=y # CONFIG_EXAMPLES_TOUCHSCREEN_MOUSE is not set # CONFIG_EXAMPLES_UDP is not set # CONFIG_EXAMPLES_UIP is not set diff --git a/nuttx/configs/olimex-lpc1766stk/hidmouse/defconfig b/nuttx/configs/olimex-lpc1766stk/hidmouse/defconfig index c1c437825..f4fd85821 100644 --- a/nuttx/configs/olimex-lpc1766stk/hidmouse/defconfig +++ b/nuttx/configs/olimex-lpc1766stk/hidmouse/defconfig @@ -675,6 +675,7 @@ CONFIG_EXAMPLES_TOUCHSCREEN=y CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0 CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/mouse0" CONFIG_EXAMPLES_TOUCHSCREEN_MOUSE=y +CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT=y # CONFIG_EXAMPLES_UDP is not set # CONFIG_EXAMPLES_DISCOVER is not set # CONFIG_EXAMPLES_UIP is not set diff --git a/nuttx/configs/sim/nsh2/defconfig b/nuttx/configs/sim/nsh2/defconfig index 87c8c0b6a..efb61a688 100644 --- a/nuttx/configs/sim/nsh2/defconfig +++ b/nuttx/configs/sim/nsh2/defconfig @@ -520,6 +520,7 @@ CONFIG_EXAMPLES_NXLINES_BPP=32 CONFIG_EXAMPLES_TOUCHSCREEN=y CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0 CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0" +CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT=y # CONFIG_EXAMPLES_TOUCHSCREEN_MOUSE is not set # CONFIG_EXAMPLES_UDP is not set # CONFIG_EXAMPLES_UIP is not set diff --git a/nuttx/configs/sim/touchscreen/defconfig b/nuttx/configs/sim/touchscreen/defconfig index bdb1b3d30..f9d98cb5e 100644 --- a/nuttx/configs/sim/touchscreen/defconfig +++ b/nuttx/configs/sim/touchscreen/defconfig @@ -515,6 +515,7 @@ CONFIG_EXAMPLES_TOUCHSCREEN=y CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0 CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0" CONFIG_EXAMPLES_TOUCHSCREEN_NSAMPLES=25 +CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT=y # CONFIG_EXAMPLES_TOUCHSCREEN_MOUSE is not set # CONFIG_EXAMPLES_UDP is not set # CONFIG_EXAMPLES_UIP is not set diff --git a/nuttx/drivers/usbhost/usbhost_enumerate.c b/nuttx/drivers/usbhost/usbhost_enumerate.c index 1857499ed..d8bcc9c02 100644 --- a/nuttx/drivers/usbhost/usbhost_enumerate.c +++ b/nuttx/drivers/usbhost/usbhost_enumerate.c @@ -179,7 +179,7 @@ static inline int usbhost_configdesc(const uint8_t *configdesc, int cfglen, configdesc += cfgdesc->len; remaining = cfglen - cfgdesc->len; - /* Loop where there are more dscriptors to examine */ + /* Loop while there are more descriptors to examine */ memset(id, 0, sizeof(FAR struct usb_desc_s)); while (remaining >= sizeof(struct usb_desc_s)) -- cgit v1.2.3