Explorar o código

remain the old handler to keep forward compatibility

weety %!s(int64=12) %!d(string=hai) anos
pai
achega
7917cf09e7

+ 3 - 2
include/rthw.h

@@ -41,9 +41,10 @@ rt_uint8_t *rt_hw_stack_init(void       *entry,
 void rt_hw_interrupt_init(void);
 void rt_hw_interrupt_mask(int vector);
 void rt_hw_interrupt_umask(int vector);
-void rt_hw_interrupt_install(int               vector,
+rt_isr_handler_t rt_hw_interrupt_install(int vector,
                              rt_isr_handler_t  handler,
-                             void *param, char *name);
+                             void *param,
+                             char *name);
 void rt_hw_interrupt_handle(int vector);
 
 rt_base_t rt_hw_interrupt_disable(void);

+ 8 - 0
include/rtthread.h

@@ -427,6 +427,14 @@ void rt_module_unload_sethook(void (*hook)(rt_module_t module));
  */
 typedef void (*rt_isr_handler_t)(int vector, void *param);
 
+struct rt_irq_desc {
+	char irq_name[RT_NAME_MAX];
+	rt_isr_handler_t isr_handle;
+	void *param;
+	rt_uint32_t interrupt_cnt;
+};
+
+
 /*
  * rt_interrupt_enter and rt_interrupt_leave only can be called by BSP
  */

+ 14 - 6
libcpu/arm/at91sam926x/interrupt.c

@@ -14,7 +14,6 @@
 
 #include <rtthread.h>
 #include "at91sam926x.h"
-#include "interrupt.h"
 
 #define MAX_HANDLERS	(AIC_IRQS + PIN_IRQS)
 
@@ -308,17 +307,26 @@ void rt_hw_interrupt_umask(int irq)
  * @param handler the interrupt service routine to be installed
  * @param param the interrupt service function parameter
  * @param name the interrupt name
+ * @return old handler
  */
-void rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, 
+rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, 
 									void *param, char *name)
 {
+	rt_isr_handler_t old_handler = RT_NULL;
+
 	if(vector < MAX_HANDLERS)
 	{
-		rt_snprintf(irq_desc[vector].irq_name, RT_NAME_MAX - 1, "%s", name);
-		irq_desc[vector].isr_handle = (rt_isr_handler_t)handler;
-		irq_desc[vector].param = param;
-		irq_desc[vector].interrupt_cnt = 0;
+		old_handler = irq_desc[vector].isr_handle;
+		if (handler != RT_NULL)
+		{
+			rt_snprintf(irq_desc[vector].irq_name, RT_NAME_MAX - 1, "%s", name);
+			irq_desc[vector].isr_handle = (rt_isr_handler_t)handler;
+			irq_desc[vector].param = param;
+			irq_desc[vector].interrupt_cnt = 0;
+		}
 	}
+
+	return old_handler;
 }
 
 /*@}*/

+ 0 - 11
libcpu/arm/at91sam926x/interrupt.h

@@ -1,11 +0,0 @@
-#ifndef __INTERRUPT_H__
-#define __INTERRUPT_H__
-
-struct rt_irq_desc {
-	char irq_name[RT_NAME_MAX];
-	rt_isr_handler_t isr_handle;
-	void *param;
-	rt_uint32_t interrupt_cnt;
-};
-
-#endif

+ 0 - 1
libcpu/arm/at91sam926x/trap.c

@@ -16,7 +16,6 @@
 #include <rthw.h>
 
 #include "at91sam926x.h"
-#include "interrupt.h"
 
 /**
  * @addtogroup AT91SAM926X