mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 13:18:50 +08:00
STMPE811 driver needs argument in interrupt handler
This commit is contained in:
parent
cb927e3226
commit
a773f9412a
7 changed files with 35 additions and 58 deletions
|
@ -137,6 +137,7 @@ struct stm32_stmpe811config_s
|
|||
|
||||
STMPE811_HANDLE handle; /* The STMPE811 driver handle */
|
||||
xcpt_t handler; /* The STMPE811 interrupt handler */
|
||||
void *arg; /* Interrupt handler argument */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -152,7 +153,8 @@ struct stm32_stmpe811config_s
|
|||
* clear - Acknowledge/clear any pending GPIO interrupt
|
||||
*/
|
||||
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr);
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr,
|
||||
FAR void *arg);
|
||||
static void stmpe811_enable(FAR struct stmpe811_config_s *state, bool enable);
|
||||
static void stmpe811_clear(FAR struct stmpe811_config_s *state);
|
||||
|
||||
|
@ -191,6 +193,7 @@ static struct stm32_stmpe811config_s g_stmpe811config =
|
|||
.clear = stmpe811_clear,
|
||||
},
|
||||
.handler = NULL,
|
||||
.arg = NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -207,7 +210,8 @@ static struct stm32_stmpe811config_s g_stmpe811config =
|
|||
* clear - Acknowledge/clear any pending GPIO interrupt
|
||||
*/
|
||||
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr)
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr,
|
||||
FAR void *arg)
|
||||
{
|
||||
FAR struct stm32_stmpe811config_s *priv = (FAR struct stm32_stmpe811config_s *)state;
|
||||
|
||||
|
@ -217,6 +221,7 @@ static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr)
|
|||
/* Just save the handler. We will use it when EXTI interruptsare enabled */
|
||||
|
||||
priv->handler = isr;
|
||||
priv->arg = arg;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ struct stm32_stmpe811config_s
|
|||
|
||||
STMPE811_HANDLE handle; /* The STMPE811 driver handle */
|
||||
xcpt_t handler; /* The STMPE811 interrupt handler */
|
||||
FAR void *arg; /* Interrupt handler argument */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -152,7 +153,8 @@ struct stm32_stmpe811config_s
|
|||
* clear - Acknowledge/clear any pending GPIO interrupt
|
||||
*/
|
||||
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr);
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr,
|
||||
FAR void *arg);
|
||||
static void stmpe811_enable(FAR struct stmpe811_config_s *state, bool enable);
|
||||
static void stmpe811_clear(FAR struct stmpe811_config_s *state);
|
||||
|
||||
|
@ -191,6 +193,7 @@ static struct stm32_stmpe811config_s g_stmpe811config =
|
|||
.clear = stmpe811_clear,
|
||||
},
|
||||
.handler = NULL,
|
||||
.arg = NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -207,7 +210,8 @@ static struct stm32_stmpe811config_s g_stmpe811config =
|
|||
* clear - Acknowledge/clear any pending GPIO interrupt
|
||||
*/
|
||||
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr)
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr,
|
||||
FAR void *arg)
|
||||
{
|
||||
FAR struct stm32_stmpe811config_s *priv = (FAR struct stm32_stmpe811config_s *)state;
|
||||
|
||||
|
@ -217,6 +221,7 @@ static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr)
|
|||
/* Just save the handler. We will use it when EXTI interruptsare enabled */
|
||||
|
||||
priv->handler = isr;
|
||||
priv->arg = arg;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ struct stm32_stmpe811config_s
|
|||
|
||||
STMPE811_HANDLE handle; /* The STMPE811 driver handle */
|
||||
xcpt_t handler; /* The STMPE811 interrupt handler */
|
||||
FAR void *arg; /* Interrupt handler argument */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -153,7 +154,8 @@ struct stm32_stmpe811config_s
|
|||
* clear - Acknowledge/clear any pending GPIO interrupt
|
||||
*/
|
||||
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr);
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr,
|
||||
FAR void *arg);
|
||||
static void stmpe811_enable(FAR struct stmpe811_config_s *state, bool enable);
|
||||
static void stmpe811_clear(FAR struct stmpe811_config_s *state);
|
||||
|
||||
|
@ -192,6 +194,7 @@ static struct stm32_stmpe811config_s g_stmpe811config =
|
|||
.clear = stmpe811_clear,
|
||||
},
|
||||
.handler = NULL,
|
||||
.arg = NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -208,7 +211,8 @@ static struct stm32_stmpe811config_s g_stmpe811config =
|
|||
* clear - Acknowledge/clear any pending GPIO interrupt
|
||||
*/
|
||||
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr)
|
||||
static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr,
|
||||
FAR void *arg)
|
||||
{
|
||||
FAR struct stm32_stmpe811config_s *priv =
|
||||
(FAR struct stm32_stmpe811config_s *)state;
|
||||
|
@ -219,6 +223,7 @@ static int stmpe811_attach(FAR struct stmpe811_config_s *state, xcpt_t isr)
|
|||
/* Just save the handler. We will use it when EXTI interruptsare enabled */
|
||||
|
||||
priv->handler = isr;
|
||||
priv->arg = arg;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* drivers/input/stmpe811_base.c
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* References:
|
||||
|
@ -54,10 +54,6 @@
|
|||
|
||||
#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_STMPE811)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
@ -155,30 +151,14 @@ static void stmpe811_worker(FAR void *arg)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stmpe811_interrupt(int irq, FAR void *context)
|
||||
static int stmpe811_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
FAR struct stmpe811_dev_s *priv;
|
||||
FAR struct stmpe811_dev_s *priv = (FAR struct stmpe811_dev_s *)arg;
|
||||
FAR struct stmpe811_config_s *config;
|
||||
int ret;
|
||||
|
||||
/* Which STMPE811 device caused the interrupt? */
|
||||
|
||||
#ifndef CONFIG_STMPE811_MULTIPLE
|
||||
priv = &g_stmpe811;
|
||||
#else
|
||||
for (priv = g_stmpe811list;
|
||||
priv && priv->config->irq != irq;
|
||||
priv = priv->flink);
|
||||
|
||||
ASSERT(priv != NULL);
|
||||
#endif
|
||||
|
||||
/* Get a pointer the callbacks for convenience (and so the code is not so
|
||||
* ugly).
|
||||
*/
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(priv != NULL && priv->config != NULL);
|
||||
config = priv->config;
|
||||
DEBUGASSERT(config != NULL);
|
||||
|
||||
/* Disable further interrupts */
|
||||
|
||||
|
@ -359,7 +339,7 @@ STMPE811_HANDLE stmpe811_instantiate(FAR struct i2c_master_s *dev,
|
|||
|
||||
/* Attach the STMPE811 interrupt handler. */
|
||||
|
||||
config->attach(config, stmpe811_interrupt);
|
||||
config->attach(config, stmpe811_interrupt, priv);
|
||||
|
||||
/* Clear any pending interrupts */
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ static uint8_t nrf24l01_setregbit(FAR struct nrf24l01_dev_s *dev, uint8_t reg,
|
|||
|
||||
static void nrf24l01_tostate(FAR struct nrf24l01_dev_s *dev, nrf24l01_state_t state);
|
||||
|
||||
static int nrf24l01_irqhandler(FAR int irq, FAR void *context);
|
||||
static int nrf24l01_irqhandler(FAR int irq, FAR void *context, FAR void *arg);
|
||||
|
||||
static inline int nrf24l01_attachirq(FAR struct nrf24l01_dev_s *dev, xcpt_t isr);
|
||||
|
||||
|
@ -222,8 +222,6 @@ static int nrf24l01_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
|||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct nrf24l01_dev_s *g_nrf24l01dev;
|
||||
|
||||
static const struct file_operations nrf24l01_fops =
|
||||
{
|
||||
nrf24l01_open, /* open */
|
||||
|
@ -491,9 +489,9 @@ uint8_t fifoget(struct nrf24l01_dev_s *dev, uint8_t *buffer, uint8_t buflen, uin
|
|||
|
||||
#endif
|
||||
|
||||
static int nrf24l01_irqhandler(int irq, FAR void *context)
|
||||
static int nrf24l01_irqhandler(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
FAR struct nrf24l01_dev_s *dev = g_nrf24l01dev;
|
||||
FAR struct nrf24l01_dev_s *dev = (FAR struct nrf24l01_dev_s *)arg;
|
||||
|
||||
winfo("*IRQ*");
|
||||
|
||||
|
@ -501,7 +499,7 @@ static int nrf24l01_irqhandler(int irq, FAR void *context)
|
|||
|
||||
/* If RX is enabled we delegate the actual work to bottom-half handler */
|
||||
|
||||
work_queue(HPWORK, &g_nrf24l01dev->irq_work, nrf24l01_worker, dev, 0);
|
||||
work_queue(HPWORK, &priv->irq_work, nrf24l01_worker, dev, 0);
|
||||
#else
|
||||
|
||||
/* Otherwise we simply wake up the send function */
|
||||
|
@ -1179,9 +1177,8 @@ static int nrf24l01_unregister(FAR struct nrf24l01_dev_s *dev)
|
|||
|
||||
nrf24l01_attachirq(dev, NULL);
|
||||
|
||||
g_nrf24l01dev = NULL;
|
||||
|
||||
/* Free memory */
|
||||
|
||||
#ifdef CONFIG_WL_NRF24L01_RXSUPPORT
|
||||
kmm_free(dev->rx_fifo);
|
||||
#endif
|
||||
|
@ -1244,13 +1241,9 @@ int nrf24l01_register(FAR struct spi_dev_s *spi, FAR struct nrf24l01_config_s *c
|
|||
sem_setprotocol(&dev->sem_rx, SEM_PRIO_NONE);
|
||||
#endif
|
||||
|
||||
/* Set the global reference */
|
||||
|
||||
g_nrf24l01dev = dev;
|
||||
|
||||
/* Configure IRQ pin (falling edge) */
|
||||
|
||||
nrf24l01_attachirq(dev, nrf24l01_irqhandler);
|
||||
nrf24l01_attachirq(dev, nrf24l01_irqhandler, dev);
|
||||
|
||||
/* Register the device as an input device */
|
||||
|
||||
|
@ -1266,11 +1259,6 @@ int nrf24l01_register(FAR struct spi_dev_s *spi, FAR struct nrf24l01_config_s *c
|
|||
return result;
|
||||
}
|
||||
|
||||
FAR struct nrf24l01_dev_s * nrf24l01_getinstance(void)
|
||||
{
|
||||
return g_nrf24l01dev;
|
||||
}
|
||||
|
||||
/* (re)set the device in a default initial state */
|
||||
|
||||
int nrf24l01_init(FAR struct nrf24l01_dev_s *dev)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/********************************************************************************************
|
||||
* include/nuttx/input/stmpe811.h
|
||||
*
|
||||
* Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* References:
|
||||
|
@ -500,7 +500,7 @@ struct stmpe811_config_s
|
|||
* clear - Acknowledge/clear any pending GPIO interrupt
|
||||
*/
|
||||
|
||||
int (*attach)(FAR struct stmpe811_config_s *state, xcpt_t isr);
|
||||
int (*attach)(FAR struct stmpe811_config_s *state, xcpt_t isr, FAR void *arg);
|
||||
void (*enable)(FAR struct stmpe811_config_s *state, bool enable);
|
||||
void (*clear)(FAR struct stmpe811_config_s *state);
|
||||
};
|
||||
|
|
|
@ -235,12 +235,6 @@ int nrf24l01_register(FAR struct spi_dev_s *spi, FAR struct nrf24l01_config_s *c
|
|||
|
||||
int nrf24l01_init(FAR struct nrf24l01_dev_s *dev);
|
||||
|
||||
/************************************************************************************
|
||||
* Get a pointer to the registered device
|
||||
************************************************************************************/
|
||||
|
||||
FAR struct nrf24l01_dev_s * nrf24l01_getinstance(void);
|
||||
|
||||
/************************************************************************************
|
||||
* Set the default TX address.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue