Adapt more drivers to utilize the IRQ argument feature.
This commit is contained in:
parent
7d2d541c70
commit
c62180732e
@ -140,7 +140,6 @@ struct twi_attr_s
|
||||
gpio_pinset_t sclcfg; /* TWIHS CK pin configuration (SCL in I2C-ese) */
|
||||
gpio_pinset_t sdacfg; /* TWIHS D pin configuration (SDA in I2C-ese) */
|
||||
uintptr_t base; /* Base address of TWIHS registers */
|
||||
xcpt_t handler; /* TWIHS interrupt handler */
|
||||
};
|
||||
|
||||
/* State of a TWIHS bus */
|
||||
@ -199,18 +198,9 @@ static inline void twi_putrel(struct twi_dev_s *priv, unsigned int offset,
|
||||
|
||||
/* I2C transfer helper functions */
|
||||
|
||||
static int twi_wait(struct twi_dev_s *priv, unsigned int size);
|
||||
static int twi_wait(struct twi_dev_s *priv, unsigned int size);
|
||||
static void twi_wakeup(struct twi_dev_s *priv, int result);
|
||||
static int twi_interrupt(struct twi_dev_s *priv);
|
||||
#ifdef CONFIG_SAMV7_TWIHS0
|
||||
static int twi0_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||
#endif
|
||||
#ifdef CONFIG_SAMV7_TWIHS1
|
||||
static int twi1_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||
#endif
|
||||
#ifdef CONFIG_SAMV7_TWIHS2
|
||||
static int twi2_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||
#endif
|
||||
static int twi_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||
static void twi_timeout(int argc, uint32_t arg, ...);
|
||||
|
||||
static void twi_startread(struct twi_dev_s *priv, struct i2c_msg_s *msg);
|
||||
@ -250,7 +240,6 @@ static const struct twi_attr_s g_twi0attr =
|
||||
.sclcfg = GPIO_TWIHS0_CK,
|
||||
.sdacfg = GPIO_TWIHS0_D,
|
||||
.base = SAM_TWIHS0_BASE,
|
||||
.handler = twi0_interrupt,
|
||||
};
|
||||
|
||||
static struct twi_dev_s g_twi0;
|
||||
@ -271,7 +260,6 @@ static const struct twi_attr_s g_twi1attr =
|
||||
.sclcfg = GPIO_TWIHS1_CK,
|
||||
.sdacfg = GPIO_TWIHS1_D,
|
||||
.base = SAM_TWIHS1_BASE,
|
||||
.handler = twi1_interrupt,
|
||||
};
|
||||
|
||||
static struct twi_dev_s g_twi1;
|
||||
@ -292,7 +280,6 @@ static const struct twi_attr_s g_twi2attr =
|
||||
.sclcfg = GPIO_TWIHS2_CK,
|
||||
.sdacfg = GPIO_TWIHS2_D,
|
||||
.base = SAM_TWIHS2_BASE,
|
||||
.handler = twi2_interrupt,
|
||||
};
|
||||
|
||||
static struct twi_dev_s g_twi2;
|
||||
@ -571,14 +558,17 @@ static void twi_wakeup(struct twi_dev_s *priv, int result)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int twi_interrupt(struct twi_dev_s *priv)
|
||||
static int twi_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
struct twi_dev_s *priv = (struct twi_dev_s *)arg;
|
||||
struct i2c_msg_s *msg;
|
||||
uint32_t sr;
|
||||
uint32_t imr;
|
||||
uint32_t pending;
|
||||
uint32_t regval;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
/* Retrieve masked interrupt status */
|
||||
|
||||
sr = twi_getrel(priv, SAM_TWIHS_SR_OFFSET);
|
||||
@ -761,27 +751,6 @@ static int twi_interrupt(struct twi_dev_s *priv)
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SAMV7_TWIHS0
|
||||
static int twi0_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
return twi_interrupt(&g_twi0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SAMV7_TWIHS1
|
||||
static int twi1_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
return twi_interrupt(&g_twi1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SAMV7_TWIHS2
|
||||
static int twi2_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
return twi_interrupt(&g_twi2);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: twi_timeout
|
||||
*
|
||||
@ -1444,7 +1413,7 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
|
||||
|
||||
/* Attach Interrupt Handler */
|
||||
|
||||
ret = irq_attach(priv->attr->irq, priv->attr->handler, NULL);
|
||||
ret = irq_attach(priv->attr->irq, twi_interrupt, priv);
|
||||
if (ret < 0)
|
||||
{
|
||||
ierr("ERROR: Failed to attach irq %d\n", priv->attr->irq);
|
||||
|
@ -135,7 +135,6 @@ struct stm32_dev_s
|
||||
#ifdef SDADC_HAVE_TIMER
|
||||
uint8_t trigger; /* Timer trigger selection: see SDADCx_JEXTSEL_TIMxx */
|
||||
#endif
|
||||
xcpt_t isr; /* Interrupt handler for this SDADC block */
|
||||
uint32_t base; /* Base address of registers unique to this SDADC
|
||||
* block */
|
||||
#ifdef SDADC_HAVE_TIMER
|
||||
@ -182,16 +181,7 @@ static void sdadc_rccreset(FAR struct stm32_dev_s *priv, bool reset);
|
||||
|
||||
/* ADC Interrupt Handler */
|
||||
|
||||
static int sdadc_interrupt(FAR struct adc_dev_s *dev);
|
||||
#if defined(CONFIG_STM32_SDADC1)
|
||||
static int sdadc1_interrupt(int irq, FAR void *context, FAR void * arg);
|
||||
#endif
|
||||
#if defined(CONFIG_STM32_SDADC2)
|
||||
static int sdadc2_interrupt(int irq, FAR void *context, FAR void * arg);
|
||||
#endif
|
||||
#if defined(CONFIG_STM32_SDADC3)
|
||||
static int sdadc3_interrupt(int irq, FAR void *context, FAR void * arg);
|
||||
#endif
|
||||
static int sdadc_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||
|
||||
/* ADC Driver Methods */
|
||||
|
||||
@ -241,7 +231,6 @@ static const struct adc_ops_s g_sdadcops =
|
||||
static struct stm32_dev_s g_sdadcpriv1 =
|
||||
{
|
||||
.irq = STM32_IRQ_SDADC1,
|
||||
.isr = sdadc1_interrupt,
|
||||
.intf = 1,
|
||||
.base = STM32_SDADC1_BASE,
|
||||
.refv = SDADC1_REFV,
|
||||
@ -271,8 +260,6 @@ static struct adc_dev_s g_sdadcdev1 =
|
||||
static struct stm32_dev_s g_sdadcpriv2 =
|
||||
{
|
||||
.irq = STM32_IRQ_SDADC2,
|
||||
.isr = sdadc2_interrupt,
|
||||
.intf = 2,
|
||||
.base = STM32_SDADC2_BASE,
|
||||
.refv = SDADC2_REFV,
|
||||
#ifdef SDADC2_HAVE_TIMER
|
||||
@ -301,8 +288,6 @@ static struct adc_dev_s g_sdadcdev2 =
|
||||
static struct stm32_dev_s g_sdadcpriv3 =
|
||||
{
|
||||
.irq = STM32_IRQ_SDADC3,
|
||||
.isr = sdadc3_interrupt,
|
||||
.intf = 3,
|
||||
.base = STM32_SDADC3_BASE,
|
||||
.refv = SDADC3_REFV,
|
||||
#ifdef SDADC3_HAVE_TIMER
|
||||
@ -998,7 +983,7 @@ static int sdadc_setup(FAR struct adc_dev_s *dev)
|
||||
{
|
||||
/* Attach the SDADC interrupt */
|
||||
|
||||
ret = irq_attach(priv->irq, priv->isr, NULL);
|
||||
ret = irq_attach(priv->irq, sdadc_interrupt, dev);
|
||||
if (ret < 0)
|
||||
{
|
||||
ainfo("irq_attach failed: %d\n", ret);
|
||||
@ -1008,7 +993,7 @@ static int sdadc_setup(FAR struct adc_dev_s *dev)
|
||||
#else
|
||||
/* Attach the SDADC interrupt */
|
||||
|
||||
ret = irq_attach(priv->irq, priv->isr, NULL);
|
||||
ret = irq_attach(priv->irq, sdadc_interrupt, dev);
|
||||
if (ret < 0)
|
||||
{
|
||||
ainfo("irq_attach failed: %d\n", ret);
|
||||
@ -1220,14 +1205,18 @@ static int sdadc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int sdadc_interrupt(FAR struct adc_dev_s *dev)
|
||||
static int sdadc_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
FAR struct stm32_dev_s *priv = (FAR struct stm32_dev_s *)dev->ad_priv;
|
||||
FAR struct adc_dev_s *dev = (FAR struct adc_dev_s *)arg;
|
||||
FAR struct stm32_dev_s *priv;
|
||||
uint32_t regval;
|
||||
uint32_t pending;
|
||||
int32_t data;
|
||||
uint8_t chan;
|
||||
|
||||
DEBUGASSERT(dev != NULL && dev->ad_priv != NULL);
|
||||
priv = (FAR struct stm32_dev_s *)dev->ad_priv;
|
||||
|
||||
regval = sdadc_getreg(priv, STM32_SDADC_ISR_OFFSET);
|
||||
pending = regval & SDADC_ISR_ALLINTS;
|
||||
if (pending == 0)
|
||||
@ -1298,75 +1287,6 @@ static int sdadc_interrupt(FAR struct adc_dev_s *dev)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adc1_interrupt
|
||||
*
|
||||
* Description:
|
||||
* ADC interrupt handler SDADC1
|
||||
*
|
||||
* Input Parameters:
|
||||
* irq - The IRQ number that generated the interrupt.
|
||||
* context - Architecture specific register save information.
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_STM32_SDADC1)
|
||||
static int sdadc1_interrupt(int irq, FAR void *context, FAR void * arg)
|
||||
{
|
||||
sdadc_interrupt(&g_sdadcdev1);
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adc2_interrupt
|
||||
*
|
||||
* Description:
|
||||
* ADC interrupt handler SDADC2
|
||||
*
|
||||
* Input Parameters:
|
||||
* irq - The IRQ number that generated the interrupt.
|
||||
* context - Architecture specific register save information.
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_STM32_SDADC2)
|
||||
static int sdadc2_interrupt(int irq, FAR void *context, FAR void * arg)
|
||||
{
|
||||
sdadc_interrupt(&g_sdadcdev2);
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: adc3_interrupt
|
||||
*
|
||||
* Description:
|
||||
* ADC interrupt handler SDADC3
|
||||
*
|
||||
* Input Parameters:
|
||||
* irq - The IRQ number that generated the interrupt.
|
||||
* context - Architecture specific register save information.
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_STM32_SDADC3)
|
||||
static int sdadc3_interrupt(int irq, FAR void *context, FAR void * arg)
|
||||
{
|
||||
sdadc_interrupt(&g_sdadcdev3);
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user