EFM32, STM32, and STM32 F7 I2C: Update to use the standard parameter passing to interrupt handlers.

This commit is contained in:
Gregory Nutt 2017-04-30 11:56:06 -06:00
parent dee736bd0d
commit c172d7cf63
6 changed files with 105 additions and 377 deletions

View File

@ -220,7 +220,6 @@ struct efm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
int (*isr) (int, void *, void *); /* Interrupt handler */
uint32_t irq; /* Event IRQ */
#endif
};
@ -294,15 +293,10 @@ static void efm32_i2c_tracedump(FAR struct efm32_i2c_priv_s *priv);
static void efm32_i2c_setclock(FAR struct efm32_i2c_priv_s *priv,
uint32_t frequency);
static int efm32_i2c_isr(struct efm32_i2c_priv_s *priv);
static int efm32_i2c_isr_process(struct efm32_i2c_priv_s *priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_EFM32_I2C0
static int efm32_i2c0_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_EFM32_I2C1
static int efm32_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
static int efm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif /* !CONFIG_I2C_POLLED */
static void efm32_i2c_hwreset(FAR struct efm32_i2c_priv_s *priv);
@ -343,7 +337,6 @@ static const struct efm32_i2c_config_s efm32_i2c0_config =
.scl_pin = BOARD_I2C0_SCL,
.sda_pin = BOARD_I2C0_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = efm32_i2c0_isr,
.irq = EFM32_IRQ_I2C0
#endif
};
@ -371,7 +364,6 @@ static const struct efm32_i2c_config_s efm32_i2c1_config =
.scl_pin = BOARD_I2C1_SCL,
.sda_pin = BOARD_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = efm32_i2c1_isr,
.irq = EFM32_IRQ_I2C1
#endif
};
@ -632,7 +624,7 @@ static inline int efm32_i2c_sem_waitdone(FAR struct efm32_i2c_priv_s *priv)
* that it is done.
*/
efm32_i2c_isr(priv);
efm32_i2c_isr_process(priv);
/* Calculate the elapsed time */
@ -869,14 +861,14 @@ static void efm32_i2c_setclock(FAR struct efm32_i2c_priv_s *priv,
}
/****************************************************************************
* Name: efm32_i2c_isr
* Name: efm32_i2c_isr_process
*
* Description:
* Common Interrupt Service Routine
*
****************************************************************************/
static int efm32_i2c_isr(struct efm32_i2c_priv_s *priv)
static int efm32_i2c_isr_process(struct efm32_i2c_priv_s *priv)
{
for (; ; )
{
@ -1279,44 +1271,24 @@ done:
return OK;
}
/****************************************************************************
* Name: efm32_i2c_isr
*
* Description:
* Common I2C interrupt service routine
*
****************************************************************************/
#ifndef CONFIG_I2C_POLLED
/****************************************************************************
* Name: efm32_i2c0_isr
*
* Description:
* I2C0 interrupt service routine
*
****************************************************************************/
#ifdef CONFIG_EFM32_I2C0
static int efm32_i2c0_isr(int irq, void *context, FAR void *arg)
static int efm32_i2c_isr(int irq, void *context, FAR void *arg)
{
return efm32_i2c_isr(&efm32_i2c0_priv);
struct efm32_i2c_priv_s *priv = (struct efm32_i2c_priv_s *)arg;
DEBUGASSERT(priv != NULL);
return efm32_i2c_isr_process(priv);
}
#endif
/****************************************************************************
* Name: efm32_i2c1_isr
*
* Description:
* I2C1 interrupt service routine
*
****************************************************************************/
#ifdef CONFIG_EFM32_I2C1
static int efm32_i2c1_isr(int irq, void *context, FAR void *arg)
{
return efm32_i2c_isr(&efm32_i2c1_priv);
}
#endif
#endif
/****************************************************************************
* Private Initialization and Deinitialization
****************************************************************************/
/****************************************************************************
* Name: efm32_i2c_hwreset
*
@ -1389,7 +1361,7 @@ static int efm32_i2c_init(FAR struct efm32_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
irq_attach(priv->config->irq, priv->config->isr, NULL);
irq_attach(priv->config->irq, efm32_i2c_isr, priv);
up_enable_irq(priv->config->irq);
#endif
@ -1523,7 +1495,7 @@ static int efm32_i2c_transfer(FAR struct i2c_master_s *dev,
* be enabled in efm32_i2c_sem_waitdone if CONFIG_I2C_POLLED is NOT defined
*/
efm32_i2c_isr(priv);
efm32_i2c_isr_process(priv);
/* Wait for an ISR, if there was a timeout, fetch latest status to get the
* BUSY flag.

View File

@ -230,7 +230,6 @@ struct stm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@ -313,18 +312,10 @@ static inline uint32_t stm32_i2c_disablefsmc(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_enablefsmc(uint32_t ahbenr);
#endif /* I2C1_FSMC_CONFLICT */
static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
static int stm32_i2c_isr_process(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
static int stm32_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C2
static int stm32_i2c2_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C3
static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
#endif
static int stm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif /* !CONFIG_I2C_POLLED */
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
@ -379,7 +370,6 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
.scl_pin = GPIO_I2C1_SCL,
.sda_pin = GPIO_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c1_isr,
.ev_irq = STM32_IRQ_I2C1EV,
.er_irq = STM32_IRQ_I2C1ER
#endif
@ -409,7 +399,6 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
.scl_pin = GPIO_I2C2_SCL,
.sda_pin = GPIO_I2C2_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c2_isr,
.ev_irq = STM32_IRQ_I2C2EV,
.er_irq = STM32_IRQ_I2C2ER
#endif
@ -439,7 +428,6 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
.scl_pin = GPIO_I2C3_SCL,
.sda_pin = GPIO_I2C3_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c3_isr,
.ev_irq = STM32_IRQ_I2C3EV,
.er_irq = STM32_IRQ_I2C3ER
#endif
@ -678,7 +666,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
* reports that it is done.
*/
stm32_i2c_isr(priv);
stm32_i2c_isr_process(priv);
}
/* Loop until the transfer is complete. */
@ -1172,14 +1160,14 @@ static inline void stm32_i2c_enablefsmc(uint32_t ahbenr)
#endif /* I2C1_FSMC_CONFLICT */
/************************************************************************************
* Name: stm32_i2c_isr
* Name: stm32_i2c_isr_process
*
* Description:
* Common Interrupt Service Routine
*
************************************************************************************/
static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv)
{
uint32_t status = stm32_i2c_getstatus(priv);
@ -1459,56 +1447,23 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
* Name: stm32_i2c1_isr
* Name: stm32_i2c_isr
*
* Description:
* I2C1 interrupt service routine
* Common I2C interrupt service routine
*
************************************************************************************/
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c1_priv);
}
#endif
/************************************************************************************
* Name: stm32_i2c2_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
#ifdef CONFIG_STM32_I2C2
#ifdef CONFIG_I2C_POLLED
static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c2_priv);
struct stm32_i2c_priv_s *priv = (struct stm32_i2c_priv_s *)arg;
DEBUGASSERT(priv != NULL);
return stm32_i2c_isr_process(priv);
}
#endif
/************************************************************************************
* Name: stm32_i2c3_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
#ifdef CONFIG_STM32_I2C3
static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c3_priv);
}
#endif
#endif
/************************************************************************************
* Private Initialization and Deinitialization
************************************************************************************/
/************************************************************************************
* Name: stm32_i2c_init
*
@ -1543,8 +1498,8 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
irq_attach(priv->config->er_irq, priv->config->isr, NULL);
irq_attach(priv->config->ev_irq, stm32_i2c_isr, priv);
irq_attach(priv->config->er_irq, stm32_i2c_isr, priv);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif

View File

@ -257,7 +257,6 @@ struct stm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@ -342,18 +341,10 @@ static inline uint32_t stm32_i2c_disablefsmc(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_enablefsmc(uint32_t ahbenr);
#endif /* I2C1_FSMC_CONFLICT */
static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
static int stm32_i2c_isr_process(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
static int stm32_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C2
static int stm32_i2c2_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C3
static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
#endif
static int stm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif /* !CONFIG_I2C_POLLED */
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
@ -387,7 +378,6 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
.scl_pin = GPIO_I2C1_SCL,
.sda_pin = GPIO_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c1_isr,
.ev_irq = STM32_IRQ_I2C1EV,
.er_irq = STM32_IRQ_I2C1ER
#endif
@ -417,7 +407,6 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
.scl_pin = GPIO_I2C2_SCL,
.sda_pin = GPIO_I2C2_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c2_isr,
.ev_irq = STM32_IRQ_I2C2EV,
.er_irq = STM32_IRQ_I2C2ER
#endif
@ -447,7 +436,6 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
.scl_pin = GPIO_I2C3_SCL,
.sda_pin = GPIO_I2C3_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c3_isr,
.ev_irq = STM32_IRQ_I2C3EV,
.er_irq = STM32_IRQ_I2C3ER
#endif
@ -686,7 +674,7 @@ static int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
* reports that it is done.
*/
stm32_i2c_isr(priv);
stm32_i2c_isr_process(priv);
}
/* Loop until the transfer is complete. */
@ -1180,7 +1168,7 @@ static inline void stm32_i2c_enablefsmc(uint32_t ahbenr)
#endif /* I2C1_FSMC_CONFLICT */
/************************************************************************************
* Name: stm32_i2c_isr
* Name: stm32_i2c_isr_process
*
* Description:
* Common interrupt service routine (ISR) that handles I2C protocol logic.
@ -1202,7 +1190,7 @@ static inline void stm32_i2c_enablefsmc(uint32_t ahbenr)
*
************************************************************************************/
static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv)
{
#ifndef CONFIG_I2C_POLLED
uint32_t regval;
@ -1892,56 +1880,23 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
* Name: stm32_i2c1_isr
* Name: stm32_i2c_isr
*
* Description:
* I2C1 interrupt service routine
* Common I2C interrupt service routine
*
************************************************************************************/
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
static int stm32_i2c_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c1_priv);
struct stm32_i2c_priv_s *priv = (struct stm32_i2c_priv_s )arg;
DEBUGASSERT(priv != NULL);
return stm32_i2c_isr_process(priv);
}
#endif
/************************************************************************************
* Name: stm32_i2c2_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
#ifdef CONFIG_STM32_I2C2
static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c2_priv);
}
#endif
/************************************************************************************
* Name: stm32_i2c3_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
#ifdef CONFIG_STM32_I2C3
static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c3_priv);
}
#endif
#endif
/************************************************************************************
* Private Initialization and Deinitialization
************************************************************************************/
/************************************************************************************
* Name: stm32_i2c_init
*
@ -1976,8 +1931,8 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
irq_attach(priv->config->er_irq, priv->config->isr, NULL);
irq_attach(priv->config->ev_irq, stm32_i2c_isr, priv);
irq_attach(priv->config->er_irq, stm32_i2c_isr, priv);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif

View File

@ -222,7 +222,6 @@ struct stm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@ -301,17 +300,9 @@ static inline void stm32_i2c_sendstart(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_clrstart(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_sendstop(FAR struct stm32_i2c_priv_s *priv);
static inline uint32_t stm32_i2c_getstatus(FAR struct stm32_i2c_priv_s *priv);
static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
static int stm32_i2c_isr_process(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
static int stm32_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C2
static int stm32_i2c2_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C3
static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
#endif
static int stm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
static int stm32_i2c_deinit(FAR struct stm32_i2c_priv_s *priv);
@ -344,7 +335,6 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
.scl_pin = GPIO_I2C1_SCL,
.sda_pin = GPIO_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c1_isr,
.ev_irq = STM32_IRQ_I2C1EV,
.er_irq = STM32_IRQ_I2C1ER
#endif
@ -374,7 +364,6 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
.scl_pin = GPIO_I2C2_SCL,
.sda_pin = GPIO_I2C2_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c2_isr,
.ev_irq = STM32_IRQ_I2C2EV,
.er_irq = STM32_IRQ_I2C2ER
#endif
@ -404,7 +393,6 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
.scl_pin = GPIO_I2C3_SCL,
.sda_pin = GPIO_I2C3_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c3_isr,
.ev_irq = STM32_IRQ_I2C3EV,
.er_irq = STM32_IRQ_I2C3ER
#endif
@ -712,7 +700,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
* reports that it is done.
*/
stm32_i2c_isr(priv);
stm32_i2c_isr_process(priv);
}
/* Loop until the transfer is complete. */
@ -1243,7 +1231,7 @@ static inline uint32_t stm32_i2c_getstatus(FAR struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
* Name: stm32_i2c_isr
* Name: stm32_i2c_isr_startmessage
*
* Description:
* Common logic when a message is started. Just adds the even to the trace buffer
@ -1276,14 +1264,14 @@ static inline void stm32_i2c_clearinterrupts(struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
* Name: stm32_i2c_isr
* Name: stm32_i2c_isr_process
*
* Description:
* Common Interrupt Service Routine
*
************************************************************************************/
static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv)
{
uint32_t status = stm32_i2c_getstatus(priv);
@ -1485,56 +1473,23 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
* Name: stm32_i2c1_isr
* Name: stm32_i2c_isr
*
* Description:
* I2C1 interrupt service routine
* Common I2C interrupt service routine
*
************************************************************************************/
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
static int stm32_i2c_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c1_priv);
struct stm32_i2c_priv_s *priv = (struct stm32_i2c_priv_s *)arg;
DEBUGASSERT(priv != NULL);
return stm32_i2c_isr_process(priv);
}
#endif
/************************************************************************************
* Name: stm32_i2c2_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
#ifdef CONFIG_STM32_I2C2
static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c2_priv);
}
#endif
/************************************************************************************
* Name: stm32_i2c3_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
#ifdef CONFIG_STM32_I2C3
static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c3_priv);
}
#endif
#endif
/************************************************************************************
* Private Initialization and Deinitialization
************************************************************************************/
/************************************************************************************
* Name: stm32_i2c_init
*
@ -1569,8 +1524,8 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
irq_attach(priv->config->er_irq, priv->config->isr, NULL);
irq_attach(priv->config->ev_irq, stm32_i2c_isr, priv);
irq_attach(priv->config->er_irq, stm32_i2c_isr, priv);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif

View File

@ -245,7 +245,6 @@ struct stm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@ -339,18 +338,10 @@ static inline uint32_t stm32_i2c_disablefsmc(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_enablefsmc(uint32_t ahbenr);
#endif /* I2C1_FSMC_CONFLICT */
static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv);
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
static int stm32_i2c1_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C2
static int stm32_i2c2_isr(int irq, void *context, FAR void *arg);
#endif
#ifdef CONFIG_STM32_I2C3
static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
#endif
static int stm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif /* !CONFIG_I2C_POLLED */
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
@ -364,8 +355,8 @@ static int stm32_i2c_reset(FAR struct i2c_master_s *dev);
/* DMA support */
#ifdef CONFIG_STM32_I2C_DMA
static void stm32_i2c_dmarxcallback(DMA_HANDLE handle, uint8_t isr, void *arg);
static void stm32_i2c_dmatxcallback(DMA_HANDLE handle, uint8_t isr, void *arg);
static void stm32_i2c_dmarxcallback(DMA_HANDLE handle, uint8_t status, void *arg);
static void stm32_i2c_dmatxcallback(DMA_HANDLE handle, uint8_t status, void *arg);
#endif
/************************************************************************************
@ -412,7 +403,6 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
.scl_pin = GPIO_I2C1_SCL,
.sda_pin = GPIO_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c1_isr,
.ev_irq = STM32_IRQ_I2C1EV,
.er_irq = STM32_IRQ_I2C1ER
#endif
@ -451,7 +441,6 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
.scl_pin = GPIO_I2C2_SCL,
.sda_pin = GPIO_I2C2_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c2_isr,
.ev_irq = STM32_IRQ_I2C2EV,
.er_irq = STM32_IRQ_I2C2ER
#endif
@ -488,7 +477,6 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
.scl_pin = GPIO_I2C3_SCL,
.sda_pin = GPIO_I2C3_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c3_isr,
.ev_irq = STM32_IRQ_I2C3EV,
.er_irq = STM32_IRQ_I2C3ER
#endif
@ -734,7 +722,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
* reports that it is done.
*/
stm32_i2c_isr(priv);
stm32_i2c_isr_process(priv);
}
/* Loop until the transfer is complete. */
@ -1229,14 +1217,14 @@ static inline void stm32_i2c_enablefsmc(uint32_t ahbenr)
#endif /* I2C1_FSMC_CONFLICT */
/************************************************************************************
* Name: stm32_i2c_isr
* Name: stm32_i2c_isr_process
*
* Description:
* Common Interrupt Service Routine
*
************************************************************************************/
static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv)
{
uint32_t status;
#ifndef CONFIG_I2C_POLLED
@ -2069,6 +2057,24 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
return OK;
}
/************************************************************************************
* Name: stm32_i2c_isr
*
* Description:
* Common I2C interrupt service routine
*
************************************************************************************/
#ifndef CONFIG_I2C_POLLED
static int stm32_i2c_isr(int irq, void *context, FAR void *arg)
{
struct stm32_i2c_priv_s *priv = (struct stm32_i2c_priv_s *)arg;
DEBUGASSERT(priv != NULL);
return stm32_i2c_isr_process(priv);
}
#endif
/*****************************************************************************
* Name: stm32_i2c_dmarxcallback
*
@ -2119,7 +2125,7 @@ static void stm32_i2c_dmarxcallback(DMA_HANDLE handle, uint8_t status, void *arg
/* let the ISR routine take care of shutting down or switching to next msg */
stm32_i2c_isr(priv);
stm32_i2c_isr_process(priv);
}
#endif /* ifdef CONFIG_STM32_I2C_DMA */
@ -2158,57 +2164,6 @@ static void stm32_i2c_dmatxcallback(DMA_HANDLE handle, uint8_t status, void *arg
}
#endif /* ifdef CONFIG_STM32_I2C_DMA */
/************************************************************************************
* Name: stm32_i2c1_isr
*
* Description:
* I2C1 interrupt service routine
*
************************************************************************************/
#ifndef CONFIG_I2C_POLLED
#ifdef CONFIG_STM32_I2C1
static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c1_priv);
}
#endif
/************************************************************************************
* Name: stm32_i2c2_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
#ifdef CONFIG_STM32_I2C2
static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c2_priv);
}
#endif
/************************************************************************************
* Name: stm32_i2c3_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
#ifdef CONFIG_STM32_I2C3
static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c3_priv);
}
#endif
#endif /* CONFIG_I2C_POLLED */
/************************************************************************************
* Private Initialization and Deinitialization
************************************************************************************/
/************************************************************************************
* Name: stm32_i2c_init
*
@ -2243,8 +2198,8 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
/* Attach ISRs */
#ifndef CONFIG_I2C_POLLED
irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
irq_attach(priv->config->er_irq, priv->config->isr, NULL);
irq_attach(priv->config->ev_irq, stm32_i2c_isr, priv);
irq_attach(priv->config->er_irq, stm32_i2c_isr, priv);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif

