⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interrupts.c

📁 SHARP_ARM720T_LH79524/5软件开发包_支持TFT_LCD_NAND_FLASH_ETH_USB
💻 C
字号:
/***********************************************************************
 * $Workfile:   interrupts.c  $
 * $Revision:   1.1  $
 * $Author:   TilburyC  $
 * $Date:   Oct 14 2004 17:52:36  $
 *
 * Project: LH79524 EEPROM test
 *
 * Description: This file contains the basic eeprom tests
 *
 * Local Includes:
 *
 * Revision History:
 * $Log::   $
 * 
 *    Rev 1.1   Oct 14 2004 17:52:36   TilburyC
 * Fixed problem with reading eeprom at 400kbpS 
 *
 *    Rev 1.0   Oct 13 2004 16:58:52   TilburyC
 * Initial revision.
 *
 *
 ***********************************************************************
 *
 *  Copyright (c) 2004 Sharp Microelectronics of the Americas
 *
 *  All rights reserved
 *
 *  SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
 *  OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
 *  AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES,
 *  SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
 *
 *  SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY
 *  FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A
 *  SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
 *  FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
 *
 **********************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include "sdk79524_board.h"
#include "interrupts.h"

/*
    Initialize basic interrupt functionality

*/
static INT_32 dev_irq;


/**********************************************************************
 *
 *  Function: init_interrupts()
 *
 *  Purpose:
 *      Put the VIC interface in a state where interrupts can be
 *      installed.
 *
 *  Processing:
 *      See comments below.
 *
 *  Parameters:
 *      None
 *
 *  Outputs:
 *      None
 *
 *  Returns:
 *      Non-zero upon error.  Otherwise return 0.
 *
 *  Notes:
 *      This function must be called before setting up any device
 *      interrupts.
 *
 *********************************************************************/
INT_32 init_interrupts(void)
{

    /* Open IRQ */
    if ((dev_irq = irq_open(0,0)) == 0x0)
    {
        /* Error opening the device */
        return 2;
    }

    /* Install the default interrupt vectors at 0x0 */
    //vic_ioctl(dev_irq, VIC_INSTALL_DEFAULT_SW_DISPATCHER, 0);

    /* enable global interrupts*/
    enable_irq();

    return 0;
}


/**********************************************************************
 *
 *  Function: create_interrupt()
 *
 *  Purpose:
 *      Instantiate a hardware interrupt vector
 *
 *  Processing:
 *      Set the VIC controller regaisters so that the specified
 *      interrupt can recieve service.
 *
 *  Parameters:
 *      source  - Which interrupt to use
 *      vector  - Where to put the interrupt handler in the table
 *      handler - Pointer to (void (*p)(void)) irq handler
 *
 *  Outputs: VIC registers
 *
 *  Returns:
 *      Non-zero value if the parameters do not make sense or if
 *      the interrupt device has not been opened.  Otherwise
 *      return 0.
 *
 *  Notes:
 *      none
 *
 *********************************************************************/
INT_32 create_interrupt(UNS_32 source, UNS_32 vector, PFV handler)
{
    VIC_CFG_T vic_cfg;

    //if((handler != NULL) || (dev_irq == 0))
    //    return 1;

    /* Enable IRQ source */
    irq_ioctl(dev_irq, IRQ_ENABLE_SOURCE, source);

    /* Set priority of IRQ source */
    irq_ioctl(dev_irq, IRQ_ENABLE_SOURCE, source);

    /* Set up interruption handler */
    irq_ioctl(dev_irq, IRQ_SET_HANDLER, (INT_32)handler);
    

    vic_cfg.source = source;
    vic_cfg.vector = vector;
    vic_cfg.handler = handler;

    /* Set up UART0 interrupt handler */
    vic_ioctl(dev_irq, VIC_ENABLE_INT_VEC, (INT_32)&vic_cfg);
    vic_ioctl(dev_irq, VIC_ADD_HANDLER, (INT_32)&vic_cfg);
    vic_ioctl(dev_irq, VIC_SET_INT_SRC_IRQ, vic_cfg.source);
    vic_ioctl(dev_irq, VIC_ENABLE_INT_SRC, vic_cfg.source);

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -