PIC32MZ: Pin IRQ logic no longer returns the xcpt_t oldhandler. There value is useless and dangerous after the recent changes to interrupt argument passing.
This commit is contained in:
parent
1564b384e1
commit
32383556fd
@ -68,7 +68,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_KL_PORTBINTS) || defined(CONFIG_KL_PORTCINTS) || \
|
#if defined(CONFIG_KL_PORTBINTS) || defined(CONFIG_KL_PORTCINTS) || \
|
||||||
defined(CONFIG_KL_PORTEINTS)
|
defined(CONFIG_KL_PORTEINTS)
|
||||||
# error Kinetis KL25 only supports interrupt on PORTA or PORTD
|
# error Kinetis KL25 only supports interrupt on PORTA or PORTD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
struct g_portisrs_s
|
struct g_portisrs_s
|
||||||
{
|
{
|
||||||
xcpt_t handler; /* Entery hander entry point */
|
xcpt_t handler; /* Interrupt handler entry point */
|
||||||
void *arg; /* The argument that accompanies the interrupt handler */
|
void *arg; /* The argument that accompanies the interrupt handler */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
struct g_cnisrs_s
|
struct g_cnisrs_s
|
||||||
{
|
{
|
||||||
xcpt_t handler; /* Entery hander entry point */
|
xcpt_t handler; /* Interrupt handler entry point */
|
||||||
void *arg; /* The argument that accompanies the interrupt handler */
|
void *arg; /* The argument that accompanies the interrupt handler */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ void pic32mx_gpioirqinitialize(void);
|
|||||||
int pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler,
|
int pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler,
|
||||||
void *arg);
|
void *arg);
|
||||||
#else
|
#else
|
||||||
# define pic32mx_gpioattach(p,c,h,a) (NULL)
|
# define pic32mx_gpioattach(p,c,h,a) (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
|
@ -199,22 +199,20 @@ void pic32mz_gpioirqinitialize(void);
|
|||||||
* case, all attached handlers will be called. Each handler must maintain state
|
* case, all attached handlers will be called. Each handler must maintain state
|
||||||
* and determine if the underlying GPIO input value changed.
|
* and determine if the underlying GPIO input value changed.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* pinset - GPIO pin configuration
|
||||||
* - pinset: GPIO pin configuration
|
* handler - Interrupt handler (may be NULL to detach)
|
||||||
* - cn: The change notification number associated with the pin
|
* arg - The argument that accompanies the interrupt
|
||||||
* - handler: Interrupt handler (may be NULL to detach)
|
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This value may,
|
* Zero (OK) is returned on success. A negated error value is returned on
|
||||||
* for example, be used to restore the previous handler when multiple handlers are
|
* any failure to indicate the nature of the failure.
|
||||||
* used.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PIC32MZ_GPIOIRQ
|
#ifdef CONFIG_PIC32MZ_GPIOIRQ
|
||||||
xcpt_t pic32mz_gpioattach(pinset_t pinset, xcpt_t handler);
|
int pic32mz_gpioattach(uint32_t pinset, xcpt_t handler, void *arg);
|
||||||
#else
|
#else
|
||||||
# define pic32mz_gpioattach(p,f) (NULL)
|
# define pic32mz_gpioattach(p,h,a) (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
|
@ -78,9 +78,15 @@ static int pic32mz_cninterrupt(int irq, FAR void *context, FAR void *arg);
|
|||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct ioport_handler_s
|
||||||
|
{
|
||||||
|
xcpt_t entry; /* Interrupt handler entry point */
|
||||||
|
void *arg; /* The argument that accompanies the interrupt handler */
|
||||||
|
};
|
||||||
|
|
||||||
struct ioport_level2_s
|
struct ioport_level2_s
|
||||||
{
|
{
|
||||||
xcpt_t handler[16];
|
struct ioport_handler_s handler[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -260,12 +266,12 @@ static int pic32mz_cninterrupt(int irq, FAR void *context, FAR void *arg)
|
|||||||
{
|
{
|
||||||
/* Yes.. Has the user attached a handler? */
|
/* Yes.. Has the user attached a handler? */
|
||||||
|
|
||||||
handler = handlers->handler[i];
|
handler = handlers->handler[i].entry;
|
||||||
if (handler)
|
if (handler)
|
||||||
{
|
{
|
||||||
/* Yes.. call the attached handler */
|
/* Yes.. call the attached handler */
|
||||||
|
|
||||||
status = handler(irq, context);
|
status = handler(irq, context, handlers->handler[i].arg);
|
||||||
|
|
||||||
/* Keep track of the status of the last handler that
|
/* Keep track of the status of the last handler that
|
||||||
* failed.
|
* failed.
|
||||||
@ -365,22 +371,21 @@ void pic32mz_gpioirqinitialize(void)
|
|||||||
* In that case, all attached handlers will be called. Each handler must
|
* In that case, all attached handlers will be called. Each handler must
|
||||||
* maintain state and determine if the underlying GPIO input value changed.
|
* maintain state and determine if the underlying GPIO input value changed.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: GPIO pin configuration
|
* pinset - GPIO pin configuration
|
||||||
* - pin: The change notification number associated with the pin.
|
* handler - Interrupt handler (may be NULL to detach)
|
||||||
* - handler: Interrupt handler (may be NULL to detach)
|
* arg - The argument that accompanies the interrupt
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) is returned on success. A negated error value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* any failure to indicate the nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t pic32mz_gpioattach(pinset_t pinset, xcpt_t handler)
|
#ifdef CONFIG_PIC32MZ_GPIOIRQ
|
||||||
|
int pic32mz_gpioattach(uint32_t pinset, xcpt_t handler, void *arg)
|
||||||
{
|
{
|
||||||
struct ioport_level2_s *handlers;
|
struct ioport_level2_s *handlers;
|
||||||
xcpt_t oldhandler = NULL;
|
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
uintptr_t base;
|
uintptr_t base;
|
||||||
int ioport;
|
int ioport;
|
||||||
@ -415,7 +420,6 @@ xcpt_t pic32mz_gpioattach(pinset_t pinset, xcpt_t handler)
|
|||||||
/* Get the previously attached handler as the return value */
|
/* Get the previously attached handler as the return value */
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
oldhandler = handlers->handler[pin];
|
|
||||||
|
|
||||||
/* Are we attaching or detaching? */
|
/* Are we attaching or detaching? */
|
||||||
|
|
||||||
@ -467,12 +471,13 @@ xcpt_t pic32mz_gpioattach(pinset_t pinset, xcpt_t handler)
|
|||||||
|
|
||||||
/* Set the new handler (perhaps NULLifying the current handler) */
|
/* Set the new handler (perhaps NULLifying the current handler) */
|
||||||
|
|
||||||
handlers->handler[pin] = handler;
|
handlers->handler[pin].entry = handler;
|
||||||
|
handlers->handler[pin].arg = arg;
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -155,19 +155,19 @@ uint8_t board_buttons(void)
|
|||||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_PIC32MZ_GPIOIRQ_PORTB
|
#ifdef CONFIG_PIC32MZ_GPIOIRQ_PORTB
|
||||||
xcpt_t oldhandler = NULL;
|
int ret = OK;
|
||||||
|
|
||||||
if ((unsigned)id < NUM_BUTTONS)
|
if ((unsigned)id < NUM_BUTTONS)
|
||||||
{
|
{
|
||||||
/* Perform the attach/detach operation */
|
/* Perform the attach/detach operation */
|
||||||
|
|
||||||
oldhandler = pic32mz_gpioattach(g_buttons[id], irqhandler);
|
ret = pic32mz_gpioattach(g_buttons[id], irqhandler, arg);
|
||||||
|
|
||||||
/* The interrupt is now disabled. Are we attaching or detaching from
|
/* The interrupt is now disabled. Are we attaching or detaching from
|
||||||
* button interrupt?
|
* button interrupt?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (irqhandler)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
/* Attaching... enable button interrupts now */
|
/* Attaching... enable button interrupts now */
|
||||||
|
|
||||||
@ -175,9 +175,9 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldhandler;
|
return ret;
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return -ENOSYS;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user