View File

@ -402,7 +402,6 @@ struct stm32_i2c_config_s
uint32_t scl_pin; /* GPIO configuration for SCL as SCL */
uint32_t sda_pin; /* GPIO configuration for SDA as SDA */
#ifndef CONFIG_I2C_POLLED
int (*isr)(int, void *, void *); /* Interrupt handler */
uint32_t ev_irq; /* Event IRQ */
uint32_t er_irq; /* Error IRQ */
#endif
@ -484,20 +483,9 @@ static void stm32_i2c_setclock(FAR struct stm32_i2c_priv_s *priv,
static inline void stm32_i2c_sendstart(FAR struct stm32_i2c_priv_s *priv);
static inline void stm32_i2c_sendstop(FAR struct stm32_i2c_priv_s *priv);
static inline uint32_t stm32_i2c_getstatus(FAR struct stm32_i2c_priv_s *priv);
static int stm32_i2c_isr(struct stm32_i2c_priv_s * priv);
static int stm32_i2c_isr_process(struct stm32_i2c_priv_s * priv);
#ifndef CONFIG_I2C_POLLED
# ifdef CONFIG_STM32F7_I2C1
static int stm32_i2c1_isr(int irq, void *context, FAR void *arg);
# endif
# ifdef CONFIG_STM32F7_I2C2
static int stm32_i2c2_isr(int irq, void *context, FAR void *arg);
# endif
# ifdef CONFIG_STM32F7_I2C3
static int stm32_i2c3_isr(int irq, void *context, FAR void *arg);
# endif
# ifdef CONFIG_STM32F7_I2C4
static int stm32_i2c4_isr(int irq, void *context, FAR void *arg);
# endif
static int stm32_i2c_isr(int irq, void *context, FAR void *arg);
#endif
static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv);
static int stm32_i2c_deinit(FAR struct stm32_i2c_priv_s *priv);
@ -523,7 +511,6 @@ static const struct stm32_i2c_config_s stm32_i2c1_config =
.scl_pin = GPIO_I2C1_SCL,
.sda_pin = GPIO_I2C1_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c1_isr,
.ev_irq = STM32_IRQ_I2C1EV,
.er_irq = STM32_IRQ_I2C1ER
#endif
@ -553,7 +540,6 @@ static const struct stm32_i2c_config_s stm32_i2c2_config =
.scl_pin = GPIO_I2C2_SCL,
.sda_pin = GPIO_I2C2_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c2_isr,
.ev_irq = STM32_IRQ_I2C2EV,
.er_irq = STM32_IRQ_I2C2ER
#endif
@ -583,7 +569,6 @@ static const struct stm32_i2c_config_s stm32_i2c3_config =
.scl_pin = GPIO_I2C3_SCL,
.sda_pin = GPIO_I2C3_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c3_isr,
.ev_irq = STM32_IRQ_I2C3EV,
.er_irq = STM32_IRQ_I2C3ER
#endif
@ -613,7 +598,6 @@ static const struct stm32_i2c_config_s stm32_i2c4_config =
.scl_pin = GPIO_I2C4_SCL,
.sda_pin = GPIO_I2C4_SDA,
#ifndef CONFIG_I2C_POLLED
.isr = stm32_i2c4_isr,
.ev_irq = STM32_IRQ_I2C4EV,
.er_irq = STM32_IRQ_I2C4ER
#endif
@ -905,7 +889,7 @@ static inline int stm32_i2c_sem_waitdone(FAR struct stm32_i2c_priv_s *priv)
* reports that it is done.
*/
stm32_i2c_isr(priv);
stm32_i2c_isr_process(priv);
}
/* Loop until the transfer is complete. */
@ -1538,7 +1522,7 @@ static inline void stm32_i2c_clearinterrupts(struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
* Name: stm32_i2c_isr
* Name: stm32_i2c_isr_process
*
* Description:
* Common interrupt service routine (ISR) that handles I2C protocol logic.
@ -1555,7 +1539,7 @@ static inline void stm32_i2c_clearinterrupts(struct stm32_i2c_priv_s *priv)
*
************************************************************************************/
static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
static int stm32_i2c_isr_process(struct stm32_i2c_priv_s *priv)
{
uint32_t status;
@ -2144,71 +2128,23 @@ static int stm32_i2c_isr(struct stm32_i2c_priv_s *priv)
}
/************************************************************************************
* Name: stm32_i2c1_isr
* Name: stm32_i2c_isr
*
* Description:
* I2C1 interrupt service routine
* Common I2C interrupt service routine
*
************************************************************************************/
#ifndef CONFIG_I2C_POLLED
# ifdef CONFIG_STM32F7_I2C1
static int stm32_i2c1_isr(int irq, void *context, FAR void *arg)
static int stm32_i2c_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c1_priv);
struct stm32_i2c_priv_s *priv = (struct stm32_i2c_priv_s *)arg;
DEBUGASSERT(priv != NULL);
return stm32_i2c_isr_process(&stm32_i2c1_priv);
}
# endif
/************************************************************************************
* Name: stm32_i2c2_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
# ifdef CONFIG_STM32F7_I2C2
static int stm32_i2c2_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c2_priv);
}
# endif
/************************************************************************************
* Name: stm32_i2c3_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
# ifdef CONFIG_STM32F7_I2C3
static int stm32_i2c3_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c3_priv);
}
# endif
/************************************************************************************
* Name: stm32_i2c4_isr
*
* Description:
* I2C2 interrupt service routine
*
************************************************************************************/
# ifdef CONFIG_STM32F7_I2C4
static int stm32_i2c4_isr(int irq, void *context, FAR void *arg)
{
return stm32_i2c_isr(&stm32_i2c4_priv);
}
# endif
#endif
/************************************************************************************
* Private Initialization and Deinitialization
************************************************************************************/
/************************************************************************************
* Name: stm32_i2c_init
*
@ -2243,8 +2179,8 @@ static int stm32_i2c_init(FAR struct stm32_i2c_priv_s *priv)
#ifndef CONFIG_I2C_POLLED
/* Attach error and event interrupts to the ISRs */
irq_attach(priv->config->ev_irq, priv->config->isr, NULL);
irq_attach(priv->config->er_irq, priv->config->isr, NULL);
irq_attach(priv->config->ev_irq, stm32_i2c_isr, priv);
irq_attach(priv->config->er_irq, stm32_i2c_isr, priv);
up_enable_irq(priv->config->ev_irq);
up_enable_irq(priv->config->er_irq);
#endif