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
@ -78,7 +78,7 @@
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
|
@ -58,7 +58,7 @@
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
|
@ -340,7 +340,7 @@ void pic32mx_gpioirqinitialize(void);
|
||||
int pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler,
|
||||
void *arg);
|
||||
#else
|
||||
# define pic32mx_gpioattach(p,c,h,a) (NULL)
|
||||
# define pic32mx_gpioattach(p,c,h,a) (0)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
|
@ -199,22 +199,20 @@ void pic32mz_gpioirqinitialize(void);
|
||||
* case, all attached handlers will be called. Each handler must maintain state
|
||||
* and determine if the underlying GPIO input value changed.
|
||||
*
|
||||
* Parameters:
|
||||
* - pinset: GPIO pin configuration
|
||||
* - cn: The change notification number associated with the pin
|
||||
* - handler: Interrupt handler (may be NULL to detach)
|
||||
* pinset - GPIO pin configuration
|
||||
* handler - Interrupt handler (may be NULL to detach)
|
||||
* arg - The argument that accompanies the interrupt
|
||||
*
|
||||
* Returns:
|
||||
* The previous value of the interrupt handler function pointer. This value may,
|
||||
* for example, be used to restore the previous handler when multiple handlers are
|
||||
* used.
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated error value is returned on
|
||||
* any failure to indicate the nature of the failure.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#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
|
||||
# define pic32mz_gpioattach(p,f) (NULL)
|
||||
# define pic32mz_gpioattach(p,h,a) (0)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
|
@ -78,9 +78,15 @@ static int pic32mz_cninterrupt(int irq, FAR void *context, FAR void *arg);
|
||||
* 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
|
||||
{
|
||||
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? */
|
||||
|
||||
handler = handlers->handler[i];
|
||||
handler = handlers->handler[i].entry;
|
||||
if (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
|
||||
* failed.
|
||||
@ -365,22 +371,21 @@ void pic32mz_gpioirqinitialize(void)
|
||||
* In that case, all attached handlers will be called. Each handler must
|
||||
* maintain state and determine if the underlying GPIO input value changed.
|
||||
*
|
||||
* Parameters:
|
||||
* - pinset: GPIO pin configuration
|
||||
* - pin: The change notification number associated with the pin.
|
||||
* - handler: Interrupt handler (may be NULL to detach)
|
||||
* Input Parameters:
|
||||
* pinset - GPIO pin configuration
|
||||
* handler - Interrupt handler (may be NULL to detach)
|
||||
* arg - The argument that accompanies the interrupt
|
||||
*
|
||||
* Returns:
|
||||
* The previous value of the interrupt handler function pointer. This
|
||||
* value may, for example, be used to restore the previous handler when
|
||||
* multiple handlers are used.
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success. A negated error value is returned on
|
||||
* any failure to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
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;
|
||||
xcpt_t oldhandler = NULL;
|
||||
irqstate_t flags;
|
||||
uintptr_t base;
|
||||
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 */
|
||||
|
||||
flags = enter_critical_section();
|
||||
oldhandler = handlers->handler[pin];
|
||||
|
||||
/* 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) */
|
||||
|
||||
handlers->handler[pin] = handler;
|
||||
handlers->handler[pin].entry = handler;
|
||||
handlers->handler[pin].arg = arg;
|
||||
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)
|
||||
{
|
||||
#ifdef CONFIG_PIC32MZ_GPIOIRQ_PORTB
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = OK;
|
||||
|
||||
if ((unsigned)id < NUM_BUTTONS)
|
||||
{
|
||||
/* 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
|
||||
* button interrupt?
|
||||
*/
|
||||
|
||||
if (irqhandler)
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* 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
|
||||
return NULL;
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user