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

📄 xiic_intr.c

📁 FPGA 并行NOR FLash的操作相关
💻 C
字号:
/* $Id: xiic_intr.c,v 1.1 2007/12/03 15:44:58 meinelte Exp $ *//********************************************************************************       XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"*       AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND*       SOLUTIONS FOR XILINX DEVICES.  BY PROVIDING THIS DESIGN, CODE,*       OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,*       APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION*       THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,*       AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE*       FOR YOUR IMPLEMENTATION.  XILINX EXPRESSLY DISCLAIMS ANY*       WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE*       IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR*       REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF*       INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS*       FOR A PARTICULAR PURPOSE.**       (c) Copyright 2002 Xilinx Inc.*       All rights reserved.*******************************************************************************//*****************************************************************************//**** @file xiic_intr.c** Contains interrupt functions of the XIic driver.  This file is required* for the driver.** <pre>* MODIFICATION HISTORY:** Ver   Who  Date     Changes* ----- ---- -------- -----------------------------------------------* 1.01a rfp  10/19/01 release* 1.01c ecm  12/05/02 new rev* 1.01c rmm  05/14/03 Fixed diab compiler warnings relating to asserts.* 1.03a ecm  06/22/06 Added a call to the status handler in the TxErrorHandler*                     even if the Rx buffer pointer is not set. This fix is as*                     a result of a Sony use model which did not set the RX*                     pointer while in Master mode so it checks if MSMS == 1.* 1.13a wgr  03/22/07 Converted to new coding style.* </pre>*******************************************************************************//***************************** Include Files *********************************/#include "xiic.h"#include "xiic_i.h"#include "xio.h"/************************** Constant Definitions *****************************//**************************** Type Definitions *******************************//***************** Macros (Inline Functions) Definitions ******************//*************** Macros (Inline Functions) Definitions ********************//************************** Function Prototypes ****************************/static void StubFunction(XIic * InstancePtr);static void TxErrorHandler(XIic * InstancePtr);/************************** Variable Definitions *****************************//* The following function pointers are used to help allow finer partitioning * of the driver such that some parts of it are optional. These pointers are * setup by functions in the optional parts of the driver. */void (*XIic_AddrAsSlaveFuncPtr) (XIic * InstancePtr) = StubFunction;void (*XIic_NotAddrAsSlaveFuncPtr) (XIic * InstancePtr) = StubFunction;void (*XIic_RecvSlaveFuncPtr) (XIic * InstancePtr) = StubFunction;void (*XIic_SendSlaveFuncPtr) (XIic * InstancePtr) = StubFunction;void (*XIic_RecvMasterFuncPtr) (XIic * InstancePtr) = StubFunction;void (*XIic_SendMasterFuncPtr) (XIic * InstancePtr) = StubFunction;void (*XIic_ArbLostFuncPtr) (XIic * InstancePtr) = StubFunction;void (*XIic_BusNotBusyFuncPtr) (XIic * InstancePtr) = StubFunction;/*****************************************************************************//**** This function is the interrupt handler for the XIic driver. This function* should be connected to the interrupt system.** Only one interrupt source is handled for each interrupt allowing* higher priority system interrupts quicker response time.** @param    InstancePtr is a pointer to the XIic instance to be worked on.** @return** None.** @internal** The XIIC_INTR_ARB_LOST_MASK and XIIC_INTR_TX_ERROR_MASK interrupts must have* higher priority than the other device interrupts so that the IIC device does* not get into a potentially confused state. The remaining interrupts may be* rearranged with no harm.** All XIic device interrupts are ORed into one device interrupt. This routine* reads the pending interrupts via the IpIf interface and masks that with the* interrupt mask to evaluate only the interrupts enabled.*******************************************************************************/void XIic_InterruptHandler(void *InstancePtr){	u8 Status;	u32 IntrStatus;	u32 IntrPending;	u32 IntrEnable;	XIic *IicPtr = NULL;	u32 Clear = 0;	/*	 * Verify that each of the inputs are valid.	 */	XASSERT_VOID(InstancePtr != NULL);	/*	 * Convert the non-typed pointer to an IIC instance pointer	 */	IicPtr = (XIic *) InstancePtr;	/* Get the interrupt Status from the IPIF. There is no clearing of	 * interrupts in the IPIF. Interrupts must be cleared at the source.	 * To find which interrupts are pending; AND interrupts pending with	 * interrupts masked.	 */	IntrPending = XIIC_READ_IISR(IicPtr->BaseAddress);	IntrEnable = XIIC_READ_IIER(IicPtr->BaseAddress);	IntrStatus = IntrPending & IntrEnable;	/* Do not processes a devices interrupts if the device has no	 * interrupts pending or the global interrupts have been disabled	 */	if ((IntrStatus == 0) |	    (XIIC_IS_GINTR_ENABLED(IicPtr->BaseAddress) == FALSE)) {		return;	}	/* Update interrupt stats and get the contents of the status register	 */	IicPtr->Stats.IicInterrupts++;	Status = XIo_In8(IicPtr->BaseAddress + XIIC_SR_REG_OFFSET);	/* Service requesting interrupt	 */	if (IntrStatus & XIIC_INTR_ARB_LOST_MASK) {		/* Bus Arbritration Lost */		IicPtr->Stats.ArbitrationLost++;		XIic_ArbLostFuncPtr(IicPtr);		Clear = XIIC_INTR_ARB_LOST_MASK;	}	else if (IntrStatus & XIIC_INTR_TX_ERROR_MASK) {		/* Transmit errors (no acknowledge) received */		IicPtr->Stats.TxErrors++;		TxErrorHandler(IicPtr);		Clear = XIIC_INTR_TX_ERROR_MASK;	}	else if (IntrStatus & XIIC_INTR_NAAS_MASK) {		/* Not Addressed As Slave */		XIic_NotAddrAsSlaveFuncPtr(IicPtr);		Clear = XIIC_INTR_NAAS_MASK;	}	else if (IntrStatus & XIIC_INTR_RX_FULL_MASK) {		/* Receive register/FIFO is full */		IicPtr->Stats.RecvInterrupts++;		if (Status & XIIC_SR_ADDR_AS_SLAVE_MASK) {			XIic_RecvSlaveFuncPtr(IicPtr);		}		else {			XIic_RecvMasterFuncPtr(IicPtr);		}		Clear = XIIC_INTR_RX_FULL_MASK;	}	else if (IntrStatus & XIIC_INTR_AAS_MASK) {		/* Addressed As Slave */		XIic_AddrAsSlaveFuncPtr(IicPtr);		Clear = XIIC_INTR_AAS_MASK;	}	else if (IntrStatus & XIIC_INTR_BNB_MASK) {		/* IIC bus has transitioned to not busy */		/* check if send callback needs to run */		if (IicPtr->BNBOnly == TRUE) {			XIic_BusNotBusyFuncPtr(IicPtr);			IicPtr->BNBOnly = FALSE;		}		else {			IicPtr->SendHandler(IicPtr->SendCallBackRef, 0);		}		Clear = XIIC_INTR_BNB_MASK;		/* The bus is not busy, disable BusNotBusy interrupt */		XIic_mDisableIntr(IicPtr->BaseAddress, XIIC_INTR_BNB_MASK);	}	else if ((IntrStatus & XIIC_INTR_TX_EMPTY_MASK) ||		 (IntrStatus & XIIC_INTR_TX_HALF_MASK)) {		/* Transmit register/FIFO is empty or 

⌨️ 快捷键说明

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