diff options
Diffstat (limited to 'nuttx/configs/stm3240g-eval/src/up_stmpe11.c')
-rw-r--r-- | nuttx/configs/stm3240g-eval/src/up_stmpe11.c | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/nuttx/configs/stm3240g-eval/src/up_stmpe11.c b/nuttx/configs/stm3240g-eval/src/up_stmpe11.c index 66e844c01..a9402eda7 100644 --- a/nuttx/configs/stm3240g-eval/src/up_stmpe11.c +++ b/nuttx/configs/stm3240g-eval/src/up_stmpe11.c @@ -181,7 +181,7 @@ static struct stm32_stmpe11config_s g_stmpe11config = #ifdef CONFIG_STMPE11_MULTIPLE .irq = STM32_IRQ_EXTI2, #endif - .ctrl1 = (ADC_CTRL1_SAMPLE_TIME_80|ADC_CTRL1_MOD_12B|ADC_CTRL1_REF_SEL), + .ctrl1 = (ADC_CTRL1_SAMPLE_TIME_80 | ADC_CTRL1_MOD_12B), .ctrl2 = ADC_CTRL2_ADC_FREQ_3p25, .attach = stmpe11_attach, @@ -262,39 +262,44 @@ int arch_tcinitialize(void) FAR struct i2c_dev_s *dev; int ret; - ivdbg("Initializing\n"); + /* Check if we are already initialized */ - /* Configure and enable the STMPE11 interrupt pin as an input */ + if (!g_stmpe11config.handle) + { + ivdbg("Initializing\n"); - (void)stm32_configgpio(GPIO_IO_EXPANDER); + /* Configure the STMPE11 interrupt pin as an input */ - /* Get an instance of the I2C interface */ + (void)stm32_configgpio(GPIO_IO_EXPANDER); - dev = up_i2cinitialize(CONFIG_STMPE11_I2CDEV); - if (!dev) - { - idbg("Failed to initialize I2C bus %d\n", CONFIG_STMPE11_I2CDEV); - return -ENODEV; - } + /* Get an instance of the I2C interface */ - /* Instantiate the STMPE11 driver */ + dev = up_i2cinitialize(CONFIG_STMPE11_I2CDEV); + if (!dev) + { + idbg("Failed to initialize I2C bus %d\n", CONFIG_STMPE11_I2CDEV); + return -ENODEV; + } - g_stmpe11config.handle = - stmpe11_instantiate(dev, (FAR struct stmpe11_config_s *)&g_stmpe11config); - if (!g_stmpe11config.handle) - { - idbg("Failed to instantiate the STMPE11 driver\n"); - return -ENODEV; - } + /* Instantiate the STMPE11 driver */ - /* Initialize and register the I2C touschscreen device */ + g_stmpe11config.handle = + stmpe11_instantiate(dev, (FAR struct stmpe11_config_s *)&g_stmpe11config); + if (!g_stmpe11config.handle) + { + idbg("Failed to instantiate the STMPE11 driver\n"); + return -ENODEV; + } - ret = stmpe11_register(dev, CONFIG_STMPE11_DEVMINOR); - if (ret < 0) - { - idbg("Failed to register STMPE driver: %d\n", ret); - /* up_i2cuninitialize(dev); */ - return -ENODEV; + /* Initialize and register the I2C touchscreen device */ + + ret = stmpe11_register(g_stmpe11config.handle, CONFIG_STMPE11_DEVMINOR); + if (ret < 0) + { + idbg("Failed to register STMPE driver: %d\n", ret); + /* up_i2cuninitialize(dev); */ + return -ENODEV; + } } return OK; |