configs: Since the touch screen initialization is now called from one-time board-initialization logic, it no longer needs protection from re-entry.

This commit is contained in:
Gregory Nutt 2018-01-17 10:14:03 -06:00
parent 301bf1ee77
commit 43390c78ea
6 changed files with 114 additions and 190 deletions

View File

@ -355,50 +355,36 @@ static FAR struct spi_dev_s *sam_tsc_spiinitialize(void)
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;

View File

@ -272,50 +272,40 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state)
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;

View File

@ -88,38 +88,28 @@
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;

View File

@ -238,52 +238,38 @@ static int mxt_interrupt(int irq, FAR void *context, FAR void *arg)
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;

View File

@ -237,52 +237,38 @@ static int mxt_interrupt(int irq, FAR void *context, FAR void *arg)
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;

View File

@ -258,46 +258,32 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state)
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;