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

📄 lpc_vic.c

📁 给大家提供一个在inram/exram中调试的示例,在周公的lpc2200上调试过.
💻 C
字号:
#ifndef __LPC_VIC_C
#define __LPC_VIC_C
/***********************************************************************
 *         BU MMS China, Philips Semiconductor Software Support
 *         Embest info&Tech Co. Software Support
 *---------------------------------------------------------------------------
 * The software is delivered "AS IS" without warranty or condition of any
 * kind, either express, implied or statutory.  Everybody can use it as 
 * it is opened and without copyright. We will not take any law responsibility
 * for any problem produced by using this software.
 *---------------------------------------------------------------------------                                                    
 *    File name: 	LPC_Vic.c
 *    Description: 
 *                                                                                      
 *    History:                                                                     
 *    1. Date:		Aug 04, 2004                                              
 *       Author: 	Shawn Zhang                                                 
 *       Description: Create
 *
 *    2. Date:		Oct 30, 2004                                              
 *       Author: 	Shawn Zhang                                                 
 *       Description: Add vectored interrupt and soft interrupt functions
 *
 *    2. Date:		Mar 10, 2005                                              
 *       Author: 	Embest w.h.xie                                                 
 *       Description: Add allow repeat include 
 *
 *	$Revision: 1.0$
 **********************************************************************/
 
#include "LPC_Vic.h"

/*************************************************************************
 * Function Name: VIC_SetProtectionMode
 * Parameters: LPC_Vic_ProtectionMode_t ProtectionType
 * Return: void
 *
 * Description: According to the parameter:- ProtectionType to decide the VIC 
 *              access mode (previledged mode | user or previledged mode).
 *  
 *************************************************************************/
void VIC_SetProtectionMode(LPC_Vic_ProtectionMode_t ProtectionType)
{
	VICProtection = ProtectionType;
}

/*************************************************************************
 * Function Name: VIC_GetProtectionMode
 * Parameters: void
 * Return: LPC_Vic_ProtectionMode_t
 *
 * Description: Get the VIC access mode (previledged mode | user or previledged mode).
 *  
 *************************************************************************/
LPC_Vic_ProtectionMode_t VIC_GetProtectionMode(void)
{
	LPC_Vic_ProtectionMode_t ProtectionType;

	if (VICProtection & 0x1)
		ProtectionType = PrivilegedMode;
	else
		ProtectionType = UserandPrivilegedMode;
	
	return ProtectionType;
}


/*************************************************************************
 * Function Name: VIC_Init
 * Parameters: void
 * Return: void 
 *
 * Description: Initialize VIC
 *  
 *************************************************************************/
void VIC_Init(void)
{
	VICIntSelect  =  0;
	VICIntEnClr = 0xFFFFFFFF;
	VICSoftIntClr = 0xFFFFFFFF;
	VICProtection = 0;

	VICVectAddr = 0;
	VICDefVectAddr = 0;
	
	VICVectAddr0 = 0;
	VICVectAddr1 = 0;
	VICVectAddr2 = 0;	
	VICVectAddr3 = 0;
	VICVectAddr4 = 0;
	VICVectAddr5 = 0;
	VICVectAddr6 = 0;
	VICVectAddr7 = 0;
	VICVectAddr8 = 0;
	VICVectAddr9 = 0;
	VICVectAddr10 = 0;
	VICVectAddr11 = 0;
	VICVectAddr12 = 0;
	VICVectAddr13 = 0;
	VICVectAddr14 = 0;
	VICVectAddr15 = 0;

	VICVectCntl0 = 0;
	VICVectCntl1 = 0;
	VICVectCntl2 = 0;
	VICVectCntl3 = 0;
	VICVectCntl4 = 0;
	VICVectCntl5 = 0;
	VICVectCntl6 = 0;
	VICVectCntl7 = 0;
	VICVectCntl8 = 0;
	VICVectCntl9 = 0;
	VICVectCntl10 = 0;
	VICVectCntl11= 0;
	VICVectCntl12 = 0;
	VICVectCntl13 = 0;
	VICVectCntl14 = 0;
	VICVectCntl15 = 0;
}

/*************************************************************************
 * Function Name: VIC_GetIRQStatus
 * Parameters: void
 * Return: lpc_uint32 
 *
 * Description: Get IRQ Status of VIC. Return register VICIRQSTATUS's value.
 *              If some IRQ interrupt request is enabled, then the corresponding
 *				bit of VICIRQSTATUS is set.
 *  
 *************************************************************************/
lpc_uint32 VIC_GetIRQStatus(void)
{
	return VICIRQStatus;
}

/*************************************************************************
 * Function Name: VIC_GetFIQStatus
 * Parameters: void
 * Return: lpc_uint32
 *
 * Description: Get FIQ Status of VIC. Return register VICFIQSTATUS's value.
 *              If some FIQ interrupt request is enabled, then the corresponding
 *				bit of VICFIQSTATUS is set. If more that one interrupt request 
 *              is assigned as FIQ, then invoking this function can decide which
 *              one or ones is/are the request source(s).
 *  
 *************************************************************************/
lpc_uint32 VIC_GetFIQStatus(void)
{
	return VICFIQStatus ;
}

/*************************************************************************
 * Function Name: VIC_EnableInt
 * Parameters: lpc_uint32 IntType
 * Return: void
 *
 * Description: Enable specific interrupt
 *  
 *************************************************************************/
void VIC_EnableInt(lpc_uint32 IntType)
{
	VICIntEnable |= IntType;
}

/*************************************************************************
 * Function Name: VIC_DisableInt
 * Parameters: lpc_uint32 IntType
 * Return: void
 *
 * Description: Disable specific interrupt
 *  
 *************************************************************************/
void VIC_DisableInt(lpc_uint32 IntType)
{
	VICIntEnClr |= IntType;
}

/*************************************************************************
 * Function Name: VIC_EnableNonVectoredIRQ
 * Parameters: pIRQSub - Non Vectored IRQ Sub address
 * Return: void
 *
 * Description:  Set VICDefVectAddr to be the IRQ Sub address.
 *
 *************************************************************************/
void VIC_EnableNonVectoredIRQ(LPC_WORD32 pIRQSub)
{
	VICDefVectAddr = pIRQSub;
}

/*************************************************************************
 * Function Name: VIC_DisableNonVectoredIRQ
 * Parameters: void
 * Return: void
 *
 * Description: Set VICDefVectAddr to be reset value (NULL).
 *		
 *************************************************************************/
void VIC_DisableNonVectoredIRQ(void)
{
	VICDefVectAddr = NULL;
}

/*************************************************************************
 * Function Name: VIC_SetVectoredIRQ
 * Parameters:  pIRQSub - Vectored IRQ Sub address
 *              	LPC_Vic_IRQSlots_t VicIrqSlot
 *              	unsigned int VicIntSource
 *
 * Return: void
 *
 * Description:  Set vectored interrupt, assigning IRQ subroutine, priority and interrupt 
 *				source
 *
 *************************************************************************/
void VIC_SetVectoredIRQ(LPC_WORD32 pIRQSub, LPC_Vic_IRQSlots_t VicIrqSlot, 
	unsigned long VicIntSource)
{
	unsigned long volatile *pReg;
	unsigned int VicIntSrcNum;

	// Load base address of vectored address registers
	pReg = &VICVectAddr0;
	// Set Address of callback function to corresponding Slot
	*(pReg+VicIrqSlot) = (unsigned long)pIRQSub;
	
	// Load base address of ctrl registers
	pReg = &VICVectCntl0;
	VicIntSrcNum = BitToNum(VicIntSource);
	// Set source channel and enable the slot
	*(pReg+VicIrqSlot) = VicIntSrcNum | 0x20;
	
	// Clear FIQ select bit
	VICIntSelect &= ~(1<<VicIntSrcNum);
}

#endif   //__LPC_VIC_C

⌨️ 快捷键说明

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