📄 hal_interrupt.c
字号:
/************************************************************************/
/* */
/* Copyright (C) 2006 Oki Electric Industry Co., LTD. */
/* */
/* System Name : uPLAT7D series */
/* Module Name : uPLAT7D intterupt HAL program */
/* File Name : hal_interrupt.c */
/* Date : 2005/12/21 initial version */
/* */
/************************************************************************/
#include "common.h"
#if defined(__arm)
#include "ml675050.h"
#else
#include "ml675050sim.h"
#endif
#include "hal_common.h"
#include "hal_interrupt.h"
#include "hal_ftm_art.h"
#include "hal_ftm_pwm.h"
#include "hal_ftm_cap.h"
/******************************/
/* Private defines */
/******************************/
/*--------- function ---------*/
static void null_vfv(void);
static void null_vfi(uint16_t);
static void _exint1_handler(void);
/*--------- variable ---------*/
static FP exint1_handler = _exint1_handler;
static VFI fiq_callback;
/******************************/
/* Public defines */
/******************************/
FP IRQ_HANDLER_TABLE[IRQSIZE];
VFI CALL_BACK_TABLE[IRQSIZE];
/************************************************************************/
/* */
/* Function Name : null_vfv */
/* Input : void */
/* Output : void */
/* */
/* Note : Get a pointer of function. */
/* */
/************************************************************************/
static void null_vfv(void)
{
}
/************************************************************************/
/* */
/* Function Name : null_vfi */
/* Input : i */
/* Output : void */
/* */
/* Note : Get a pointer of function. */
/* */
/************************************************************************/
static void null_vfi(uint16_t i)
{
}
/************************************************************************/
/* */
/* Function Name : HALInterrupt_InitAll */
/* Input : void */
/* Output : void */
/* */
/* Note : Initialize interrupt. */
/* */
/************************************************************************/
void HALInterrupt_InitAll(void) {
int16_t i;
OkiCLib_write32(FIQEN, 0x0); /* FIQ enable register. */
OkiCLib_write32(EXIDM, 0x0); /* Extended interrupt register. */
OkiCLib_write32(EXIRQSB, 0x0); /* Extended IRQ status register. */
OkiCLib_write32(EXFIQ, 0x0); /* Extended FIQ register. */
OkiCLib_write32(EXFIDM, 0x0); /* Extended FIQ mode register. */
OkiCLib_write32(EXIRCL, 0x0); /* Extended EXIRQ clear register. */
OkiCLib_write32(EXINTCNT, 0x0); /* Extended control register. */
OkiCLib_write32(CIL, 0x0); /* Current IRQ register. */
OkiCLib_write32(ILC0, 0x0); /* IRQ level register0. */
OkiCLib_write32(ILC1, 0x0); /* IRQ level register1. */
OkiCLib_write32(EXILCA, 0x0); /* Extended FIQ register. */
OkiCLib_write32(EXILCB, 0x0); /* Extended FIQ mode register. */
OkiCLib_write32(EXILCC, 0x0); /* Extended EXIRQ clear register. */
OkiCLib_write32(IRQS, 0x0); /* Extended EXIRQ clear register. */
for (i = 0; i < IRQSIZE; i++) {
IRQ_HANDLER_TABLE[i] = null_vfv;
CALL_BACK_TABLE[i] = null_vfi;
}
}
/************************************************************************/
/* */
/* Function Name : HALInterrupt_SetPrimary */
/* Input : param Interrupt parameter. */
/* Output : int16_t HAL_OK(1) */
/* HAL_PARAM_ERROR(-2) */
/* */
/* Note : Set interrupt. */
/* */
/************************************************************************/
int16_t HALInterrupt_SetPrimary(const uPLAT_InterruptParam *param) {
int16_t rtnVal = HAL_OK;
extern FP timer_handler;
extern FP wdt_handler;
extern FP adc_handler;
extern FP sio_handler;
extern FP lcdc_handler;
extern FP i2c0_handler;
extern FP i2c1_handler;
extern FP uart_handler;
extern FP spi0_handler;
extern FP art0_handler;
extern FP art1_handler;
extern FP art3_handler;
extern FP art4_handler;
extern FP art5_handler;
extern FP pwm1_handler;
extern FP cap0_handler;
extern FP dmacCH0_handler;
extern FP dmacCH1_handler;
extern FP dmacCH2_handler;
extern FP dmacCH3_handler;
#if USB_USED
#if (!USB_PERI_ACTIVE)
extern FP usbhost_handler;
#else
extern FP usbperi_handler;
extern FP exint6_handler;
#endif
#endif
switch (param->primary) {
case INT_FIQ:
fiq_callback = param->callback;
break;
case INT_SYSTIMER:
/* Set interrupt level. */
OkiCLib_set32bit(ILC0, param->level);
/* Register call back function. */
CALL_BACK_TABLE[INT_SYSTIMER] = param->callback;
/* Register handler function. */
IRQ_HANDLER_TABLE[INT_SYSTIMER] = timer_handler;
break;
case INT_WDT:
/* Set interrupt level. */
OkiCLib_set32bit(ILC0, param->level);
/* Register call back function. */
CALL_BACK_TABLE[INT_WDT] = param->callback;
/* Register handler function. */
IRQ_HANDLER_TABLE[INT_WDT] = wdt_handler;
break;
case INT_ADC:
/* Set interrupt level. */
OkiCLib_set32bit(ILC1, param->level);
/* Register call back function. */
CALL_BACK_TABLE[INT_ADC] = param->callback;
/* Register handler function. */
IRQ_HANDLER_TABLE[INT_ADC] = adc_handler;
break;
case INT_SIO:
/* Set interrupt level. */
OkiCLib_set32bit(ILC1, param->level);
/* Register call back function. */
CALL_BACK_TABLE[INT_SIO] = param->callback;
/* Register handler function. */
IRQ_HANDLER_TABLE[INT_SIO] = sio_handler;
break;
case INT_UART0:
/* Set interrupt level. */
OkiCLib_set32bit(EXILCC, param->level);
/* Register call back function. */
CALL_BACK_TABLE[INT_UART0] = param->callback;
/* Register handler function. */
IRQ_HANDLER_TABLE[INT_UART0] = uart_handler;
break;
case INT_EXINT1:
/* Set interrupt level. */
OkiCLib_set32bit(EXILCB, param->level);
/* Register call back function. */
CALL_BACK_TABLE[INT_EXINT1] = param->callback;
/* dummy write to init the edge detect circuit */
OkiCLib_set32bit(EXIRQB, EXIRQB_IRQ34);
/* Set Ext Interrupt0 to edge detect */
OkiCLib_set32bit(EXIDM, EXIDM_IDM34);
/* Register handler function. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -