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