refactored
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "MCF5475.h"
|
||||
#include "bas_utils.h"
|
||||
#include "bas_printf.h"
|
||||
#include "bas_string.h"
|
||||
#include "exceptions.h"
|
||||
#include "interrupts.h"
|
||||
#include "bas_printf.h"
|
||||
@@ -96,33 +97,24 @@ int register_interrupt_handler(uint8_t source, uint8_t level, uint8_t priority,
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct
|
||||
struct isrentry
|
||||
{
|
||||
int vector;
|
||||
int (*handler)(void *, void *);
|
||||
void *hdev;
|
||||
void *harg;
|
||||
} ISRENTRY;
|
||||
|
||||
ISRENTRY isrtab[MAX_ISR_ENTRY];
|
||||
};
|
||||
|
||||
static struct isrentry isrtab[MAX_ISR_ENTRY]; /* list of interrupt service routines */
|
||||
|
||||
/*
|
||||
* clear the table of interrupt service handlers
|
||||
*/
|
||||
void isr_init(void)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 0; index < MAX_ISR_ENTRY; index++)
|
||||
{
|
||||
isrtab[index].vector = 0;
|
||||
isrtab[index].handler = 0;
|
||||
isrtab[index].hdev = 0;
|
||||
isrtab[index].harg = 0;
|
||||
}
|
||||
memset(isrtab, 0, sizeof(isrtab));
|
||||
}
|
||||
|
||||
|
||||
int isr_register_handler(int vector, int (*handler)(void *, void *), void *hdev, void *harg)
|
||||
{
|
||||
/*
|
||||
* This function places an interrupt handler in the ISR table,
|
||||
* thereby registering it so that the low-level handler may call it.
|
||||
@@ -131,6 +123,8 @@ int isr_register_handler(int vector, int (*handler)(void *, void *), void *hdev,
|
||||
* pointer to the device itself, and the second a pointer to a data
|
||||
* structure used by the device driver for that particular device.
|
||||
*/
|
||||
int isr_register_handler(int vector, int (*handler)(void *, void *), void *hdev, void *harg)
|
||||
{
|
||||
int index;
|
||||
|
||||
if ((vector == 0) || (handler == NULL))
|
||||
@@ -175,10 +169,7 @@ void isr_remove_handler(int (*handler)(void *, void *))
|
||||
{
|
||||
if (isrtab[index].handler == handler)
|
||||
{
|
||||
isrtab[index].vector = 0;
|
||||
isrtab[index].handler = 0;
|
||||
isrtab[index].hdev = 0;
|
||||
isrtab[index].harg = 0;
|
||||
memset(&isrtab[index], 0, sizeof(struct isrentry));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -186,13 +177,12 @@ void isr_remove_handler(int (*handler)(void *, void *))
|
||||
dbg("no such handler registered (handler=%p\r\n", handler);
|
||||
}
|
||||
|
||||
|
||||
bool isr_execute_handler(int vector)
|
||||
{
|
||||
/*
|
||||
* This routine searches the ISR table for an entry that matches
|
||||
* 'vector'. If one is found, then 'handler' is executed.
|
||||
*/
|
||||
bool isr_execute_handler(int vector)
|
||||
{
|
||||
int index;
|
||||
bool retval = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user