ENC28J60: Update interface to use newer parameter passing to interrupt handlers
This commit is contained in:
parent
241c1433ef
commit
67befb9642
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* configs/fire-stm32v2/src/stm32_enc28j60.c
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -106,13 +106,15 @@ struct stm32_lower_s
|
||||
{
|
||||
const struct enc_lower_s lower; /* Low-level MCU interface */
|
||||
xcpt_t handler; /* ENC28J60 interrupt handler */
|
||||
FAR void *arg; /* Argument that accompanies the interrupt */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler);
|
||||
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler,
|
||||
FAR void *arg);
|
||||
static void up_enable(FAR const struct enc_lower_s *lower);
|
||||
static void up_disable(FAR const struct enc_lower_s *lower);
|
||||
|
||||
@ -134,6 +136,7 @@ static struct stm32_lower_s g_enclower =
|
||||
.disable = up_disable
|
||||
},
|
||||
.handler = NULL,
|
||||
.arg = NULL
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -144,13 +147,15 @@ static struct stm32_lower_s g_enclower =
|
||||
* Name: struct enc_lower_s methods
|
||||
****************************************************************************/
|
||||
|
||||
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler)
|
||||
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler,
|
||||
FAR void *arg)
|
||||
{
|
||||
FAR struct stm32_lower_s *priv = (FAR struct stm32_lower_s *)lower;
|
||||
|
||||
/* Just save the handler for use when the interrupt is enabled */
|
||||
|
||||
priv->handler = handler;
|
||||
priv->arg = arg;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -160,9 +165,14 @@ static void up_enable(FAR const struct enc_lower_s *lower)
|
||||
|
||||
DEBUGASSERT(priv->handler);
|
||||
(void)stm32_gpiosetevent(GPIO_ENC28J60_INTR, false, true, true,
|
||||
priv->handler, NULL);
|
||||
priv->handler, priv->arg);
|
||||
}
|
||||
|
||||
/* REVISIT: Since the interrupt is completely torn down, not just disabled,
|
||||
* in interrupt requests that occurs while the interrupt is disabled will be
|
||||
* lost.
|
||||
*/
|
||||
|
||||
static void up_disable(FAR const struct enc_lower_s *lower)
|
||||
{
|
||||
(void)stm32_gpiosetevent(GPIO_ENC28J60_INTR, false, true, true,
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* configs/olimex-strp711/src/str71_enc28j60.c
|
||||
*
|
||||
* Copyright (C) 2010, 2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2010, 2012, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -154,7 +154,8 @@
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler);
|
||||
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler,
|
||||
FAR void *arg);
|
||||
static void up_enable(FAR const struct enc_lower_s *lower);
|
||||
static void up_disable(FAR const struct enc_lower_s *lower);
|
||||
|
||||
@ -182,9 +183,10 @@ static const struct enc_lower_s g_enclower =
|
||||
* Name: struct enc_lower_s methods
|
||||
****************************************************************************/
|
||||
|
||||
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler)
|
||||
static int up_attach(FAR const struct enc_lower_s *lower, xcpt_t handler,
|
||||
FAR void *arg)
|
||||
{
|
||||
return irq_attach(ENC28J60_IRQ, handler, NULL);
|
||||
return irq_attach(ENC28J60_IRQ, handler, arg);
|
||||
}
|
||||
|
||||
static void up_enable(FAR const struct enc_lower_s *lower)
|
||||
|
@ -1833,7 +1833,10 @@ static void enc_irqworker(FAR void *arg)
|
||||
|
||||
static int enc_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
register FAR struct enc_driver_s *priv = &g_enc28j60[0];
|
||||
FAR struct enc_driver_s *priv;
|
||||
|
||||
DEBUGASSERT(arg != NULL);
|
||||
priv = (FAR struct enc_driver_s *)arg;
|
||||
|
||||
/* In complex environments, we cannot do SPI transfers from the interrupt
|
||||
* handler because semaphores are probably used to lock the SPI bus. In
|
||||
@ -2648,7 +2651,7 @@ int enc_initialize(FAR struct spi_dev_s *spi,
|
||||
|
||||
/* Attach the interrupt to the driver (but don't enable it yet) */
|
||||
|
||||
if (lower->attach(lower, enc_interrupt))
|
||||
if (lower->attach(lower, enc_interrupt, priv) < 0)
|
||||
{
|
||||
/* We could not attach the ISR to the interrupt */
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/net/encx24j600.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013-2014 UVC Ingenieure. All rights reserved.
|
||||
* Author: Max Holtzberg <mh@uvc.de>
|
||||
*
|
||||
@ -1976,7 +1977,7 @@ static void enc_irqworker(FAR void *arg)
|
||||
|
||||
static int enc_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||
{
|
||||
FAR struct enc_driver_s *priv = &g_encx24j600[0];
|
||||
FAR struct enc_driver_s *priv;
|
||||
|
||||
DEBUGASSERT(arg != NULL);
|
||||
priv = (FAR struct enc_driver_s *)arg;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/net/enc28j60.h
|
||||
*
|
||||
* Copyright (C) 2010, 2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2010, 2012, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -86,7 +86,8 @@
|
||||
|
||||
struct enc_lower_s
|
||||
{
|
||||
int (*attach)(FAR const struct enc_lower_s *lower, xcpt_t handler);
|
||||
int (*attach)(FAR const struct enc_lower_s *lower, xcpt_t handler,
|
||||
FAR void *arg);
|
||||
void (*enable)(FAR const struct enc_lower_s *lower);
|
||||
void (*disable)(FAR const struct enc_lower_s *lower);
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/net/encx24j600.h
|
||||
*
|
||||
* Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
Loading…
x
Reference in New Issue
Block a user