diff --git a/arch/arm/src/samdl/chip/samd_eic.h b/arch/arm/src/samdl/chip/samd_eic.h index 9bbd0dc4feb..adc89821244 100644 --- a/arch/arm/src/samdl/chip/samd_eic.h +++ b/arch/arm/src/samdl/chip/samd_eic.h @@ -6,7 +6,7 @@ * Matt Thompson * * References: - * "Microchip SAMD21 datasheet" + * "Microchip SAMD21 datasheet" * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -116,7 +116,6 @@ #define EIC_EXTINT_SHIFT (0) /* Bits 0-15: External interrupt n */ #define EIC_EXTINT_MASK (0x3ffff << EIC_EXTINT_SHIFT) -//# define EIC_EXTINT(n) ((uint32_t)(n) << EIC_EXTINT_SHIFT) # define EIC_EXTINT(n) (1 << (n)) # define EIC_EXTINT_0 (1 << 0) /* Bit 0: External interrupt 0 */ # define EIC_EXTINT_1 (1 << 1) /* Bit 1: External interrupt 1 */ diff --git a/arch/arm/src/samdl/chip/saml_eic.h b/arch/arm/src/samdl/chip/saml_eic.h index e6bb167e2eb..56d91824ec4 100644 --- a/arch/arm/src/samdl/chip/saml_eic.h +++ b/arch/arm/src/samdl/chip/saml_eic.h @@ -123,7 +123,7 @@ #define EIC_EXTINT_SHIFT (0) /* Bits 0-15: External interrupt n */ #define EIC_EXTINT_MASK (0xffff << EIC_EXTINT_SHIFT) -# define EIC_EXTINT(n) ((uint32_t)(n) << EIC_EXTINT_SHIFT) +# define EIC_EXTINT(n) (1 << (n)) # define EIC_EXTINT_0 (1 << 0) /* Bit 0: External interrupt 0 */ # define EIC_EXTINT_1 (1 << 1) /* Bit 1: External interrupt 1 */ # define EIC_EXTINT_2 (1 << 2) /* Bit 2: External interrupt 2 */ diff --git a/arch/arm/src/samdl/sam_eic.c b/arch/arm/src/samdl/sam_eic.c index e6661548384..ff73950cc0f 100644 --- a/arch/arm/src/samdl/sam_eic.c +++ b/arch/arm/src/samdl/sam_eic.c @@ -83,16 +83,16 @@ static int sam_eic_isr(int irq, FAR void *context, FAR void *arg) for(bit=0;bit> bit & 0x1) - { - irq_dispatch(SAM_IRQ_EXTINT0 + bit, context); - } + if (intflag >> bit & 0x1) + { + irq_dispatch(SAM_IRQ_EXTINT0 + bit, context); + } } /* Clear the pending interrupt flags */ putreg32(EIC_EXTINT_ALL, SAM_EIC_INTFLAG); - + return 0; } @@ -126,7 +126,13 @@ void sam_eic_dumpregs(void) * Name: sam_eic_initialize * * Description: - * Configure the external interrupt controller. + * Initialize the external interrupt controller (EIC). + * + * Input Parameters: + * gclkgen - GCLK Generator + * + * Returned Value: + * None * ****************************************************************************/ @@ -139,7 +145,7 @@ int sam_eic_initialize(uint8_t gclkgen) regval = GCLK_CLKCTRL_ID_EIC | GCLK_CLKCTRL_GEN(gclkgen) | GCLK_CLKCTRL_CLKEN; putreg16(regval, SAM_GCLK_CLKCTRL); - putreg8(EIC_CTRLA_ENABLE, SAM_EIC_CTRLA); + putreg8(EIC_CTRLA_ENABLE, SAM_EIC_CTRLA); sam_eic_syncwait(); irq_attach(SAM_IRQ_EIC, sam_eic_isr, NULL); @@ -151,12 +157,26 @@ int sam_eic_initialize(uint8_t gclkgen) return OK; } +/**************************************************************************** + * Name: sam_eic_initialize + * + * Description: + * Enable a external interrupt. + * + * Input Parameters: + * irq - SAM_IRQ_EXTINTn IRQ to be enabled + * + * Returned Value: + * None + * + ****************************************************************************/ + int sam_eic_irq_enable(int irq) { uint32_t config; int eirq = irq - SAM_IRQ_EXTINT0; - config = getreg32(SAM_EIC_CONFIG0); + config = getreg32(SAM_EIC_CONFIG0); config |= EIC_CONFIG0_FILTEN(eirq) | EIC_CONFIG0_SENSE_FALL(eirq); putreg32(config, SAM_EIC_CONFIG0); @@ -165,6 +185,21 @@ int sam_eic_irq_enable(int irq) return OK; } +/**************************************************************************** + * Name: sam_eic_config + * + * Description: + * Configure the interrupt edge sensitivity in CONFIGn register of the EIC + * + * Input Parameters: + * eirq - Pin to be configured + * pinset - Configuration of the pin + * + * Returned Value: + * None + * + ****************************************************************************/ + int sam_eic_config(uint8_t eirq, port_pinset_t pinset) { uint32_t reg; @@ -173,18 +208,24 @@ int sam_eic_config(uint8_t eirq, port_pinset_t pinset) /* Determine which of the CONFIG[0:2] registers to write to */ - if(eirq < 8) + if (eirq < 8) { reg = SAM_EIC_CONFIG0; - + val = EIC_CONFIG0_SENSE_BOTH(eirq); - if(pinset & PORT_INT_RISING) - val = EIC_CONFIG0_SENSE_RISE(eirq); - if(pinset & PORT_INT_FALLING) - val = EIC_CONFIG0_SENSE_FALL(eirq); + if (pinset & PORT_INT_RISING) + { + val = EIC_CONFIG0_SENSE_RISE(eirq); + } + + if (pinset & PORT_INT_FALLING) + { + val = EIC_CONFIG0_SENSE_FALL(eirq); + } + val |= EIC_CONFIG0_FILTEN(eirq); } - else if(eirq < 16) + else if (eirq < 16) { reg = SAM_EIC_CONFIG1; val = EIC_CONFIG1_FILTEN(eirq) | EIC_CONFIG1_SENSE_FALL(eirq); @@ -197,7 +238,7 @@ int sam_eic_config(uint8_t eirq, port_pinset_t pinset) /* Write the new config to the CONFIGn register */ - config = getreg32(reg); + config = getreg32(reg); config |= val; putreg32(config, reg); @@ -206,6 +247,5 @@ int sam_eic_config(uint8_t eirq, port_pinset_t pinset) putreg32(EIC_EXTINT(eirq), SAM_EIC_INTENSET); sam_eic_dumpregs(); - return OK; } diff --git a/arch/arm/src/samdl/sam_eic.h b/arch/arm/src/samdl/sam_eic.h index b149d182ea2..d60c936cef5 100644 --- a/arch/arm/src/samdl/sam_eic.h +++ b/arch/arm/src/samdl/sam_eic.h @@ -57,19 +57,7 @@ #endif /**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Data + * Public Function Prototypes ****************************************************************************/ #undef EXTERN @@ -82,14 +70,10 @@ extern "C" #endif /**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: sam_eic_configure + * Name: sam_eic_initialize * * Description: - * Configure the EIC + * Initialize the EIC * * Input Parameters: * gclkgen - GCLK Generator @@ -100,6 +84,38 @@ extern "C" ****************************************************************************/ int sam_eic_initialize(uint8_t gclkgen); + +/**************************************************************************** + * Name: sam_eic_initialize + * + * Description: + * Enable a external interrupt. + * + * Input Parameters: + * irq - SAM_IRQ_EXTINTn IRQ to be enabled + * + * Returned Value: + * None + * + ****************************************************************************/ + +int sam_eic_irq_enable(int irq); + +/**************************************************************************** + * Name: sam_eic_config + * + * Description: + * Configure the interrupt edge sensitivity in CONFIGn register of the EIC + * + * Input Parameters: + * eirq - Pin to be configured + * pinset - Configuration of the pin + * + * Returned Value: + * None + * + ****************************************************************************/ + int sam_eic_config(uint8_t eirq, port_pinset_t pinset); #undef EXTERN diff --git a/arch/arm/src/samdl/sam_port.c b/arch/arm/src/samdl/sam_port.c index 19be6f030fd..df35aae65a7 100644 --- a/arch/arm/src/samdl/sam_port.c +++ b/arch/arm/src/samdl/sam_port.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/samdl/sam_port.c * - * Copyright (C) 2014-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -190,13 +190,15 @@ static inline void sam_configinput(uintptr_t base, port_pinset_t pinset) static inline void sam_configinterrupt(uintptr_t base, port_pinset_t pinset) { +#ifdef CONFIG_SAMDL_EIC uint32_t func; uint32_t regval; int pin; - pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT; + pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT; - regval = (PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX | PORT_WRCONFIG_PMUXEN | PORT_WRCONFIG_INEN); + regval = (PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX | + PORT_WRCONFIG_PMUXEN | PORT_WRCONFIG_INEN); regval |= PORT_WRCONFIG_PINMASK(pin); func = (pinset & PORT_FUNC_MASK) >> PORT_FUNC_SHIFT; @@ -211,6 +213,7 @@ static inline void sam_configinterrupt(uintptr_t base, port_pinset_t pinset) #ifdef CONFIG_DEBUG_GPIO_INFO sam_dumpport(pinset, "extint"); #endif +#endif /* CONFIG_SAMDL_EIC */ } /**************************************************************************** @@ -552,7 +555,7 @@ int sam_dumpport(uint32_t pinset, const char *msg) /* Get the base address associated with the PIO port */ - pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT; + pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT; port = (pinset & PORT_MASK) >> PORT_SHIFT; base = SAM_PORTN_BASE(port); diff --git a/configs/Kconfig b/configs/Kconfig index c278ece1e8d..bf770edd1dc 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -2351,15 +2351,6 @@ config BOARDCTL_USBDEVCTRL ---help--- Enables support for the BOARDIOC_USBDEV_CONTROL boardctl() command. -config BOARDCTL_TSCTEST - bool "Enable touchscreen test interfaces" - default n - ---help--- - Enables support for the BOARDIOC_TSCTEST_SETUP and - BOARDIOC_TSCTEST_TEARDOWN boardctl() commands. Architecture - specific logic must provide board_tsc_setup() and - board_tsc_teardown() interfaces. - config BOARDCTL_IOCTL bool "Board-specific boardctl() commands" default n diff --git a/configs/arduino-due/src/arduino-due.h b/configs/arduino-due/src/arduino-due.h index 0e2b6736b34..01768855d76 100644 --- a/configs/arduino-due/src/arduino-due.h +++ b/configs/arduino-due/src/arduino-due.h @@ -166,7 +166,7 @@ * and the SD card. * 2. UART0 cannot be used. USARTs on the COMM connector should be available. * 3. Parallel data is not contiguous in the PIO register - * 4. Touchcontroller /CS pin is connected to ground (always selected). + * 4. Touch controller /CS pin is connected to ground (always selected). * 5. Either PA28 or PC29 may drive PWM10 */ @@ -308,7 +308,7 @@ * Public Functions ************************************************************************************/ -/**************************************************************************** +/************************************************************************************ * Name: sam_bringup * * Description: @@ -320,23 +320,44 @@ * CONFIG_BOARD_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y : * Called from the NSH library * - ****************************************************************************/ + ************************************************************************************/ int sam_bringup(void); -/**************************************************************************** +/************************************************************************************ * Name: sam_sdinitialize * * Description: * Initialize the SPI-based SD card. * - ****************************************************************************/ + ************************************************************************************/ #if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \ defined(CONFIG_MMCSD_SPI) int sam_sdinitialize(int minor); #endif +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ************************************************************************************/ + +#if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \ + defined(CONFIG_INPUT_ADS7843E) +int sam_tsc_setup(int minor); +#endif #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_ARDUINO_DUE_SRC_ARDUNO_DUE_H */ diff --git a/configs/arduino-due/src/sam_bringup.c b/configs/arduino-due/src/sam_bringup.c index 298a5b0dbb9..50dc141500b 100644 --- a/configs/arduino-due/src/sam_bringup.c +++ b/configs/arduino-due/src/sam_bringup.c @@ -118,6 +118,17 @@ int sam_bringup(void) } #endif +#if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \ + defined(CONFIG_INPUT_ADS7843E) + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + UNUSED(ret); return OK; } diff --git a/configs/arduino-due/src/sam_touchscreen.c b/configs/arduino-due/src/sam_touchscreen.c index 4e78c9376a1..48dae4c1625 100644 --- a/configs/arduino-due/src/sam_touchscreen.c +++ b/configs/arduino-due/src/sam_touchscreen.c @@ -336,13 +336,12 @@ static FAR struct spi_dev_s *sam_tsc_spiinitialize(void) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -353,79 +352,42 @@ static FAR struct spi_dev_s *sam_tsc_spiinitialize(void) * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { FAR struct spi_dev_s *dev; - static bool initialized = false; int ret; iinfo("minor %d\n", minor); DEBUGASSERT(minor == 0); - /* Have we already initialized? Since we never uninitialize we must prevent - * multiple initializations. This is necessary, for example, when the - * touchscreen example is used as a built-in application in NSH and can be - * called numerous time. It will attempt to initialize each time. - */ + /* Configure and enable the XPT2046 interrupt pin as an input */ - if (!initialized) + (void)sam_configgpio(GPIO_TSC_IRQ); + + /* Configure the PIO interrupt */ + + sam_gpioirq(SAM_TSC_IRQ); + + /* Get an instance of the SPI interface for the touchscreen chip select */ + + dev = sam_tsc_spiinitialize(); + if (!dev) { - /* Configure and enable the XPT2046 interrupt pin as an input */ + ierr("ERROR: Failed to initialize bit bang SPI\n"); + return -ENODEV; + } - (void)sam_configgpio(GPIO_TSC_IRQ); + /* Initialize and register the SPI touschscreen device */ - /* Configure the PIO interrupt */ - - sam_gpioirq(SAM_TSC_IRQ); - - /* Get an instance of the SPI interface for the touchscreen chip select */ - - dev = sam_tsc_spiinitialize(); - if (!dev) - { - ierr("ERROR: Failed to initialize bit bang SPI\n"); - return -ENODEV; - } - - /* Initialize and register the SPI touschscreen device */ - - ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device\n"); - /* up_spiuninitialize(dev); */ - return -ENODEV; - } - - /* Now we are initialized */ - - initialized = true; + ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device\n"); + /* up_spiuninitialize(dev); */ + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen XPT2046 device. It will - * continue to run and process touch interrupts in the background. - */ -} - #endif /* CONFIG_ARDUINO_ITHEAD_TFT && CONFIG_SPI_BITBANG && CONFIG_INPUT_ADS7843E */ diff --git a/configs/boardctl.c b/configs/boardctl.c index d5404711354..d7e6d3c4ee6 100644 --- a/configs/boardctl.c +++ b/configs/boardctl.c @@ -401,35 +401,6 @@ int boardctl(unsigned int cmd, uintptr_t arg) break; #endif -#ifdef CONFIG_BOARDCTL_TSCTEST - /* CMD: BOARDIOC_TSCTEST_SETUP - * DESCRIPTION: Touchscreen controller test configuration - * ARG: Touch controller device minor number - * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST - * DEPENDENCIES: Board logic must provide board_tsc_setup() - */ - - case BOARDIOC_TSCTEST_SETUP: - { - ret = board_tsc_setup((int)arg); - } - break; - - /* CMD: BOARDIOC_TSCTEST_TEARDOWN - * DESCRIPTION: Touchscreen controller test configuration - * ARG: None - * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST - * DEPENDENCIES: Board logic must provide board_tsc_teardown() - */ - - case BOARDIOC_TSCTEST_TEARDOWN: - { - board_tsc_teardown(); - ret = OK; - } - break; -#endif - default: { #ifdef CONFIG_BOARDCTL_IOCTL diff --git a/configs/hymini-stm32v/src/hymini-stm32v.h b/configs/hymini-stm32v/src/hymini-stm32v.h index f821d03465d..cdfd96704a2 100644 --- a/configs/hymini-stm32v/src/hymini-stm32v.h +++ b/configs/hymini-stm32v/src/hymini-stm32v.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/hymini-stm32v/src/hymini-stm32v.h * - * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * Laurent Latil * @@ -122,7 +122,7 @@ * ************************************************************************************/ -extern void weak_function stm32_spidev_initialize(void); +void weak_function stm32_spidev_initialize(void); /************************************************************************************ * Name: stm32_usbinitialize @@ -132,7 +132,28 @@ extern void weak_function stm32_spidev_initialize(void); * ************************************************************************************/ -extern void weak_function stm32_usbinitialize(void); +void weak_function stm32_usbinitialize(void); + +/************************************************************************************ + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ************************************************************************************/ + +#ifdef CONFIG_INPUT +int stm32_tsc_setup(int minor); +#endif #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_HYMINI_STM32V_H */ diff --git a/configs/hymini-stm32v/src/stm32_appinit.c b/configs/hymini-stm32v/src/stm32_appinit.c index 5b99c4445b6..85be09ecb7d 100644 --- a/configs/hymini-stm32v/src/stm32_appinit.c +++ b/configs/hymini-stm32v/src/stm32_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/hymini-stm32v/src/stm32_appinit.c * - * Copyright (C) 2009, 2011, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011, 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -170,10 +170,11 @@ static int nsh_cdinterrupt(int irq, FAR void *context, FAR void *arg) int board_app_initialize(uintptr_t arg) { -#ifdef NSH_HAVEMMCSD int ret; +#ifdef NSH_HAVEMMCSD /* Card detect */ + bool cd_status; /* Configure the card detect GPIO */ @@ -220,5 +221,17 @@ int board_app_initialize(uintptr_t arg) sdio_mediachange(g_sdiodev, cd_status); #endif + +#ifdef CONFIG_INPUT + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + + UNUSED(ret); return OK; } diff --git a/configs/hymini-stm32v/src/stm32_ts.c b/configs/hymini-stm32v/src/stm32_ts.c index 781eafc9f15..59f7caa0509 100644 --- a/configs/hymini-stm32v/src/stm32_ts.c +++ b/configs/hymini-stm32v/src/stm32_ts.c @@ -53,7 +53,7 @@ #include "hymini-stm32v.h" /************************************************************************************ - * Pre-processor Defintiions + * Pre-processor Definitions ************************************************************************************/ #if !defined(CONFIG_STM32_SPI1) @@ -136,13 +136,12 @@ static bool hymini_ts_pendown(FAR struct ads7843e_config_s *state) } /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -153,7 +152,7 @@ static bool hymini_ts_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { FAR struct spi_dev_s *dev; @@ -172,24 +171,3 @@ int board_tsc_setup(int minor) return ads7843e_register(dev, &ts_cfg, minor); } - -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* FIXME What can/should we do here ? */ -} diff --git a/configs/lpcxpresso-lpc54628/README.txt b/configs/lpcxpresso-lpc54628/README.txt index 0f31315c946..2cb8625a859 100644 --- a/configs/lpcxpresso-lpc54628/README.txt +++ b/configs/lpcxpresso-lpc54628/README.txt @@ -264,7 +264,6 @@ Configurations $ telnet fc00::42 - nsh: Configures the NuttShell (nsh) application located at examples/nsh. diff --git a/configs/lpcxpresso-lpc54628/fb/defconfig b/configs/lpcxpresso-lpc54628/fb/defconfig index 2dc326a0794..afc8562724e 100644 --- a/configs/lpcxpresso-lpc54628/fb/defconfig +++ b/configs/lpcxpresso-lpc54628/fb/defconfig @@ -1,5 +1,4 @@ # CONFIG_ARCH_FPU is not set -# CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT is not set CONFIG_ARCH_BOARD_LPCXPRESSO_LPC54628=y CONFIG_ARCH_BOARD="lpcxpresso-lpc54628" CONFIG_ARCH_CHIP_LPC54628=y diff --git a/configs/lpcxpresso-lpc54628/nxwm/defconfig b/configs/lpcxpresso-lpc54628/nxwm/defconfig index 5bc987dbb5e..6bcffd4a4b5 100644 --- a/configs/lpcxpresso-lpc54628/nxwm/defconfig +++ b/configs/lpcxpresso-lpc54628/nxwm/defconfig @@ -2,7 +2,6 @@ # CONFIG_NX_DISABLE_16BPP is not set # CONFIG_NXFONTS_DISABLE_16BPP is not set # CONFIG_NXTK_DEFAULT_BORDERCOLORS is not set -# CONFIG_NXWM_TOUCHSCREEN_DEVINIT is not set CONFIG_ARCH_BOARD_LPCXPRESSO_LPC54628=y CONFIG_ARCH_BOARD="lpcxpresso-lpc54628" CONFIG_ARCH_CHIP_LPC54628=y @@ -11,7 +10,6 @@ CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH_STDARG_H=y CONFIG_ARCH="arm" -CONFIG_BOARD_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=21082 CONFIG_BUILTIN=y CONFIG_FAT_LCNAMES=y diff --git a/configs/lpcxpresso-lpc54628/src/lpc54_ft5x06.c b/configs/lpcxpresso-lpc54628/src/lpc54_ft5x06.c index 162089b190b..8893f08ff65 100644 --- a/configs/lpcxpresso-lpc54628/src/lpc54_ft5x06.c +++ b/configs/lpcxpresso-lpc54628/src/lpc54_ft5x06.c @@ -245,25 +245,4 @@ int lpc54_ft5x06_register(void) return OK; } -/**************************************************************************** - * Name: board_tsc_setup and board_tsc_teardown - * - * Description: - * Stubs for expected interfaces. This implementation does not permit the - * application to mange the touch screen controller. - * - ****************************************************************************/ - -#ifdef CONFIG_BOARDCTL_TSCTEST -int board_tsc_setup(int minor) -{ - DEBUGASSERT(minor == 0); - return OK; -} - -void board_tsc_teardown(void) -{ -} -#endif - #endif /* HAVE_FT5x06*/ diff --git a/configs/mikroe-stm32f4/fulldemo/defconfig b/configs/mikroe-stm32f4/fulldemo/defconfig index 0896fb14125..dab8c12914e 100644 --- a/configs/mikroe-stm32f4/fulldemo/defconfig +++ b/configs/mikroe-stm32f4/fulldemo/defconfig @@ -45,6 +45,7 @@ CONFIG_INTELHEX_BINARY=y CONFIG_LCD_MIO283QT2=y CONFIG_LCD=y CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_STRERROR=y CONFIG_M25P_MANUFACTURER=0x1C CONFIG_M25P_MEMORY_TYPE=0x31 diff --git a/configs/mikroe-stm32f4/src/mikroe-stm32f4.h b/configs/mikroe-stm32f4/src/mikroe-stm32f4.h index 4b8bcc3dafa..0df889c4246 100644 --- a/configs/mikroe-stm32f4/src/mikroe-stm32f4.h +++ b/configs/mikroe-stm32f4/src/mikroe-stm32f4.h @@ -1,7 +1,7 @@ /**************************************************************************************************** * configs/mikroe-stm32f4/src/mikroe-stm32f4.h * - * Copyright (C) 2011-2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -218,7 +218,7 @@ void weak_function stm32_spidev_initialize(void); * Name: stm32_usbinitialize * * Description: - * Called from stm32_usbinitialize very early in inialization to setup USB-related + * Called from stm32_usbinitialize very early in initialization to setup USB-related * GPIO pins for the Mikroe-stm32f4 board. * ****************************************************************************************************/ @@ -227,13 +227,13 @@ void weak_function stm32_spidev_initialize(void); void weak_function stm32_usbinitialize(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_pwm_setup * * Description: * Initialize PWM and register the PWM device. * - ************************************************************************************/ + ****************************************************************************************************/ #ifdef CONFIG_PWM int stm32_pwm_setup(void); @@ -252,13 +252,13 @@ int stm32_pwm_setup(void); # error "The Mikroe-STM32F4 board does not support HOST OTG, only device!" #endif -/**************************************************************************** +/**************************************************************************************************** * Name: stm32_qencoder_initialize * * Description: * Initialize and register a qencoder * - ****************************************************************************/ + ****************************************************************************************************/ #ifdef CONFIG_SENSORS_QENCODER int stm32_qencoder_initialize(FAR const char *devpath, int timer); @@ -277,6 +277,26 @@ int stm32_qencoder_initialize(FAR const char *devpath, int timer); void stm32_lcdinitialize(void); #endif +/**************************************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen device. This + * function will register the driver as /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to indicate the + * nature of the failure. + * + ****************************************************************************************************/ + +#ifdef CONFIG_INPUT +int stm32_tsc_setup(int minor); +#endif + /**************************************************************************************************** * Name: up_vs1053initialize * diff --git a/configs/mikroe-stm32f4/src/stm32_appinit.c b/configs/mikroe-stm32f4/src/stm32_appinit.c index 134f819fc4c..18028def312 100644 --- a/configs/mikroe-stm32f4/src/stm32_appinit.c +++ b/configs/mikroe-stm32f4/src/stm32_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/mikroe_stm32f4/src/stm32_appinit.c * - * Copyright (C) 2012-2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -350,6 +350,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_INPUT + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ diff --git a/configs/mikroe-stm32f4/src/stm32_touchscreen.c b/configs/mikroe-stm32f4/src/stm32_touchscreen.c index 8dfb259f48b..efdb46d9a2f 100644 --- a/configs/mikroe-stm32f4/src/stm32_touchscreen.c +++ b/configs/mikroe-stm32f4/src/stm32_touchscreen.c @@ -1474,13 +1474,12 @@ errout: ************************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -1491,7 +1490,7 @@ errout: * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { FAR struct tc_dev_s *priv; char devname[DEV_NAMELEN]; @@ -1583,25 +1582,4 @@ errout_with_priv: return ret; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* Need to unregister the /dev/inputN device here. */ -} - #endif /* CONFIG_INPUT */ diff --git a/configs/nucleo-l432kc/include/board.h b/configs/nucleo-l432kc/include/board.h index cbec4b9c37a..dbe6dbe48fa 100644 --- a/configs/nucleo-l432kc/include/board.h +++ b/configs/nucleo-l432kc/include/board.h @@ -45,7 +45,9 @@ # include #endif +#ifdef __KERNEL__ #include +#endif /************************************************************************************ * Pre-processor Definitions diff --git a/configs/nucleo-l432kc/src/nucleo-l432kc.h b/configs/nucleo-l432kc/src/nucleo-l432kc.h index a9ce4bee647..9ce05bc83d3 100644 --- a/configs/nucleo-l432kc/src/nucleo-l432kc.h +++ b/configs/nucleo-l432kc/src/nucleo-l432kc.h @@ -87,6 +87,7 @@ #define GPIO_LD2 \ (GPIO_PORTA | GPIO_PIN5 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | \ GPIO_SPEED_50MHz) +#define LED_DRIVER_PATH "/dev/userleds" /* Buttons * diff --git a/configs/nucleo-l432kc/src/stm32_appinit.c b/configs/nucleo-l432kc/src/stm32_appinit.c index 0422e0cf20c..d3a725c776a 100644 --- a/configs/nucleo-l432kc/src/stm32_appinit.c +++ b/configs/nucleo-l432kc/src/stm32_appinit.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -135,6 +136,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER) + /* Register the LED driver */ + + ret = userled_lower_initialize(LED_DRIVER_PATH); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + } +#endif + #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32L4 lower-half RTC driver */ diff --git a/configs/olimex-lpc1766stk/src/lpc1766stk.h b/configs/olimex-lpc1766stk/src/lpc1766stk.h index e591862819a..bb67e6b7efd 100644 --- a/configs/olimex-lpc1766stk/src/lpc1766stk.h +++ b/configs/olimex-lpc1766stk/src/lpc1766stk.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/olimex-lpc1766stk/src/lpc1766stk.h * - * Copyright (C) 2010-2011, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2010-2011, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -272,6 +272,27 @@ void weak_function lpc1766stk_sspdev_initialize(void); int lpc1766stk_can_setup(void); #endif +/************************************************************************************ + * Name: lpc1766stk_hidmouse_setup + * + * Description: + * This function is called by board-bringup logic to configure the HID mouse + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ************************************************************************************/ + +#ifdef CONFIG_USBHOST_HIDMOUSE +int lpc1766stk_hidmouse_setup(int minor); +#endif + #endif /* __ASSEMBLY__ */ #endif /* _CONFIGS_OLIMEX_LPC1766STK_SRC_LPC1766STK_H */ diff --git a/configs/olimex-lpc1766stk/src/lpc17_appinit.c b/configs/olimex-lpc1766stk/src/lpc17_appinit.c index 22e4858fc3e..8c3d455e9aa 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_appinit.c +++ b/configs/olimex-lpc1766stk/src/lpc17_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/olimex-lpc1766stk/src/lpc17_appinit.c * - * Copyright (C) 2010, 2013-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2013-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -362,6 +362,16 @@ int board_app_initialize(uintptr_t arg) syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret); } +#ifdef CONFIG_USBHOST_HIDMOUSE + /* Initialize the HID Mouse class */ + + ret = lpc1766stk_hidmouse_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: lpc1766stk_hidmouse_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_CAN /* Initialize CAN and register the CAN driver. */ diff --git a/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c b/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c index f583d526792..c4b6792d12f 100644 --- a/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c +++ b/configs/olimex-lpc1766stk/src/lpc17_hidmouse.c @@ -71,17 +71,15 @@ ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: lpc1766stk_hidmouse_setup * * Description: - * Each board that supports a touchscreen device must provide this - * function. This function is called by application-specific, setup logic - * to configure the USB HID mouse driver that emulates a touchscreen - * device. This function will register the driver as /dev/mouseN where N - * is the minor device number. + * This function is called by board-bringup logic to configure the HID + * mouse device. This function will register the driver as /dev/inputN + * where N is the minor device number. * * Input Parameters: - * minor - The mouse device minor number + * minor - The mouse device minor number * * Returned Value: * Zero is returned on success. Otherwise, a negated errno value is @@ -89,7 +87,7 @@ * ****************************************************************************/ -int board_tsc_setup(int minor) +int lpc1766stk_hidmouse_setup(int minor) { static bool initialized = false; int ret; @@ -132,27 +130,4 @@ int board_tsc_setup(int minor) return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the USB mouse driver. It will continue - * to run and process touch interrupts in the background. - */ -} - #endif /* CONFIG_USBHOST_HIDMOUSE */ diff --git a/configs/olimexino-stm32/can/defconfig b/configs/olimexino-stm32/can/defconfig index 0791cf78896..8ed1c496421 100644 --- a/configs/olimexino-stm32/can/defconfig +++ b/configs/olimexino-stm32/can/defconfig @@ -48,7 +48,7 @@ CONFIG_I2C=y CONFIG_IDLETHREAD_STACKSIZE=300 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_NAME_MAX=8 diff --git a/configs/olimexino-stm32/composite/defconfig b/configs/olimexino-stm32/composite/defconfig index ad25c1672df..868b2a697ef 100644 --- a/configs/olimexino-stm32/composite/defconfig +++ b/configs/olimexino-stm32/composite/defconfig @@ -66,7 +66,7 @@ CONFIG_HAVE_CXXINITIALIZE=y CONFIG_IDLETHREAD_STACKSIZE=300 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MMCSD=y diff --git a/configs/olimexino-stm32/nsh/defconfig b/configs/olimexino-stm32/nsh/defconfig index 30a421918e3..0bd53f08b20 100644 --- a/configs/olimexino-stm32/nsh/defconfig +++ b/configs/olimexino-stm32/nsh/defconfig @@ -54,7 +54,7 @@ CONFIG_HAVE_CXXINITIALIZE=y CONFIG_IDLETHREAD_STACKSIZE=300 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MMCSD=y diff --git a/configs/open1788/src/lpc17_appinit.c b/configs/open1788/src/lpc17_appinit.c index 19cc0ee0ac3..ee557911a5f 100644 --- a/configs/open1788/src/lpc17_appinit.c +++ b/configs/open1788/src/lpc17_appinit.c @@ -89,6 +89,6 @@ int board_app_initialize(uintptr_t arg) #else /* Perform board-specific initialization */ - return lpc17_bringup(); + return open1788_bringup(); #endif } diff --git a/configs/open1788/src/lpc17_boardinitialize.c b/configs/open1788/src/lpc17_boardinitialize.c index 12109ea14e7..1058f6cc7ed 100644 --- a/configs/open1788/src/lpc17_boardinitialize.c +++ b/configs/open1788/src/lpc17_boardinitialize.c @@ -137,6 +137,6 @@ void board_initialize(void) { /* Perform board-specific initialization */ - (void)lpc17_bringup(); + (void)open1788_bringup(); } #endif diff --git a/configs/open1788/src/lpc17_bringup.c b/configs/open1788/src/lpc17_bringup.c index 98a79fcf4ec..047c31df84c 100644 --- a/configs/open1788/src/lpc17_bringup.c +++ b/configs/open1788/src/lpc17_bringup.c @@ -245,12 +245,11 @@ static int nsh_sdinitialize(void) lpc17_configgpio(GPIO_SD_CD); +#ifdef NSH_HAVE_MMCSD_CDINT /* Attach an interrupt handler to get notifications when a card is * inserted or deleted. */ -#ifdef NSH_HAVE_MMCSD_CDINT - (void)irq_attach(LPC17_IRQ_P0p13, nsh_cdinterrupt, NULL); up_enable_irq(LPC17_IRQ_P0p13); @@ -361,7 +360,7 @@ static int nsh_usbhostinitialize(void) ****************************************************************************/ /**************************************************************************** - * Name: lpc17_bringup + * Name: open1788_bringup * * Description: * Perform architecture-specific initialization @@ -374,7 +373,7 @@ static int nsh_usbhostinitialize(void) * ****************************************************************************/ -int lpc17_bringup(void) +int open1788_bringup(void) { int ret; @@ -398,6 +397,16 @@ int lpc17_bringup(void) } #endif +#ifdef CONFIG_INPUT_ADS7843E + /* Initialize the touchscreen */ + + ret = open1788_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: open1788_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_OPEN1788_DJOYSTICK /* Initialize and register the joystick driver */ diff --git a/configs/open1788/src/lpc17_touchscreen.c b/configs/open1788/src/lpc17_touchscreen.c index eb63f526145..65a0f33faef 100644 --- a/configs/open1788/src/lpc17_touchscreen.c +++ b/configs/open1788/src/lpc17_touchscreen.c @@ -1,6 +1,5 @@ /************************************************************************************ * configs/open1788/src/lpc17_touchscreen.c - * arch/arm/src/board/lpc17_touchscreen.c * * Copyright (C) 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -255,13 +254,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: open1788_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this - * function. This function is called by application-specific, setup logic - * to configure the touchscreen device. This function will register the - * driver as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -272,76 +270,45 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int open1788_tsc_setup(int minor) { - static bool initialized = false; FAR struct spi_dev_s *dev; int ret; - iinfo("initialized:%d minor:%d\n", initialized, minor); + iinfo("minor:%d\n", minor); DEBUGASSERT(minor == 0); - /* Since there is no uninitialized logic, this initialization can be - * performed only one time. - */ + /* Configure and enable the XPT2046 PENIRQ pin as an interrupting input. */ - if (!initialized) - { - /* Configure and enable the XPT2046 PENIRQ pin as an interrupting input. */ + (void)lpc17_configgpio(GPIO_TC_PENIRQ); - (void)lpc17_configgpio(GPIO_TC_PENIRQ); - - /* Configure the XPT2046 BUSY pin as a normal input. */ + /* Configure the XPT2046 BUSY pin as a normal input. */ #ifndef XPT2046_NO_BUSY - (void)lpc17_configgpio(GPIO_TC_BUSY); + (void)lpc17_configgpio(GPIO_TC_BUSY); #endif - /* Get an instance of the SPI interface */ + /* Get an instance of the SPI interface */ - dev = lpc17_sspbus_initialize(CONFIG_ADS7843E_SPIDEV); - if (!dev) - { - ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV); - return -ENODEV; - } + dev = lpc17_sspbus_initialize(CONFIG_ADS7843E_SPIDEV); + if (!dev) + { + ierr("ERROR: Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV); + return -ENODEV; + } - /* Initialize and register the SPI touchscreen device */ + /* Initialize and register the SPI touchscreen device */ - ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device minor=%d\n", - CONFIG_ADS7843E_DEVMINOR); - /* up_spiuninitialize(dev); */ - return -ENODEV; - } - - initialized = true; + ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device minor=%d\n", + CONFIG_ADS7843E_DEVMINOR); + /* up_spiuninitialize(dev); */ + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen XPT2046 device yet */ -} - #endif /* CONFIG_INPUT_ADS7843E */ diff --git a/configs/open1788/src/open1788.h b/configs/open1788/src/open1788.h index 589d78b261b..4a8254348bc 100644 --- a/configs/open1788/src/open1788.h +++ b/configs/open1788/src/open1788.h @@ -2,7 +2,7 @@ * configs/open1788/src/open1788.h * arch/arm/src/board/open1788.n * - * Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -162,7 +162,7 @@ ************************************************************************************/ /************************************************************************************ - * Name: lpc17_bringup + * Name: open1788_bringup * * Description: * Perform architecture-specific initialization @@ -175,7 +175,7 @@ * ************************************************************************************/ -int lpc17_bringup(void); +int open1788_bringup(void); /************************************************************************************ * Name: open1788_sspdev_initialize @@ -237,13 +237,34 @@ void open1788_nand_initialize(void); void open1788_lcd_initialize(void); #endif -/**************************************************************************** +/************************************************************************************ + * Name: open1788_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ************************************************************************************/ + +#ifdef CONFIG_INPUT_ADS7843E +int open1788_tsc_setup(int minor); +#endif + +/************************************************************************************ * Name: lpc17_djoy_initialization * * Description: * Initialize and register the discrete joystick driver * - ****************************************************************************/ + ************************************************************************************/ #ifdef CONFIG_OPEN1788_DJOYSTICK int lpc17_djoy_initialization(void); diff --git a/configs/pic32mx7mmb/src/pic32_bringup.c b/configs/pic32mx7mmb/src/pic32_bringup.c index c082621356e..81fc7e98e70 100644 --- a/configs/pic32mx7mmb/src/pic32_bringup.c +++ b/configs/pic32mx7mmb/src/pic32_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/pic32mx7mmb/src/pic32_bringup.c * - * Copyright (C) 2012, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -407,5 +407,15 @@ int pic32mx_bringup(void) ret = nsh_usbdevinitialize(); } +#ifdef CONFIG_INPUT + /* Initialize the touchscreen */ + + ret = pic32mx_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: pic32mx_tsc_setup failed: %d\n", ret); + } +#endif + return ret; } diff --git a/configs/pic32mx7mmb/src/pic32_touchscreen.c b/configs/pic32mx7mmb/src/pic32_touchscreen.c index 950d1fc8671..3974d6a3587 100644 --- a/configs/pic32mx7mmb/src/pic32_touchscreen.c +++ b/configs/pic32mx7mmb/src/pic32_touchscreen.c @@ -1343,13 +1343,12 @@ errout: ************************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: pic32mx_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -1360,7 +1359,7 @@ errout: * ****************************************************************************/ -int board_tsc_setup(int minor) +int pic32mx_tsc_setup(int minor) { FAR struct tc_dev_s *priv; char devname[DEV_NAMELEN]; @@ -1435,25 +1434,4 @@ errout_with_priv: return ret; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* Need to unregister the /dev/inputN device here. */ -} - #endif /* CONFIG_INPUT */ diff --git a/configs/pic32mx7mmb/src/pic32mx7mmb.h b/configs/pic32mx7mmb/src/pic32mx7mmb.h index da60ef9b6fc..f28e0cb901f 100644 --- a/configs/pic32mx7mmb/src/pic32mx7mmb.h +++ b/configs/pic32mx7mmb/src/pic32mx7mmb.h @@ -1,7 +1,7 @@ /**************************************************************************** * configs/pic32mx7mmb/src/pic32mx7mmb.h * - * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -119,33 +119,33 @@ extern "C" { #define EXTERN extern #endif -/************************************************************************************ +/**************************************************************************** * Name: pic32mx_spidev_initialize * * Description: - * Called to configure SPI chip select GPIO pins for the Mikroelektronika PIC32MX7 - * MMB board. + * Called to configure SPI chip select GPIO pins for the Mikroelektronika + * PIC32MX7 MMB board. * - ************************************************************************************/ + ****************************************************************************/ #if defined(CONFIG_PIC32MX_SPI1) || defined(CONFIG_PIC32MX_SPI2) || \ defined(CONFIG_PIC32MX_SPI3) || defined(CONFIG_PIC32MX_SPI4) void weak_function pic32mx_spidev_initialize(void); #endif -/************************************************************************************ +/**************************************************************************** * Name: pic32mx_led_initialize * * Description: * Configure on-board LEDs if LED support has been selected. * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_ARCH_LEDS void pic32mx_led_initialize(void); #endif -/************************************************************************************ +/**************************************************************************** * Name: pic32mx_bringup * * Description: @@ -157,7 +157,7 @@ void pic32mx_led_initialize(void); * CONFIG_BOARD_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y : * Called from the NSH library * - ************************************************************************************/ + ****************************************************************************/ int pic32mx_bringup(void); @@ -173,6 +173,27 @@ int pic32mx_bringup(void); void pic32mx_lcdinitialize(void); +/**************************************************************************** + * Name: pic32mx_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_INPUT +int pic32mx_tsc_setup(int minor); +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/configs/sam3u-ek/nxwm/defconfig b/configs/sam3u-ek/nxwm/defconfig index 3e21c6bd892..498f5833f51 100644 --- a/configs/sam3u-ek/nxwm/defconfig +++ b/configs/sam3u-ek/nxwm/defconfig @@ -19,7 +19,6 @@ CONFIG_ARCH="arm" CONFIG_ARMV7M_OABI_TOOLCHAIN=y CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y CONFIG_BOARD_LOOPSPERMSEC=8720 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_CXX_NEWLONG=y CONFIG_DISABLE_POLL=y CONFIG_HAVE_CXX=y @@ -29,6 +28,7 @@ CONFIG_INPUT=y CONFIG_LCD_MAXCONTRAST=1 CONFIG_LCD_MAXPOWER=31 CONFIG_LCD=y +CONFIG_LIB_BOARDCTL=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_REGIONS=2 diff --git a/configs/sam3u-ek/src/sam3u-ek.h b/configs/sam3u-ek/src/sam3u-ek.h index 714ff54c2a4..87119e417d4 100644 --- a/configs/sam3u-ek/src/sam3u-ek.h +++ b/configs/sam3u-ek/src/sam3u-ek.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/sam3u-ek/src/sam3u-ek.h * - * Copyright (C) 2009-2011, 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2011, 2013, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -263,5 +263,26 @@ bool sam_writeprotected(unsigned char slot); # define sam_writeprotected(slot) (false) #endif +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ***********************************************************************************/ + +#ifdef CONFIG_INPUT_ADS7843E +int sam_tsc_setup(int minor); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_SAM3U_EK_SRC_SAM3U_EK_H */ diff --git a/configs/sam3u-ek/src/sam_appinit.c b/configs/sam3u-ek/src/sam_appinit.c index 00f2cd2e212..3de2d64e614 100644 --- a/configs/sam3u-ek/src/sam_appinit.c +++ b/configs/sam3u-ek/src/sam_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/sam3u-ek/src/sam_appinit.c * - * Copyright (C) 2010, 2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2013, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -128,9 +128,10 @@ int board_app_initialize(uintptr_t arg) { + int ret; + #ifdef NSH_HAVE_MMCSD FAR struct sdio_dev_s *sdio; - int ret; /* Mount the SDIO-based MMC/SD block driver */ /* First, get an instance of the SDIO interface */ @@ -164,5 +165,17 @@ int board_app_initialize(uintptr_t arg) sdio_mediachange(sdio, sam_cardinserted(0)); #endif + +#ifdef CONFIG_INPUT + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + + UNUSED(ret); return OK; } diff --git a/configs/sam3u-ek/src/sam_touchscreen.c b/configs/sam3u-ek/src/sam_touchscreen.c index c5cc9df288d..da529f2d873 100644 --- a/configs/sam3u-ek/src/sam_touchscreen.c +++ b/configs/sam3u-ek/src/sam_touchscreen.c @@ -216,13 +216,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -233,7 +232,7 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { FAR struct spi_dev_s *dev; int ret; @@ -272,26 +271,4 @@ int board_tsc_setup(int minor) return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen ADS7843E device yet */ -} - #endif /* CONFIG_INPUT_ADS7843E */ - diff --git a/configs/sam4e-ek/nxwm/defconfig b/configs/sam4e-ek/nxwm/defconfig index a9b0bb4aea7..bb74cc19521 100644 --- a/configs/sam4e-ek/nxwm/defconfig +++ b/configs/sam4e-ek/nxwm/defconfig @@ -31,6 +31,7 @@ CONFIG_INTELHEX_BINARY=y CONFIG_LCD_MAXCONTRAST=1 CONFIG_LCD_MAXPOWER=64 CONFIG_LCD=y +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 diff --git a/configs/sam4e-ek/src/sam4e-ek.h b/configs/sam4e-ek/src/sam4e-ek.h index 591b90be1f6..dacbe510986 100644 --- a/configs/sam4e-ek/src/sam4e-ek.h +++ b/configs/sam4e-ek/src/sam4e-ek.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/sam4e-ek/src/sam4e-ek.h * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -440,14 +440,14 @@ bool sam_writeprotected(int slotno); # define sam_writeprotected(slotno) (false) #endif -/**************************************************************************** +/************************************************************************************ * Name: sam_at25_automount * * Description: * Initialize, configure, and mount the AT25 serial FLASH. The FLASH will * be mounted at /dev/at25. * - ****************************************************************************/ + ************************************************************************************/ #ifdef HAVE_AT25 int sam_at25_automount(int minor); @@ -455,5 +455,26 @@ int sam_at25_automount(int minor); # define sam_at25_automount(minor) (-ENOSYS) #endif +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ***********************************************************************************/ + +#ifdef CONFIG_INPUT_ADS7843E +int sam_tsc_setup(int minor); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_SAM4E_EK_SRC_SAM4E_EK_H */ diff --git a/configs/sam4e-ek/src/sam_ads7843e.c b/configs/sam4e-ek/src/sam_ads7843e.c index 82dd848cd90..b925125a516 100644 --- a/configs/sam4e-ek/src/sam_ads7843e.c +++ b/configs/sam4e-ek/src/sam_ads7843e.c @@ -213,13 +213,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -230,7 +229,7 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { FAR struct spi_dev_s *dev; int ret; @@ -269,25 +268,4 @@ int board_tsc_setup(int minor) return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen ADS7843E device yet */ -} - #endif /* CONFIG_INPUT && CONFIG_INPUT_ADS7843E */ diff --git a/configs/sam4e-ek/src/sam_appinit.c b/configs/sam4e-ek/src/sam_appinit.c index b9ec0bcf11e..38c239602f4 100644 --- a/configs/sam4e-ek/src/sam_appinit.c +++ b/configs/sam4e-ek/src/sam_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/sam4e-ek/src/sam_appinit.c * - * Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -89,9 +89,7 @@ int board_app_initialize(uintptr_t arg) { -#if defined(HAVE_AT25) || defined(HAVE_HSMCI) || defined(HAVE_USBMONITOR) int ret; -#endif #ifdef HAVE_AT25 /* Initialize the AT25 driver */ @@ -115,6 +113,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_INPUT_ADS7843E + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ @@ -126,5 +134,6 @@ int board_app_initialize(uintptr_t arg) } #endif + UNUSED(ret); return OK; } diff --git a/configs/sama5d3x-ek/nxwm/defconfig b/configs/sama5d3x-ek/nxwm/defconfig index 998bd7c2523..8fef1f7fd99 100644 --- a/configs/sama5d3x-ek/nxwm/defconfig +++ b/configs/sama5d3x-ek/nxwm/defconfig @@ -12,7 +12,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_ARMV7A_TOOLCHAIN_CODESOURCERYW=y CONFIG_BOARD_LOOPSPERMSEC=49341 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_BUILTIN=y CONFIG_DISABLE_POLL=y CONFIG_FLASH_SIZE=134217728 @@ -23,6 +22,7 @@ CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y CONFIG_HOST_WINDOWS=y CONFIG_INTELHEX_BINARY=y +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 diff --git a/configs/sama5d3x-ek/src/sam_appinit.c b/configs/sama5d3x-ek/src/sam_appinit.c index 0d3083ad2bc..5da376d0427 100644 --- a/configs/sama5d3x-ek/src/sam_appinit.c +++ b/configs/sama5d3x-ek/src/sam_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/sama5d3x-ek/src/sam_appinit.c * - * Copyright (C) 2013-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -173,6 +173,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_SAMA5_TSD + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef HAVE_WM8904 /* Configure WM8904 audio */ diff --git a/configs/sama5d3x-ek/src/sam_touchscreen.c b/configs/sama5d3x-ek/src/sam_touchscreen.c index ba5126643ae..e22f9911210 100644 --- a/configs/sama5d3x-ek/src/sam_touchscreen.c +++ b/configs/sama5d3x-ek/src/sam_touchscreen.c @@ -64,34 +64,17 @@ # define CONFIG_SAMA5D3xEK_TSD_DEVMINOR 0 #endif -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this - * function. This function is called by application-specific, setup logic - * to configure the touchscreen device. This function will register the - * driver as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -102,65 +85,34 @@ * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { struct sam_adc_s *adc; - static bool initialized = false; int ret; - iinfo("initialized:%d minor:%d\n", initialized, minor); + iinfo("minor:%d\n", minor); DEBUGASSERT(minor == 0); - /* Since there is no uninitialized logic, this initialization can be - * performed only one time. - */ + /* Initialize the ADC driver */ - if (!initialized) + adc = sam_adc_initialize(); + if (!adc) { - /* Initialize the ADC driver */ + ierr("ERROR: Failed to initialize the ADC driver\n"); + return -ENODEV; + } - adc = sam_adc_initialize(); - if (!adc) - { - ierr("ERROR: Failed to initialize the ADC driver\n"); - return -ENODEV; - } + /* Initialize and register the SPI touchscreen device */ - /* Initialize and register the SPI touchscreen device */ - - ret = sam_tsd_register(adc, CONFIG_SAMA5D3xEK_TSD_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device /dev/input%d: %d\n", - CONFIG_SAMA5D3xEK_TSD_DEVMINOR, ret); - return -ENODEV; - } - - initialized = true; + ret = sam_tsd_register(adc, CONFIG_SAMA5D3xEK_TSD_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device /dev/input%d: %d\n", + CONFIG_SAMA5D3xEK_TSD_DEVMINOR, ret); + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen yet */ -} - #endif /* CONFIG_INPUT_ADS7843E */ diff --git a/configs/sama5d3x-ek/src/sama5d3x-ek.h b/configs/sama5d3x-ek/src/sama5d3x-ek.h index fcdfa53b3ee..c6dd625998a 100644 --- a/configs/sama5d3x-ek/src/sama5d3x-ek.h +++ b/configs/sama5d3x-ek/src/sama5d3x-ek.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/sama5d3x-ek/src/sama5d3x-ek.h * - * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -833,6 +833,27 @@ int sam_usbhost_initialize(void); void weak_function sam_netinitialize(void); #endif +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ***********************************************************************************/ + +#ifdef CONFIG_SAMA5_TSD +int sam_tsc_setup(int minor); +#endif + /************************************************************************************ * Name: sam_pwm_setup * diff --git a/configs/sama5d4-ek/README.txt b/configs/sama5d4-ek/README.txt index 40a703e4025..fa063560b7a 100644 --- a/configs/sama5d4-ek/README.txt +++ b/configs/sama5d4-ek/README.txt @@ -3268,7 +3268,6 @@ TM7000 LCD/Touchscreen build in a touchscreen test: CONFIG_EXAMPLES_TOUCHSCREEN=y - CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT=y CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0" CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0 diff --git a/configs/sama5d4-ek/nxwm/defconfig b/configs/sama5d4-ek/nxwm/defconfig index 5970178745b..c669a50f4a2 100644 --- a/configs/sama5d4-ek/nxwm/defconfig +++ b/configs/sama5d4-ek/nxwm/defconfig @@ -46,6 +46,7 @@ CONFIG_I2CTOOL_MAXBUS=0 CONFIG_INPUT_MXT=y CONFIG_INPUT=y CONFIG_INTELHEX_BINARY=y +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 diff --git a/configs/sama5d4-ek/src/sam_bringup.c b/configs/sama5d4-ek/src/sam_bringup.c index 5669b17fc78..d5a01c2fe67 100644 --- a/configs/sama5d4-ek/src/sam_bringup.c +++ b/configs/sama5d4-ek/src/sam_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/sama5d4-ek/src/sam_bringup.c * - * Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -288,6 +288,16 @@ int sam_bringup(void) } #endif +#ifdef HAVE_MAXTOUCH + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ diff --git a/configs/sama5d4-ek/src/sam_maxtouch.c b/configs/sama5d4-ek/src/sam_maxtouch.c index 1511c7a662c..0790caa711d 100644 --- a/configs/sama5d4-ek/src/sam_maxtouch.c +++ b/configs/sama5d4-ek/src/sam_maxtouch.c @@ -219,13 +219,12 @@ static int mxt_interrupt(int irq, FAR void *context, FAR void *arg) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -236,81 +235,44 @@ static int mxt_interrupt(int irq, FAR void *context, FAR void *arg) * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { FAR struct i2c_master_s *i2c; - static bool initialized = false; int ret; iinfo("minor %d\n", minor); DEBUGASSERT(minor == 0); - /* Have we already initialized? Since we never uninitialize we must prevent - * multiple initializations. This is necessary, for example, when the - * touchscreen example is used as a built-in application in NSH and can be - * called numerous time. It will attempt to initialize each time. - */ + /* Configure the maXTouch CHG interrupt pin */ - if (!initialized) + (void)sam_configpio(PIO_CHG_MXT); + + /* Get an instance of the I2C interface for the touchscreen chip select */ + + i2c = sam_i2cbus_initialize(MXT_TWI_BUS); + if (!i2c) { - /* Configure the maXTouch CHG interrupt pin */ + ierr("ERROR: Failed to initialize I2C%d\n", MXT_TWI_BUS); + return -ENODEV; + } - (void)sam_configpio(PIO_CHG_MXT); + /* Configure maXTouch CHG interrupts */ - /* Get an instance of the I2C interface for the touchscreen chip select */ + sam_pioirq(PIO_CHG_MXT); + (void)irq_attach(IRQ_CHG_MXT, mxt_interrupt, NULL); - i2c = sam_i2cbus_initialize(MXT_TWI_BUS); - if (!i2c) - { - ierr("ERROR: Failed to initialize I2C%d\n", MXT_TWI_BUS); - return -ENODEV; - } + /* Initialize and register the I2C touchscreen device */ - /* Configure maXTouch CHG interrupts */ - - sam_pioirq(PIO_CHG_MXT); - (void)irq_attach(IRQ_CHG_MXT, mxt_interrupt, NULL); - - /* Initialize and register the I2C touchscreen device */ - - ret = mxt_register(i2c, &g_mxtinfo.lower, CONFIG_SAMA5D4EK_MXT_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device\n"); - irq_detach(IRQ_CHG_MXT); - /* sam_i2cbus_uninitialize(i2c); */ - return -ENODEV; - } - - /* Now we are initialized */ - - initialized = true; + ret = mxt_register(i2c, &g_mxtinfo.lower, CONFIG_SAMA5D4EK_MXT_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device\n"); + irq_detach(IRQ_CHG_MXT); + /* sam_i2cbus_uninitialize(i2c); */ + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen maXTouch device. It will - * continue to run and process touch interrupts in the background. - */ -} - #endif /* HAVE_MAXTOUCH */ diff --git a/configs/sama5d4-ek/src/sama5d4-ek.h b/configs/sama5d4-ek/src/sama5d4-ek.h index 1a364f64c23..50e956b08de 100644 --- a/configs/sama5d4-ek/src/sama5d4-ek.h +++ b/configs/sama5d4-ek/src/sama5d4-ek.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/sama5d4-ek/src/sama5d4-ek.h * - * Copyright (C) 2014-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -1060,19 +1060,41 @@ bool sam_writeprotected(int slotno); void weak_function sam_usbinitialize(void); #endif -/**************************************************************************************************** +/************************************************************************************ * Name: stm32_usbhost_initialize * * Description: - * Called at application startup time to initialize the USB host functionality. This function will - * start a thread that will monitor for device connection/disconnection events. + * Called at application startup time to initialize the USB host functionality. + * This function will start a thread that will monitor for device connection/ + * disconnection events. * - ****************************************************************************************************/ + ************************************************************************************/ #ifdef HAVE_USBHOST int sam_usbhost_initialize(void); #endif +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ***********************************************************************************/ + +#ifdef HAVE_MAXTOUCH +int sam_tsc_setup(int minor); +#endif + /************************************************************************************ * Name: sam_pwm_setup * diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index c290d05badd..782bdaf6327 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -1231,7 +1231,6 @@ MXT Configuration Options Application Configuration -> Examples -> Touchscreen example CONFIG_EXAMPLES_TOUCHSCREEN=y : Enables the example - CONFIG_EXAMPLES_TOUCHSCREEN_ARCHINIT=y : Have board-specific intialization CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/input0" CONFIG_EXAMPLES_TOUCHSCREEN_MINOR=0 diff --git a/configs/samv71-xult/nxwm/defconfig b/configs/samv71-xult/nxwm/defconfig index 80cc25bf5c7..668cdb620d9 100644 --- a/configs/samv71-xult/nxwm/defconfig +++ b/configs/samv71-xult/nxwm/defconfig @@ -27,7 +27,6 @@ CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 CONFIG_AT24XX_SIZE=2 CONFIG_BOARD_LOOPSPERMSEC=51262 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_BUILTIN=y CONFIG_DISABLE_POLL=y CONFIG_FAT_LCNAMES=y @@ -41,6 +40,7 @@ CONFIG_INPUT_MXT=y CONFIG_INPUT=y CONFIG_LCD_NOGETRUN=y CONFIG_LCD=y +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index 5d6e288e214..4326c2b8eec 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -507,6 +507,16 @@ int sam_bringup(void) } #endif +#ifdef HAVE_MAXTOUCH + /* Initialize the touchscreen */ + + ret = sam_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef HAVE_WM8904 /* Configure WM8904 audio */ diff --git a/configs/samv71-xult/src/sam_maxtouch.c b/configs/samv71-xult/src/sam_maxtouch.c index e6e97de0e52..e368d5958d9 100644 --- a/configs/samv71-xult/src/sam_maxtouch.c +++ b/configs/samv71-xult/src/sam_maxtouch.c @@ -218,13 +218,12 @@ static int mxt_interrupt(int irq, FAR void *context, FAR void *arg) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: sam_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -235,81 +234,44 @@ static int mxt_interrupt(int irq, FAR void *context, FAR void *arg) * ****************************************************************************/ -int board_tsc_setup(int minor) +int sam_tsc_setup(int minor) { FAR struct i2c_master_s *i2c; - static bool initialized = false; int ret; iinfo("minor %d\n", minor); DEBUGASSERT(minor == 0); - /* Have we already initialized? Since we never uninitialize we must prevent - * multiple initializations. This is necessary, for example, when the - * touchscreen example is used as a built-in application in NSH and can be - * called numerous time. It will attempt to initialize each time. - */ + /* Configure the maXTouch CHG interrupt pin */ - if (!initialized) + (void)sam_configgpio(GPIO_MXT_CHG); + + /* Get an instance of the I2C interface for the touchscreen chip select */ + + i2c = sam_i2cbus_initialize(MXT_TWI_BUS); + if (!i2c) { - /* Configure the maXTouch CHG interrupt pin */ + ierr("ERROR: Failed to initialize I2C%d\n", MXT_TWI_BUS); + return -ENODEV; + } - (void)sam_configgpio(GPIO_MXT_CHG); + /* Configure maXTouch CHG interrupts */ - /* Get an instance of the I2C interface for the touchscreen chip select */ + sam_gpioirq(GPIO_MXT_CHG); + (void)irq_attach(IRQ_MXT_CHG, mxt_interrupt, NULL); - i2c = sam_i2cbus_initialize(MXT_TWI_BUS); - if (!i2c) - { - ierr("ERROR: Failed to initialize I2C%d\n", MXT_TWI_BUS); - return -ENODEV; - } + /* Initialize and register the I2C touchscreen device */ - /* Configure maXTouch CHG interrupts */ - - sam_gpioirq(GPIO_MXT_CHG); - (void)irq_attach(IRQ_MXT_CHG, mxt_interrupt, NULL); - - /* Initialize and register the I2C touchscreen device */ - - ret = mxt_register(i2c, &g_mxtinfo.lower, CONFIG_SAMV71XULT_MXT_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device\n"); - irq_detach(IRQ_MXT_CHG); - /* sam_i2cbus_uninitialize(i2c); */ - return -ENODEV; - } - - /* Now we are initialized */ - - initialized = true; + ret = mxt_register(i2c, &g_mxtinfo.lower, CONFIG_SAMV71XULT_MXT_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device\n"); + irq_detach(IRQ_MXT_CHG); + /* sam_i2cbus_uninitialize(i2c); */ + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen maXTouch device. It will - * continue to run and process touch interrupts in the background. - */ -} - #endif /* HAVE_MAXTOUCH */ diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index c9b3718b2cc..cb273a819fa 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/samv71-xult/src/samv71-xult.h * - * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -846,28 +846,49 @@ bool sam_writeprotected(int slotno); int sam_at24config(void); #endif -/**************************************************************************** +/************************************************************************************ + * Name: sam_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen + * device. This function will register the driver as /dev/inputN where N is the + * minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to + * indicate the nature of the failure. + * + ************************************************************************************/ + +#ifdef HAVE_MAXTOUCH +int sam_tsc_setup(int minor); +#endif + +/************************************************************************************ * Name: sam_wm8904_initialize * * Description: - * This function is called by platform-specific, setup logic to configure - * and register the WM8904 device. This function will register the driver - * as /dev/wm8904[x] where x is determined by the minor device number. + * This function is called by platform-specific, setup logic to configure and + * register the WM8904 device. This function will register the driver as + * /dev/wm8904[x] where x is determined by the minor device number. * * Input Parameters: * minor - The input device minor number * * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. + * Zero is returned on success. Otherwise, a negated errno value is returned + * to indicate the nature of the failure. * - ****************************************************************************/ + ************************************************************************************/ #ifdef HAVE_WM8904 int sam_wm8904_initialize(int minor); #endif /* HAVE_WM8904 */ -/**************************************************************************** +/************************************************************************************ * Name: sam_audio_null_initialize * * Description: @@ -877,26 +898,26 @@ int sam_wm8904_initialize(int minor); * minor - The input device minor number * * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. + * Zero is returned on success. Otherwise, a negated errno value is returned + * to indicate the nature of the failure. * - ****************************************************************************/ + ************************************************************************************/ #ifdef HAVE_AUDIO_NULL int sam_audio_null_initialize(int minor); #endif /* HAVE_AUDIO_NULL */ -/**************************************************************************** +/************************************************************************************ * Name: stm32_mrf24j40_initialize * * Description: * Initialize the MRF24J40 device. * * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. + * Zero is returned on success. Otherwise, a negated errno value is returned + * to indicate the nature of the failure. * - ****************************************************************************/ + ************************************************************************************/ #ifdef HAVE_MRF24J40 int sam_mrf24j40_initialize(void); diff --git a/configs/samv71-xult/vnxwm/defconfig b/configs/samv71-xult/vnxwm/defconfig index ac4e18a30d8..40870a8f12d 100644 --- a/configs/samv71-xult/vnxwm/defconfig +++ b/configs/samv71-xult/vnxwm/defconfig @@ -39,6 +39,7 @@ CONFIG_HOST_WINDOWS=y CONFIG_I2C_DRIVER=y CONFIG_IOB_NBUFFERS=72 CONFIG_IOB_THROTTLE=32 +CONFIG_LIB_BOARDCTL=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 diff --git a/configs/shenzhou/nxwm/defconfig b/configs/shenzhou/nxwm/defconfig index 33241b13dc7..859bb2ca3e4 100644 --- a/configs/shenzhou/nxwm/defconfig +++ b/configs/shenzhou/nxwm/defconfig @@ -17,7 +17,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y CONFIG_BOARD_LOOPSPERMSEC=5483 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_ETH0_PHY_DM9161=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y @@ -29,6 +28,7 @@ CONFIG_LCD_MAXCONTRAST=1 CONFIG_LCD_NOGETRUN=y CONFIG_LCD_SSD1289=y CONFIG_LCD=y +CONFIG_LIB_BOARDCTL=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MQ_MAXMSGSIZE=64 diff --git a/configs/shenzhou/src/shenzhou.h b/configs/shenzhou/src/shenzhou.h index 68fb63d1020..a841307dfb5 100644 --- a/configs/shenzhou/src/shenzhou.h +++ b/configs/shenzhou/src/shenzhou.h @@ -1,7 +1,7 @@ /**************************************************************************************************** * configs/shenzhou/src/shenzhou.h * - * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -426,7 +426,7 @@ void weak_function stm32_spidev_initialize(void); * Name: stm32_usbinitialize * * Description: - * Called from stm32_usbinitialize very early in inialization to setup USB-related GPIO pins for + * Called from stm32_usbinitialize very early in initialization to setup USB-related GPIO pins for * the STM3240G-EVAL board. * ****************************************************************************************************/ @@ -448,13 +448,34 @@ void weak_function stm32_usbinitialize(void); int stm32_usbhost_initialize(void); #endif -/************************************************************************************ +/**************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_INPUT_ADS7843E +int stm32_tsc_setup(int minor); +#endif + +/**************************************************************************** * Name: stm32_adc_setup * * Description: * Initialize ADC and register the ADC driver. * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_ADC int stm32_adc_setup(void); diff --git a/configs/shenzhou/src/stm32_appinit.c b/configs/shenzhou/src/stm32_appinit.c index a260c4ec1e9..18de2f1660d 100644 --- a/configs/shenzhou/src/stm32_appinit.c +++ b/configs/shenzhou/src/stm32_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/shenzhou/src/stm32_appinit.c * - * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -204,6 +204,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_INPUT_ADS7843E + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_ADC /* Initialize ADC and register the ADC driver. */ diff --git a/configs/shenzhou/src/stm32_touchscreen.c b/configs/shenzhou/src/stm32_touchscreen.c index 99b3971df80..1e0fe2e12cc 100644 --- a/configs/shenzhou/src/stm32_touchscreen.c +++ b/configs/shenzhou/src/stm32_touchscreen.c @@ -230,13 +230,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -247,7 +246,7 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { FAR struct spi_dev_s *dev; int ret; @@ -281,26 +280,5 @@ int board_tsc_setup(int minor) return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen ADS7843E device yet */ -} - #endif /* CONFIG_INPUT_ADS7843E */ diff --git a/configs/sim/README.txt b/configs/sim/README.txt index 226ddd3ffd8..b463f412af1 100644 --- a/configs/sim/README.txt +++ b/configs/sim/README.txt @@ -729,10 +729,6 @@ nx11 CONFIG_INPUT=y CONFIG_SIM_TOUCHSCREEN=y - Then you must also have some application logic that will call - board_tsc_setup(0) to register the touchscreen driver. See - also configuration "touchscreen" - NOTES: a. If you do not have the call to sim_tcinitialize(0), the build diff --git a/configs/sim/nxwm/defconfig b/configs/sim/nxwm/defconfig index 17fadb5035f..a0c17d2cfa1 100644 --- a/configs/sim/nxwm/defconfig +++ b/configs/sim/nxwm/defconfig @@ -15,6 +15,7 @@ CONFIG_FS_PROCFS=y CONFIG_FS_ROMFS=y CONFIG_HAVE_CXX=y CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_LIB_BOARDCTL=y CONFIG_MAX_TASKS=16 CONFIG_MQ_MAXMSGSIZE=64 CONFIG_NSH_ARCHINIT=y diff --git a/configs/sim/src/sim.h b/configs/sim/src/sim.h index f851b339cca..808818da1ac 100644 --- a/configs/sim/src/sim.h +++ b/configs/sim/src/sim.h @@ -1,7 +1,7 @@ /**************************************************************************** * config/sim/src/sim.h * - * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -123,4 +123,25 @@ int sim_zoneinfo(int minor); int sim_gpio_initialize(void); #endif +/**************************************************************************** + * Name: sim_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#if defined(CONFIG_SIM_X11FB) && defined(CONFIG_SIM_TOUCHSCREEN) +int sim_tsc_setup(int minor); +#endif + #endif /* __CONFIGS_SIM_SRC_SIM_H */ \ No newline at end of file diff --git a/configs/sim/src/sim_bringup.c b/configs/sim/src/sim_bringup.c index 22351f6270b..a2233a5fd84 100644 --- a/configs/sim/src/sim_bringup.c +++ b/configs/sim/src/sim_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * configs/sim/src/sam_bringup.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -68,8 +68,7 @@ int trv_mount_world(int minor, FAR const char *mountpoint); #define NEED_FRAMEBUFFER 1 /* If we are using the X11 touchscreen simulation, then the frame buffer - * initialization happens in board_tsc_setup. Otherwise, we will need to - * do that here. + * initialization will need to be done here. */ #if defined(CONFIG_SIM_X11FB) && defined(CONFIG_SIM_TOUCHSCREEN) @@ -200,6 +199,16 @@ int sim_bringup(void) sim_ajoy_initialize(); #endif +#if defined(CONFIG_SIM_X11FB) && defined(CONFIG_SIM_TOUCHSCREEN) + /* Initialize the touchscreen */ + + ret = sim_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sim_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO /* Special initialization for the Traveler game simulation */ diff --git a/configs/sim/src/sim_touchscreen.c b/configs/sim/src/sim_touchscreen.c index 0f45d5300df..c3b15a8e5d7 100644 --- a/configs/sim/src/sim_touchscreen.c +++ b/configs/sim/src/sim_touchscreen.c @@ -145,16 +145,23 @@ static FAR void *sim_listener(FAR void *arg) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup() + * Name: sim_tsc_setup * * Description: - * Perform architecuture-specific initialization of the touchscreen - * hardware. This interface must be provided by all configurations - * using apps/examples/touchscreen + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. * ****************************************************************************/ -int board_tsc_setup(int minor) +int sim_tsc_setup(int minor) { struct sched_param param; nxgl_mxpixel_t color; @@ -262,24 +269,3 @@ errout_with_nx: errout: return ret; } - -/**************************************************************************** - * Name: board_tsc_teardown() - * - * Description: - * Perform architecuture-specific un-initialization of the touchscreen - * hardware. This interface must be provided by all configurations - * using apps/examples/touchscreen - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* Shut down the touchscreen driver */ - - sim_tsc_uninitialize(); - - /* Close NX */ - - nx_disconnect(g_simtc.hnx); -} diff --git a/configs/spark/composite/defconfig b/configs/spark/composite/defconfig index af4f8711003..64e28d8db7b 100644 --- a/configs/spark/composite/defconfig +++ b/configs/spark/composite/defconfig @@ -58,7 +58,7 @@ CONFIG_IDLETHREAD_STACKSIZE=280 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_RAND_ORDER=2 CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MQ_MAXMSGSIZE=8 diff --git a/configs/spark/nsh/defconfig b/configs/spark/nsh/defconfig index 40363aae9f9..28222b3f4d9 100644 --- a/configs/spark/nsh/defconfig +++ b/configs/spark/nsh/defconfig @@ -49,7 +49,7 @@ CONFIG_IDLETHREAD_STACKSIZE=300 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_RAND_ORDER=2 CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MQ_MAXMSGSIZE=8 diff --git a/configs/spark/usbmsc/defconfig b/configs/spark/usbmsc/defconfig index 37cd3ef6cc5..eed15c31c75 100644 --- a/configs/spark/usbmsc/defconfig +++ b/configs/spark/usbmsc/defconfig @@ -44,7 +44,7 @@ CONFIG_IDLETHREAD_STACKSIZE=280 CONFIG_INTELHEX_BINARY=y CONFIG_LIB_RAND_ORDER=2 CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MQ_MAXMSGSIZE=8 diff --git a/configs/spark/usbserial/defconfig b/configs/spark/usbserial/defconfig index 1699ef387d7..7b0d94af996 100644 --- a/configs/spark/usbserial/defconfig +++ b/configs/spark/usbserial/defconfig @@ -41,7 +41,7 @@ CONFIG_INTELHEX_BINARY=y CONFIG_LIB_BOARDCTL=y CONFIG_LIB_RAND_ORDER=2 CONFIG_LIB_SENDFILE_BUFSIZE=0 -CONFIG_MAX_TASKS=12 +CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_SMALL=y CONFIG_MQ_MAXMSGSIZE=8 diff --git a/configs/stm3220g-eval/nxwm/defconfig b/configs/stm3220g-eval/nxwm/defconfig index 1bfe7f85415..25a868d8726 100644 --- a/configs/stm3220g-eval/nxwm/defconfig +++ b/configs/stm3220g-eval/nxwm/defconfig @@ -15,7 +15,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y CONFIG_BOARD_LOOPSPERMSEC=10926 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_ETH0_PHY_DP83848C=y CONFIG_FAT_LCNAMES=y CONFIG_FAT_LFN=y diff --git a/configs/stm3220g-eval/src/stm3220g-eval.h b/configs/stm3220g-eval/src/stm3220g-eval.h index 1e3087109f4..95e603fd17a 100644 --- a/configs/stm3220g-eval/src/stm3220g-eval.h +++ b/configs/stm3220g-eval/src/stm3220g-eval.h @@ -1,7 +1,7 @@ /**************************************************************************************************** * configs/stm3220g_eval/src/stm3220g.h * - * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -249,6 +249,26 @@ void weak_function stm32_usbinitialize(void); int stm32_usbhost_initialize(void); #endif +/**************************************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen device. This + * function will register the driver as /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to indicate the + * nature of the failure. + * + ****************************************************************************************************/ + +#ifdef CONFIG_INPUT_STMPE811 +int stm32_tsc_setup(int minor); +#endif + /**************************************************************************************************** * Name: stm32_pwm_setup * @@ -321,7 +341,7 @@ void stm32_extmemaddr(int naddrs); void stm32_extmemdata(int ndata); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_enablefsmc * * Description: @@ -333,7 +353,7 @@ void stm32_extmemdata(int ndata); void stm32_enablefsmc(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_disablefsmc * * Description: @@ -345,7 +365,7 @@ void stm32_enablefsmc(void); void stm32_disablefsmc(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_selectsram * * Description: @@ -375,7 +395,7 @@ void stm32_disablefsmc(void); void stm32_selectsram(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_deselectsram * * Description: @@ -387,7 +407,7 @@ void stm32_selectsram(void); void stm32_deselectsram(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_selectlcd * * Description: @@ -399,7 +419,7 @@ void stm32_deselectsram(void); void stm32_selectlcd(void); #endif -/************************************************************************************ +/**************************************************************************************************** * Name: stm32_deselectlcd * * Description: @@ -413,4 +433,3 @@ void stm32_deselectlcd(void); #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_STM3220G_EVAL_SRC_STM3220G_H */ - diff --git a/configs/stm3220g-eval/src/stm32_appinit.c b/configs/stm3220g-eval/src/stm32_appinit.c index 447bb24f3d2..4800fca0707 100644 --- a/configs/stm3220g-eval/src/stm32_appinit.c +++ b/configs/stm3220g-eval/src/stm32_appinit.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/stm3220g_eval/src/stm32_appinit.c * - * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -292,6 +292,16 @@ int board_app_initialize(uintptr_t arg) } #endif +#ifdef CONFIG_INPUT_STMPE811 + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ diff --git a/configs/stm3220g-eval/src/stm32_stmpe811.c b/configs/stm3220g-eval/src/stm32_stmpe811.c index ec79a318644..d0346d5cf2e 100644 --- a/configs/stm3220g-eval/src/stm32_stmpe811.c +++ b/configs/stm3220g-eval/src/stm32_stmpe811.c @@ -146,7 +146,8 @@ struct stm32_stmpe811config_s /* IRQ/GPIO access callbacks. These operations all hidden behind callbacks * to isolate the STMPE811 driver from differences in GPIO - * interrupt handling by varying boards and MCUs.* so that contact and loss-of-contact events can be detected. + * interrupt handling by varying boards and MCUs.* so that contact and loss- + * of-contact events can be detected. * * attach - Attach the STMPE811 interrupt handler to the GPIO interrupt * enable - Enable or disable the GPIO interrupt @@ -264,16 +265,15 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: - * minor - The input device minor number + * minor - The input device minor number * * Returned Value: * Zero is returned on success. Otherwise, a negated errno value is @@ -281,7 +281,7 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { #ifndef CONFIG_STMPE811_TSC_DISABLE FAR struct i2c_master_s *dev; @@ -336,26 +336,5 @@ int board_tsc_setup(int minor) #endif } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen STMPE811 device yet */ -} - #endif /* CONFIG_INPUT_STMPE811 */ diff --git a/configs/stm3240g-eval/knxwm/defconfig b/configs/stm3240g-eval/knxwm/defconfig index 8a33d10f565..18f80a8e220 100644 --- a/configs/stm3240g-eval/knxwm/defconfig +++ b/configs/stm3240g-eval/knxwm/defconfig @@ -13,9 +13,7 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_ARM_MPU=y CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y -CONFIG_BOARD_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=16717 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_BUILD_PROTECTED=y CONFIG_CXX_NEWLONG=y CONFIG_DISABLE_POLL=y diff --git a/configs/stm3240g-eval/nxwm/defconfig b/configs/stm3240g-eval/nxwm/defconfig index a72b8984d48..6a277c9bd89 100644 --- a/configs/stm3240g-eval/nxwm/defconfig +++ b/configs/stm3240g-eval/nxwm/defconfig @@ -15,7 +15,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y CONFIG_BOARD_LOOPSPERMSEC=16717 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_FAT_LCNAMES=y CONFIG_FAT_LFN=y CONFIG_FS_FAT=y diff --git a/configs/stm3240g-eval/src/stm3240g-eval.h b/configs/stm3240g-eval/src/stm3240g-eval.h index 8b98bf85d57..71d997bbd38 100644 --- a/configs/stm3240g-eval/src/stm3240g-eval.h +++ b/configs/stm3240g-eval/src/stm3240g-eval.h @@ -1,7 +1,7 @@ /**************************************************************************************************** * configs/stm3240g_eval/src/stm3240g_eval.h * - * Copyright (C) 2011-2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -266,6 +266,26 @@ void weak_function stm32_usbinitialize(void); int stm32_usbhost_initialize(void); #endif +/**************************************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the touchscreen device. This + * function will register the driver as /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is returned to indicate the + * nature of the failure. + * + ****************************************************************************************************/ + +#ifdef CONFIG_INPUT_STMPE811 +int stm32_tsc_setup(int minor); +#endif + /**************************************************************************************************** * Name: stm32_led_initialize * diff --git a/configs/stm3240g-eval/src/stm32_appinit.c b/configs/stm3240g-eval/src/stm32_appinit.c index f3362bf0129..1ae1aa76baf 100644 --- a/configs/stm3240g-eval/src/stm32_appinit.c +++ b/configs/stm3240g-eval/src/stm32_appinit.c @@ -67,7 +67,7 @@ * arg - The boardctl() argument is passed to the board_app_initialize() * implementation without modification. The argument has no * meaning to NuttX; the meaning of the argument is a contract - * between the board-specific initalization logic and the + * between the board-specific initialization logic and the * matching application logic. The value cold be such things as a * mode enumeration value, a set of DIP switch switch settings, a * pointer to configuration data read from a file or serial FLASH, diff --git a/configs/stm3240g-eval/src/stm32_boot.c b/configs/stm3240g-eval/src/stm32_boot.c index 13f7591a40e..2309fc50bba 100644 --- a/configs/stm3240g-eval/src/stm32_boot.c +++ b/configs/stm3240g-eval/src/stm32_boot.c @@ -64,12 +64,8 @@ #endif /* Should we initialize the touchscreen for the NxWM (CONFIG_NXWM=y)? This - * is done if we have a touchscreen (CONFIG_INPUT_STMPE811=y), NxWM uses the - * touchscreen (CONFIG_NXWM_TOUCHSCREEN=y), and if we were asked to - * initialize the touchscreen for NxWM (NXWM_TOUCHSCREEN_DEVINIT=n). This - * combination of settings is normally only used in the kernel build mode - * (CONFIG_BUILD_PROTECTED) when NxWidgets is unable to initialize NX from - * user-space. + * is done if we have a touchscreen (CONFIG_INPUT_STMPE811=y) and NxWM uses the + * touchscreen (CONFIG_NXWM_TOUCHSCREEN=y). */ #undef HAVE_TCINIT @@ -78,14 +74,10 @@ # if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVNO) # error CONFIG_NXWM_TOUCHSCREEN_DEVNO is not defined # elif defined(CONFIG_INPUT_STMPE811) -# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVINIT) -# define HAVE_TCINIT -# include -# endif +# define HAVE_TCINIT 1 +# include # else -# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVINIT) && defined(CONFIG_BUILD_PROTECTED) -# error CONFIG_INPUT_STMPE811=y is needed -# endif +# error CONFIG_INPUT_STMPE811=y is needed # endif #endif @@ -143,10 +135,7 @@ static int board_initthread(int argc, char *argv[]) { int ret; - /* Perform NSH initialization here instead of from the NSH. This - * alternative NSH initialization is necessary when NSH is ran in user-space - * but the initialization function must run in kernel space. - */ + /* Perform the board initialization on an initialization thread */ ret = stm32_bringup(); if (ret < 0) @@ -154,26 +143,6 @@ static int board_initthread(int argc, char *argv[]) gerr("ERROR: stm32_bringup failed: %d\n", ret); } -#ifdef HAVE_NXSTART - /* Initialize the NX server */ - - ret = nx_start(); - if (ret < 0) - { - gerr("ERROR: nx_start failed: %d\n", ret); - } -#endif - -#ifdef HAVE_TCINIT - /* Initialize the touchscreen */ - - ret = board_tsc_setup(CONFIG_NXWM_TOUCHSCREEN_DEVNO); - if (ret < 0) - { - gerr("ERROR: board_tsc_setup failed: %d\n", ret); - } -#endif - return EXIT_SUCCESS; } #endif @@ -257,6 +226,11 @@ void board_initialize(void) NULL); ASSERT(server > 0); #else + /* Perform the board initialization on the start-up thread. Some + * initializations may fail in this case due to the limited capability of + * the start-up thread. + */ + (void)stm32_bringup(); #endif } diff --git a/configs/stm3240g-eval/src/stm32_bringup.c b/configs/stm3240g-eval/src/stm32_bringup.c index 3fcc402b22a..61d3f4a69c9 100644 --- a/configs/stm3240g-eval/src/stm32_bringup.c +++ b/configs/stm3240g-eval/src/stm32_bringup.c @@ -354,6 +354,26 @@ int stm32_bringup(void) } #endif +#ifdef HAVE_NXSTART + /* Initialize the NX server */ + + ret = nx_start(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: nx_start failed: %d\n", ret); + } +#endif + +#ifdef HAVE_TCINIT + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(CONFIG_NXWM_TOUCHSCREEN_DEVNO); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ diff --git a/configs/stm3240g-eval/src/stm32_stmpe811.c b/configs/stm3240g-eval/src/stm32_stmpe811.c index b1b8126c579..876b91d0d52 100644 --- a/configs/stm3240g-eval/src/stm32_stmpe811.c +++ b/configs/stm3240g-eval/src/stm32_stmpe811.c @@ -264,13 +264,12 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -281,7 +280,7 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { #ifndef CONFIG_STMPE811_TSC_DISABLE FAR struct i2c_master_s *dev; @@ -336,26 +335,5 @@ int board_tsc_setup(int minor) #endif } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen STMPE811 device yet */ -} - #endif /* CONFIG_INPUT_STMPE811 */ diff --git a/configs/stm32f429i-disco/nxwm/defconfig b/configs/stm32f429i-disco/nxwm/defconfig index c1bda648f9a..06a3ce05a26 100644 --- a/configs/stm32f429i-disco/nxwm/defconfig +++ b/configs/stm32f429i-disco/nxwm/defconfig @@ -11,9 +11,7 @@ CONFIG_ARCH_CHIP_STM32F429Z=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH="arm" -CONFIG_BOARD_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=16717 -CONFIG_BOARDCTL_TSCTEST=y CONFIG_BUILTIN=y CONFIG_DEBUG_CUSTOMOPT=y CONFIG_DEBUG_SYMBOLS=y @@ -29,6 +27,7 @@ CONFIG_HEAP2_SIZE=8081408 CONFIG_INPUT_STMPE811=y CONFIG_INPUT=y CONFIG_INTELHEX_BINARY=y +CONFIG_LIB_BOARDCTL=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MM_REGIONS=2 diff --git a/configs/stm32f429i-disco/src/stm32_boot.c b/configs/stm32f429i-disco/src/stm32_boot.c index 8af811400a3..9dda08d1de8 100644 --- a/configs/stm32f429i-disco/src/stm32_boot.c +++ b/configs/stm32f429i-disco/src/stm32_boot.c @@ -68,12 +68,8 @@ #endif /* Should we initialize the touchscreen for the NxWM (CONFIG_NXWM=y)? This - * is done if we have a touchscreen (CONFIG_INPUT_STMPE811=y), NxWM uses the - * touchscreen (CONFIG_NXWM_TOUCHSCREEN=y), and if we were asked to - * initialize the touchscreen for NxWM (NXWM_TOUCHSCREEN_DEVINIT=n). This - * combination of settings is normally only used in the kernel build mode - * (CONFIG_BUILD_PROTECTED) when NxWidgets is unable to initialize NX from - * user-space. + * is done if we have a touchscreen (CONFIG_INPUT_STMPE811=y) and NxWM uses the + * touchscreen (CONFIG_NXWM_TOUCHSCREEN=y). */ #undef HAVE_TCINIT @@ -82,14 +78,10 @@ # if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVNO) # error CONFIG_NXWM_TOUCHSCREEN_DEVNO is not defined # elif defined(CONFIG_INPUT_STMPE811) -# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVINIT) -# define HAVE_TCINIT -# include -# endif +# define HAVE_TCINIT +# include # else -# if !defined(CONFIG_NXWM_TOUCHSCREEN_DEVINIT) && defined(CONFIG_BUILD_PROTECTED) -# error CONFIG_INPUT_STMPE811=y is needed -# endif +# error CONFIG_INPUT_STMPE811=y is needed # endif #endif diff --git a/configs/stm32f429i-disco/src/stm32_bringup.c b/configs/stm32f429i-disco/src/stm32_bringup.c index 3ba8a5c2133..821ddeb1991 100644 --- a/configs/stm32f429i-disco/src/stm32_bringup.c +++ b/configs/stm32f429i-disco/src/stm32_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/stm32f429i-disco/src/stm32_bringup.c * - * Copyright (C) 2012, 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -345,6 +345,16 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_INPUT_STMPE811 + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_SENSORS_L3GD20 ret = stm32_l3gd20initialize("/dev/gyr0"); if (ret != OK) diff --git a/configs/stm32f429i-disco/src/stm32_stmpe811.c b/configs/stm32f429i-disco/src/stm32_stmpe811.c index 29fb9284a8b..71bc9830d9c 100644 --- a/configs/stm32f429i-disco/src/stm32_stmpe811.c +++ b/configs/stm32f429i-disco/src/stm32_stmpe811.c @@ -267,13 +267,12 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -284,7 +283,7 @@ static void stmpe811_clear(FAR struct stmpe811_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { #ifndef CONFIG_STMPE811_TSC_DISABLE FAR struct i2c_master_s *dev; @@ -339,26 +338,5 @@ int board_tsc_setup(int minor) #endif } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen STMPE811 device yet */ -} - #endif /* CONFIG_INPUT_STMPE811 */ diff --git a/configs/stm32f429i-disco/src/stm32f429i-disco.h b/configs/stm32f429i-disco/src/stm32f429i-disco.h index 46355dcdc11..d3240608768 100644 --- a/configs/stm32f429i-disco/src/stm32f429i-disco.h +++ b/configs/stm32f429i-disco/src/stm32f429i-disco.h @@ -1,7 +1,7 @@ /**************************************************************************** * configs/stm32f429i-disco/src/stm32f429i-disco.h * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2018 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * Marco Krahl * @@ -230,8 +230,8 @@ void weak_function stm32_spidev_initialize(void); * Name: stm32_usbinitialize * * Description: - * Called from stm32_usbinitialize very early in inialization to setup USB-related - * GPIO pins for the STM32F429Discovery board. + * Called from stm32_usbinitialize very early in inialization to setup USB- + * related GPIO pins for the STM32F429Discovery board. * ****************************************************************************/ @@ -253,6 +253,27 @@ void weak_function stm32_usbinitialize(void); int stm32_usbhost_initialize(void); #endif +/**************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_INPUT_STMPE811 +int stm32_tsc_setup(int minor); +#endif + /**************************************************************************** * Name: stm32_enablefsmc @@ -352,7 +373,6 @@ FAR struct ili9341_lcd_s *stm32_ili93414ws_initialize(void); FAR struct spi_dev_s *stm32_spi5initialize(void); #endif - /**************************************************************************** * Name: stm32_l3gd20initialize() * diff --git a/configs/viewtool-stm32f107/src/stm32_bringup.c b/configs/viewtool-stm32f107/src/stm32_bringup.c index cba3798e889..97ca12b9861 100644 --- a/configs/viewtool-stm32f107/src/stm32_bringup.c +++ b/configs/viewtool-stm32f107/src/stm32_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/viewtool-stm32f107/src/stm32_bringup.c * - * Copyright (C) 2013, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -165,6 +165,16 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_INPUT_ADS7843E + /* Initialize the touchscreen */ + + ret = stm32_tsc_setup(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_tsc_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_CAN /* Initialize CAN and register the CAN driver. */ diff --git a/configs/viewtool-stm32f107/src/stm32_touchscreen.c b/configs/viewtool-stm32f107/src/stm32_touchscreen.c index 8d6bc3c2593..39130e78932 100644 --- a/configs/viewtool-stm32f107/src/stm32_touchscreen.c +++ b/configs/viewtool-stm32f107/src/stm32_touchscreen.c @@ -239,13 +239,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) ****************************************************************************/ /**************************************************************************** - * Name: board_tsc_setup + * Name: stm32_tsc_setup * * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. * * Input Parameters: * minor - The input device minor number @@ -256,75 +255,38 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state) * ****************************************************************************/ -int board_tsc_setup(int minor) +int stm32_tsc_setup(int minor) { FAR struct spi_dev_s *dev; - static bool initialized = false; int ret; iinfo("minor %d\n", minor); DEBUGASSERT(minor == 0); - /* Have we already initialized? Since we never uninitialize we must prevent - * multiple initializations. This is necessary, for example, when the - * touchscreen example is used as a built-in application in NSH and can be - * called numerous time. It will attempt to initialize each time. - */ + /* Configure the XPT2046 interrupt pin as an input */ - if (!initialized) + (void)stm32_configgpio(GPIO_LCDTP_IRQ); + + /* Get an instance of the SPI interface for the touchscreen chip select */ + + dev = stm32_spibus_initialize(TSC_DEVNUM); + if (!dev) { - /* Configure the XPT2046 interrupt pin as an input */ + ierr("ERROR: Failed to initialize SPI%d\n", TSC_DEVNUM); + return -ENODEV; + } - (void)stm32_configgpio(GPIO_LCDTP_IRQ); + /* Initialize and register the SPI touchscreen device */ - /* Get an instance of the SPI interface for the touchscreen chip select */ - - dev = stm32_spibus_initialize(TSC_DEVNUM); - if (!dev) - { - ierr("ERROR: Failed to initialize SPI%d\n", TSC_DEVNUM); - return -ENODEV; - } - - /* Initialize and register the SPI touchscreen device */ - - ret = ads7843e_register(dev, &g_tscinfo.config, CONFIG_ADS7843E_DEVMINOR); - if (ret < 0) - { - ierr("ERROR: Failed to register touchscreen device\n"); - /* up_spiuninitialize(dev); */ - return -ENODEV; - } - - /* Now we are initialized */ - - initialized = true; + ret = ads7843e_register(dev, &g_tscinfo.config, CONFIG_ADS7843E_DEVMINOR); + if (ret < 0) + { + ierr("ERROR: Failed to register touchscreen device\n"); + /* up_spiuninitialize(dev); */ + return -ENODEV; } return OK; } -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void board_tsc_teardown(void) -{ - /* No support for un-initializing the touchscreen XPT2046 device. It will - * continue to run and process touch interrupts in the background. - */ -} - #endif /* CONFIG_INPUT_ADS7843E */ diff --git a/configs/viewtool-stm32f107/src/viewtool_stm32f107.h b/configs/viewtool-stm32f107/src/viewtool_stm32f107.h index 8ec579e1407..8a196108c54 100644 --- a/configs/viewtool-stm32f107/src/viewtool_stm32f107.h +++ b/configs/viewtool-stm32f107/src/viewtool_stm32f107.h @@ -1,7 +1,7 @@ /**************************************************************************** * configs/viewtool-stm32f107/src/viewtool_stm32f107.h * - * Copyright (C) 2013-2014, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2014, 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -348,8 +348,8 @@ void stm32_led_initialize(void); * Name: stm32_usbdev_initialize * * Description: - * Called from stm32_usbdev_initialize very early in initialization to setup USB-related - * GPIO pins for the Viewtool STM32F107 board. + * Called from stm32_usbdev_initialize very early in initialization to + * setup USB-related GPIO pins for the Viewtool STM32F107 board. * ****************************************************************************/ @@ -357,6 +357,27 @@ void stm32_led_initialize(void); void weak_function stm32_usbdev_initialize(void); #endif +/**************************************************************************** + * Name: stm32_tsc_setup + * + * Description: + * This function is called by board-bringup logic to configure the + * touchscreen device. This function will register the driver as + * /dev/inputN where N is the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_INPUT_ADS7843E +int stm32_tsc_setup(int minor); +#endif + /**************************************************************************** * Name: stm32_sdinitialize * diff --git a/fs/smartfs/smartfs_utils.c b/fs/smartfs/smartfs_utils.c index 99bb8c16567..0fcfecfd4ed 100644 --- a/fs/smartfs/smartfs_utils.c +++ b/fs/smartfs/smartfs_utils.c @@ -1825,6 +1825,7 @@ int smartfs_shrinkfile(FAR struct smartfs_mountpt_s *fs, { dest = (FAR uint8_t *)&sf->buffer; destsize = fs->fs_llformat.availbytes; + } else { offset = sizeof(struct smartfs_chain_header_s) + length; diff --git a/include/nuttx/board.h b/include/nuttx/board.h index af120a8808e..5c646a48a96 100644 --- a/include/nuttx/board.h +++ b/include/nuttx/board.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/board.h * - * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -285,58 +285,6 @@ int board_composite_initialize(int port); FAR void *board_composite_connect(int port, int configid); #endif -/**************************************************************************** - * Name: board_tsc_setup - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * configure the touchscreen device. This function will register the driver - * as /dev/inputN where N is the minor device number. - * - * This is an internal OS interface but may be invoked indirectly from - * application-level touchscreen testing logic (perhaps by - * apps/examples/touchscreen). If CONFIG_LIB_BOARDCTL=y and - * CONFIG_BOARDCTL_TSCTEST=y, then this functions will be invoked via the - * (non-standard) boardctl() interface using the BOARDIOC_TSCTEST_SETUP - * command. - * - * Input Parameters: - * minor - The input device minor number - * - * Returned Value: - * Zero is returned on success. Otherwise, a negated errno value is - * returned to indicate the nature of the failure. - * - ****************************************************************************/ - -int board_tsc_setup(int minor); - -/**************************************************************************** - * Name: board_tsc_teardown - * - * Description: - * Each board that supports a touchscreen device must provide this function. - * This function is called by application-specific, setup logic to - * uninitialize the touchscreen device. - * - * This is an internal OS interface but may be invoked indirectly from - * application-level touchscreen testing logic (perhaps by - * apps/examples/touchscreen). If CONFIG_LIB_BOARDCTL=y and - * CONFIG_BOARDCTL_TSCTEST=y, then this functions will be invoked via the - * (non-standard) boardctl() interface using the BOARDIOC_TSCTEST_TEARDOWN - * command. - * - * Input Parameters: - * None - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void board_tsc_teardown(void); - /**************************************************************************** * Name: board_graphics_setup * diff --git a/include/nuttx/spinlock.h b/include/nuttx/spinlock.h index 3798e177ff5..7ce1c1594e0 100644 --- a/include/nuttx/spinlock.h +++ b/include/nuttx/spinlock.h @@ -197,6 +197,30 @@ void spin_initializer(FAR struct spinlock_s *lock); void spin_lock(FAR volatile spinlock_t *lock); +/**************************************************************************** + * Name: spin_lock_wo_note + * + * Description: + * If this CPU does not already hold the spinlock, then loop until the + * spinlock is successfully locked. + * + * This implementation is the same as the above spin_lock() except that + * it does not perform instrumentation logic. + * + * Input Parameters: + * lock - A reference to the spinlock object to lock. + * + * Returned Value: + * None. When the function returns, the spinlock was successfully locked + * by this CPU. + * + * Assumptions: + * Not running at the interrupt level. + * + ****************************************************************************/ + +void spin_lock_wo_note(FAR volatile spinlock_t *lock); + /**************************************************************************** * Name: spin_trylock * @@ -268,6 +292,28 @@ void spin_unlock(FAR volatile spinlock_t *lock); # define spin_unlock(l) do { *(l) = SP_UNLOCKED; } while (0) #endif +/**************************************************************************** + * Name: spin_unlock_wo_note + * + * Description: + * Release one count on a non-reentrant spinlock. + * + * This implementation is the same as the above spin_unlock() except that + * it does not perform instrumentation logic. + * + * Input Parameters: + * lock - A reference to the spinlock object to unlock. + * + * Returned Value: + * None. + * + * Assumptions: + * Not running at the interrupt level. + * + ****************************************************************************/ + +void spin_unlock_wo_note(FAR volatile spinlock_t *lock); + /**************************************************************************** * Name: spin_unlockr * diff --git a/include/sys/boardctl.h b/include/sys/boardctl.h index d059b9f8283..907fbd66067 100644 --- a/include/sys/boardctl.h +++ b/include/sys/boardctl.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/sys/boardctl.h * - * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -114,18 +114,6 @@ * ARG: None * CONFIGURATION: CONFIG_NX * DEPENDENCIES: Base graphics logic provides nx_start() - * - * CMD: BOARDIOC_TSCTEST_SETUP - * DESCRIPTION: Touchscreen controller test configuration - * ARG: Touch controller device minor number - * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST - * DEPENDENCIES: Board logic must provide board_tsc_setup() - * - * CMD: BOARDIOC_TSCTEST_TEARDOWN - * DESCRIPTION: Touchscreen controller test configuration - * ARG: None - * CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_TSCTEST - * DEPENDENCIES: Board logic must provide board_tsc_teardown() */ #define BOARDIOC_INIT _BOARDIOC(0x0001) @@ -136,8 +124,6 @@ #define BOARDIOC_OS_SYMTAB _BOARDIOC(0x0006) #define BOARDIOC_USBDEV_CONTROL _BOARDIOC(0x0007) #define BOARDIOC_NX_START _BOARDIOC(0x0008) -#define BOARDIOC_TSCTEST_SETUP _BOARDIOC(0x0009) -#define BOARDIOC_TSCTEST_TEARDOWN _BOARDIOC(0x000a) /* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support. * In this case, all commands not recognized by boardctl() will be forwarded @@ -146,7 +132,7 @@ * User defined board commands may begin with this value: */ -#define BOARDIOC_USER _BOARDIOC(0x000b) +#define BOARDIOC_USER _BOARDIOC(0x0009) /**************************************************************************** * Public Type Definitions diff --git a/sched/sched/sched_note.c b/sched/sched/sched_note.c index 6dc17b9936a..40470b6561f 100644 --- a/sched/sched/sched_note.c +++ b/sched/sched/sched_note.c @@ -94,6 +94,10 @@ static void note_add(FAR const uint8_t *note, uint8_t notelen); static struct note_info_s g_note_info; +#ifdef CONFIG_SMP +static volatile spinlock_t g_note_lock; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -299,21 +303,10 @@ static void note_add(FAR const uint8_t *note, uint8_t notelen) } #endif - /* REVISIT: In the single CPU case, the following should be safe because - * the logic is always called within a critical section, but in the SMP - * case we have protection. One option would be to precalculate and - * advancing the new head entry before writing the data into the buffer. - * That will eliminate fatal race conditions (although could result in - * single notes being corrupted harmlessly). - * - * But there is a complexity: Advancing the head pointer where the note - * buffer is almost full could advance the head to wrap beyond the tail - * leaving the buffer in a bad state. A solution to this would be to pre- - * remove entries at the tail of the buffer as necessary to make certain - * that there will be space for the new note at the beginning of the - * buffer. I am less certain that this can be done safely in the SMP - * case. - */ +#ifdef CONFIG_SMP + irqstate_t flags = up_irq_save(); + spin_lock_wo_note(&g_note_lock); +#endif /* Get the index to the head of the circular buffer */ @@ -345,6 +338,11 @@ static void note_add(FAR const uint8_t *note, uint8_t notelen) } g_note_info.ni_head = head; + +#ifdef CONFIG_SMP + spin_unlock_wo_note(&g_note_lock); + up_irq_restore(flags); +#endif } /**************************************************************************** diff --git a/sched/semaphore/spinlock.c b/sched/semaphore/spinlock.c index 674ebb6b522..2d667c0ed39 100644 --- a/sched/semaphore/spinlock.c +++ b/sched/semaphore/spinlock.c @@ -139,6 +139,38 @@ void spin_lock(FAR volatile spinlock_t *lock) SP_DMB(); } +/**************************************************************************** + * Name: spin_lock_wo_note + * + * Description: + * If this CPU does not already hold the spinlock, then loop until the + * spinlock is successfully locked. + * + * This implementation is the same as the above spin_lock() except that + * it does not perform instrumentation logic. + * + * Input Parameters: + * lock - A reference to the spinlock object to lock. + * + * Returned Value: + * None. When the function returns, the spinlock was successfully locked + * by this CPU. + * + * Assumptions: + * Not running at the interrupt level. + * + ****************************************************************************/ + +void spin_lock_wo_note(FAR volatile spinlock_t *lock) +{ + while (up_testset(lock) == SP_LOCKED) + { + SP_DSB(); + } + + SP_DMB(); +} + /**************************************************************************** * Name: spin_unlock * @@ -171,6 +203,33 @@ void spin_unlock(FAR volatile spinlock_t *lock) } #endif +/**************************************************************************** + * Name: spin_unlock_wo_note + * + * Description: + * Release one count on a non-reentrant spinlock. + * + * This implementation is the same as the above spin_unlock() except that + * it does not perform instrumentation logic. + * + * Input Parameters: + * lock - A reference to the spinlock object to unlock. + * + * Returned Value: + * None. + * + * Assumptions: + * Not running at the interrupt level. + * + ****************************************************************************/ + +void spin_unlock_wo_note(FAR volatile spinlock_t *lock) +{ + SP_DMB(); + *lock = SP_UNLOCKED; + SP_DSB(); +} + /**************************************************************************** * Name: spin_lockr *