Add PPC405 port in V10.1 format.

This commit is contained in:
Richard Barry 2008-03-30 21:15:19 +00:00
parent c2a6dc193e
commit bc7068a690
68 changed files with 22832 additions and 0 deletions

View file

@ -0,0 +1,107 @@
/*
*
* Xilinx, Inc.
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
* COURTESY TO YOU. 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.
*/
/*
* Xilinx EDK 10.1 EDK_K.15
*
* This file is a sample test application
*
* This application is intended to test and/or illustrate some
* functionality of your system. The contents of this file may
* vary depending on the IP in your system and may use existing
* IP driver functions. These drivers will be generated in your
* XPS project when you run the "Generate Libraries" menu item
* in XPS.
*
* Your XPS project directory is at:
* C:\E\Dev\FreeRTOS\WorkingCopy2\Demo\PPC405_Xilinx_Virtex4_GCC\
*/
// Located in: ppc405_0/include/xparameters.h
#include "xparameters.h"
#include "xcache_l.h"
#include "xintc.h"
#include "xexception_l.h"
#include "intc_header.h"
#include "xuartlite.h"
#include "uartlite_header.h"
#include "uartlite_intr_header.h"
#include "xbasic_types.h"
#include "xgpio.h"
#include "gpio_header.h"
//====================================================
int main (void) {
static XIntc intc;
XCache_EnableICache(0x00000001);
XCache_EnableDCache(0x00000001);
static XUartLite RS232_Uart_UartLite;
{
XStatus status;
// status = IntcSelfTestExample(XPAR_XPS_INTC_0_DEVICE_ID);
}
{
XStatus Status;
// Status = IntcInterruptSetup(&intc, XPAR_XPS_INTC_0_DEVICE_ID);
}
{
XStatus status;
// status = UartLiteSelfTestExample(XPAR_RS232_UART_DEVICE_ID);
}
{
XStatus Status;
// Status = UartLiteIntrExample(&intc, &RS232_Uart_UartLite, \
// XPAR_RS232_UART_DEVICE_ID, \
// XPAR_XPS_INTC_0_RS232_UART_INTERRUPT_INTR);
}
{
XStatus status;
status = GpioOutputExample(XPAR_LEDS_4BIT_DEVICE_ID,4);
}
{
XStatus status;
status = GpioOutputExample(XPAR_LEDS_POSITIONS_DEVICE_ID,5);
}
XCache_DisableDCache();
XCache_DisableICache();
return 0;
}

View file

@ -0,0 +1,224 @@
/*******************************************************************/
/* */
/* This file is automatically generated by linker script generator.*/
/* */
/* Version: Xilinx EDK 10.1 EDK_K.15 */
/* */
/* Copyright (c) 2004 Xilinx, Inc. All rights reserved. */
/* */
/* Description : PowerPC405 Linker Script */
/* */
/*******************************************************************/
_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x2000;
_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x2000;
/* Define Memories in the system */
MEMORY
{
SRAM_C_MEM0_BASEADDR : ORIGIN = 0xFFF00000, LENGTH = 0x000FFFEC
}
/* Specify the default entry point to the program */
ENTRY(_boot)
STARTUP(boot.o)
/* Define the sections, and where they are mapped in memory */
SECTIONS
{
.vectors : {
__vectors_start = .;
*(.vectors)
__vectors_end = .;
} > SRAM_C_MEM0_BASEADDR
.text : {
*(.text)
*(.text.*)
*(.gnu.linkonce.t.*)
} > SRAM_C_MEM0_BASEADDR
.init : {
KEEP (*(.init))
} > SRAM_C_MEM0_BASEADDR
.fini : {
KEEP (*(.fini))
} > SRAM_C_MEM0_BASEADDR
.rodata : {
__rodata_start = .;
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r.*)
__rodata_end = .;
} > SRAM_C_MEM0_BASEADDR
.rodata1 : {
__rodata1_start = .;
*(.rodata1)
*(.rodata1.*)
__rodata1_end = .;
} > SRAM_C_MEM0_BASEADDR
.sdata2 : {
__sdata2_start = .;
*(.sdata2)
*(.sdata2.*)
*(.gnu.linkonce.s2.*)
__sdata2_end = .;
} > SRAM_C_MEM0_BASEADDR
.sbss2 : {
__sbss2_start = .;
*(.sbss2)
*(.sbss2.*)
*(.gnu.linkonce.sb2.*)
__sbss2_end = .;
} > SRAM_C_MEM0_BASEADDR
.data : {
__data_start = .;
*(.data)
*(.data.*)
*(.gnu.linkonce.d.*)
__data_end = .;
} > SRAM_C_MEM0_BASEADDR
.data1 : {
__data1_start = .;
*(.data1)
*(.data1.*)
__data1_end = .;
} > SRAM_C_MEM0_BASEADDR
.got : {
*(.got)
} > SRAM_C_MEM0_BASEADDR
.got1 : {
*(.got1)
} > SRAM_C_MEM0_BASEADDR
.got2 : {
*(.got2)
} > SRAM_C_MEM0_BASEADDR
.ctors : {
__CTOR_LIST__ = .;
___CTORS_LIST___ = .;
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
__CTOR_END__ = .;
___CTORS_END___ = .;
} > SRAM_C_MEM0_BASEADDR
.dtors : {
__DTOR_LIST__ = .;
___DTORS_LIST___ = .;
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
__DTOR_END__ = .;
___DTORS_END___ = .;
} > SRAM_C_MEM0_BASEADDR
.fixup : {
__fixup_start = .;
*(.fixup)
__fixup_end = .;
} > SRAM_C_MEM0_BASEADDR
.eh_frame : {
*(.eh_frame)
} > SRAM_C_MEM0_BASEADDR
.jcr : {
*(.jcr)
} > SRAM_C_MEM0_BASEADDR
.gcc_except_table : {
*(.gcc_except_table)
} > SRAM_C_MEM0_BASEADDR
.sdata : {
__sdata_start = .;
*(.sdata)
*(.sdata.*)
*(.gnu.linkonce.s.*)
__sdata_end = .;
} > SRAM_C_MEM0_BASEADDR
.sbss : {
__sbss_start = .;
*(.sbss)
*(.sbss.*)
*(.gnu.linkonce.sb.*)
*(.scommon)
__sbss_end = .;
} > SRAM_C_MEM0_BASEADDR
.tdata : {
__tdata_start = .;
*(.tdata)
*(.tdata.*)
*(.gnu.linkonce.td.*)
__tdata_end = .;
} > SRAM_C_MEM0_BASEADDR
.tbss : {
__tbss_start = .;
*(.tbss)
*(.tbss.*)
*(.gnu.linkonce.tb.*)
__tbss_end = .;
} > SRAM_C_MEM0_BASEADDR
.bss : {
__bss_start = .;
*(.bss)
*(.bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
__bss_end = .;
} > SRAM_C_MEM0_BASEADDR
.boot0 0xFFFFFFEC : {
__boot0_start = .;
*(.boot0)
__boot0_end = .;
}
.boot 0xFFFFFFFC : {
__boot_start = .;
*(.boot)
__boot_end = .;
}
/* Generate Stack and Heap Sections */
.stack : {
_stack_end = .;
. += _STACK_SIZE;
. = ALIGN(16);
__stack = .;
} > SRAM_C_MEM0_BASEADDR
.heap : {
. = ALIGN(16);
_heap_start = .;
. += _HEAP_SIZE;
. = ALIGN(16);
_heap_end = .;
_end = .;
} > SRAM_C_MEM0_BASEADDR
}

View file

@ -0,0 +1,12 @@
#define TESTAPP_GEN
/* $Id: gpio_header.h,v 1.1 2007/05/15 06:49:42 mta Exp $ */
#include "xbasic_types.h"
#include "xstatus.h"
XStatus GpioOutputExample(Xuint16 DeviceId, Xuint32 GpioWidth);
XStatus GpioInputExample(Xuint16 DeviceId, Xuint32 *DataRead);

View file

@ -0,0 +1,12 @@
#define TESTAPP_GEN
/* $Id: intc_header.h,v 1.1 2007/05/15 07:08:08 mta Exp $ */
#include "xbasic_types.h"
#include "xstatus.h"
XStatus IntcSelfTestExample(Xuint16 DeviceId);
XStatus IntcInterruptSetup(XIntc *IntcInstancePtr, Xuint16 DeviceId);

View file

@ -0,0 +1,11 @@
#define TESTAPP_GEN
/* $Id: uartlite_header.h,v 1.1 2007/05/15 07:00:27 mta Exp $ */
#include "xbasic_types.h"
#include "xstatus.h"
XStatus UartLiteSelfTestExample(Xuint16 DeviceId);

View file

@ -0,0 +1,14 @@
#define TESTAPP_GEN
/* $Id: uartlite_intr_header.h,v 1.1 2007/05/15 07:00:27 mta Exp $ */
#include "xbasic_types.h"
#include "xstatus.h"
XStatus UartLiteIntrExample(XIntc* IntcInstancePtr, \
XUartLite* UartLiteInstancePtr, \
Xuint16 UartLiteDeviceId, \
Xuint16 UartLiteIntrId);

View file

@ -0,0 +1,311 @@
#define TESTAPP_GEN
/* $Id: xgpio_tapp_example.c,v 1.1 2007/05/15 06:49:42 mta 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 2005 Xilinx Inc.
* All rights reserved.
*
******************************************************************************/
/*****************************************************************************/
/**
* @file xgpio_tapp_example.c
*
* This file contains a example for using GPIO hardware and driver.
* This example assumes that there is a UART Device or STDIO Device in the
* hardware system.
*
* This example can be run on the Xilinx ML300 board with either the PowerPC or
* the MicroBlaze processor using the Prototype Pins & LEDs of the board
* connected to the GPIO and the Push Buttons connected.
*
* @note
*
* None
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ---- -------- -----------------------------------------------
* 1.00a sv 04/15/05 Initial release for TestApp integration.
* </pre>
*
*****************************************************************************/
/***************************** Include Files ********************************/
#include "xparameters.h"
#include "xgpio.h"
#include "stdio.h"
#include "xstatus.h"
/************************** Constant Definitions ****************************/
/*
* The following constant is used to wait after an LED is turned on to make
* sure that it is visible to the human eye. This constant might need to be
* tuned for faster or slower processor speeds.
*/
#define LED_DELAY 1000000
/* following constant is used to determine which channel of the GPIO is
* used if there are 2 channels supported in the GPIO.
*/
#define LED_CHANNEL 1
#define LED_MAX_BLINK 0x1 /* Number of times the LED Blinks */
#define GPIO_BITWIDTH 16 /* This is the width of the GPIO */
#define printf xil_printf /* A smaller footprint printf */
/*
* The following constants map to the XPAR parameters created in the
* xparameters.h file. They are defined here such that a user can easily
* change all the needed parameters in one place.
*/
#ifndef TESTAPP_GEN
#define GPIO_OUTPUT_DEVICE_ID XPAR_LEDS_4BIT_DEVICE_ID
#define GPIO_INPUT_DEVICE_ID XPAR_LEDS_4BIT_DEVICE_ID
#endif /* TESTAPP_GEN */
/**************************** Type Definitions ******************************/
/***************** Macros (Inline Functions) Definitions *******************/
/************************** Function Prototypes ****************************/
XStatus GpioOutputExample(Xuint16 DeviceId, Xuint32 GpioWidth);
XStatus GpioInputExample(Xuint16 DeviceId, Xuint32 *DataRead);
void GpioDriverHandler(void *CallBackRef);
/************************** Variable Definitions **************************/
/*
* The following are declared globally so they are zeroed and so they are
* easily accessible from a debugger
*/
XGpio GpioOutput; /* The driver instance for GPIO Device configured as O/P */
XGpio GpioInput; /* The driver instance for GPIO Device configured as I/P */
/*****************************************************************************/
/**
* Main function to call the example.This function is not included if the
* example is generated from the TestAppGen test tool.
*
* @param None
*
* @return XST_SUCCESS if successful, XST_FAILURE if unsuccessful
*
* @note None
*
******************************************************************************/
#ifndef TESTAPP_GEN
int main(void)
{
XStatus Status;
Xuint32 InputData;
Status = GpioOutputExample(GPIO_OUTPUT_DEVICE_ID, GPIO_BITWIDTH);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
Status = GpioInputExample(GPIO_INPUT_DEVICE_ID, &InputData);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
printf("Data read from GPIO Input is 0x%x \n", (int)InputData);
return XST_SUCCESS;
}
#endif
/*****************************************************************************/
/**
*
* This function does a minimal test on the GPIO device configured as OUTPUT
* and driver as a example.
*
*
* @param DeviceId is the XPAR_<GPIO_instance>_DEVICE_ID value from
* xparameters.h
* @param GpioWidth is the width of the GPIO
*
* @return XST_SUCCESS if successful, XST_FAILURE if unsuccessful
*
* @note None
*
****************************************************************************/
XStatus GpioOutputExample(Xuint16 DeviceId, Xuint32 GpioWidth)
{
Xuint32 Data;
volatile int Delay;
Xuint32 LedBit;
Xuint32 LedLoop;
XStatus Status;
/*
* Initialize the GPIO driver so that it's ready to use,
* specify the device ID that is generated in xparameters.h
*/
Status = XGpio_Initialize(&GpioOutput, DeviceId);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
/*
* Set the direction for all signals to be outputs
*/
XGpio_SetDataDirection(&GpioOutput, LED_CHANNEL, 0x0);
/*
* Set the GPIO outputs to low
*/
XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL, 0x0);
for (LedBit = 0x0; LedBit < GpioWidth; LedBit++)
{
for (LedLoop = 0; LedLoop < LED_MAX_BLINK; LedLoop++)
{
/*
* Set the GPIO Output to High
*/
XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL, 1 << LedBit);
#ifndef __SIM__
/*
* Wait a small amount of time so the LED is visible
*/
for (Delay = 0; Delay < LED_DELAY; Delay++);
#endif
/*
* Read the state of the data so that it can be verified
*/
/* Data = XGpio_DiscreteRead(&GpioOutput, LED_CHANNEL); */
/*
* If the data read back is not the same as the data
* written then return FAILURE
*/
/*if (Data != (1 << LedBit))
{
return XST_FAILURE;
}*/
/*
* Clear the GPIO Output
*/
XGpio_DiscreteClear(&GpioOutput, LED_CHANNEL, 1 << LedBit);
/*
* Read the state of the data so that it can be verified
*/
/* Data = XGpio_DiscreteRead(&GpioOutput, LED_CHANNEL);*/
/*
* If the data read back is not the same as the data
* written then return FAILURE
*/
/* if (Data & ( 1 << LedBit))
{
return XST_FAILURE;
}*/
#ifndef __SIM__
/*
* Wait a small amount of time so the LED is visible
*/
for (Delay = 0; Delay < LED_DELAY; Delay++);
#endif
}
}
return XST_SUCCESS;
}
/******************************************************************************/
/**
*
* This function performs a test on the GPIO driver/device with the GPIO
* configured as INPUT
*
* @param DeviceId is the XPAR_<GPIO_instance>_DEVICE_ID value from
* xparameters.h
* @param DataRead is the pointer where the data read from GPIO Input is
* returned
*
* @return XST_SUCCESS if the Test is successful, otherwise XST_FAILURE
*
* @note None.
*
******************************************************************************/
XStatus GpioInputExample(Xuint16 DeviceId, Xuint32 *DataRead)
{
XStatus Status;
/*
* Initialize the GPIO driver so that it's ready to use,
* specify the device ID that is generated in xparameters.h
*/
Status = XGpio_Initialize(&GpioInput, DeviceId);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
/*
* Set the direction for all signals to be inputs
*/
XGpio_SetDataDirection(&GpioInput, LED_CHANNEL, 0xFFFFFFFF);
/*
* Read the state of the data so that it can be verified
*/
*DataRead = XGpio_DiscreteRead(&GpioInput, LED_CHANNEL);
return XST_SUCCESS;
}

View file

@ -0,0 +1,263 @@
#define TESTAPP_GEN
/* $Id: xintc_tapp_example.c,v 1.1 2007/05/15 07:08:09 mta 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-2006 Xilinx Inc.
* All rights reserved.
*
*******************************************************************************/
/******************************************************************************/
/**
*
* @file xintc_tapp_example.c
*
* This file contains a self test example using the Interrupt Controller driver
* (XIntc) and hardware device. Please reference other device driver examples to
* see more examples of how the intc and interrupts can be used by a software
* application.
*
* This example shows the use of the Interrupt Controller both with a PowerPC405
* and MicroBlaze processor.
*
* The TestApp Gen utility uses this file to perform the self test and setup
* of intc for interrupts.
*
* @note
*
* None
*
* <pre>
*
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ---- -------- --------------------------------------------------------
* 1.00a sv 06/29/05 Created for Test App Integration
* 1.00c sn 05/09/06 Added Interrupt Setup Function
* </pre>
******************************************************************************/
/***************************** Include Files *********************************/
#include "xparameters.h"
#include "xstatus.h"
#include "xintc.h"
#ifdef __MICROBLAZE__
#include "mb_interface.h"
#endif
#ifdef __PPC__
#include "xexception_l.h"
#endif
/************************** Constant Definitions *****************************/
/*
* The following constants map to the XPAR parameters created in the
* xparameters.h file. They are defined here such that a user can easily
* change all the needed parameters in one place. This definition is not
* included if the example is generated from the TestAppGen test tool.
*/
#ifndef TESTAPP_GEN
#define INTC_DEVICE_ID XPAR_OPB_INTC_0_DEVICE_ID
#endif
/**************************** Type Definitions *******************************/
/***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/
XStatus IntcSelfTestExample(Xuint16 DeviceId);
XStatus IntcInterruptSetup(XIntc *IntcInstancePtr, Xuint16 DeviceId);
/************************** Variable Definitions *****************************/
static XIntc InterruptController; /* Instance of the Interrupt Controller */
/*****************************************************************************/
/**
*
* This is the main function for the Interrupt Controller example. This
* function is not included if the example is generated from the TestAppGen test
* tool.
*
* @param None.
*
* @return XST_SUCCESS to indicate success, otherwise XST_FAILURE.
*
* @note None.
*
******************************************************************************/
#ifndef TESTAPP_GEN
int main(void)
{
XStatus Status;
/*
* Run the Intc example , specify the Device ID generated in xparameters.h
*/
Status = IntcSelfTestExample(INTC_DEVICE_ID);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
return XST_SUCCESS;
}
#endif
/*****************************************************************************/
/**
*
* This function runs a self-test on the driver/device. This is a destructive
* test. This function is an example of how to use the interrupt controller
* driver component (XIntc) and the hardware device. This function is designed
* to work without any hardware devices to cause interrupts. It may not return
* if the interrupt controller is not properly connected to the processor in
* either software or hardware.
*
* This function relies on the fact that the interrupt controller hardware
* has come out of the reset state such that it will allow interrupts to be
* simulated by the software.
*
* @param DeviceId is device ID of the Interrupt Controller Device , typically
* XPAR_<INTC_instance>_DEVICE_ID value from xparameters.h
*
* @return XST_SUCCESS to indicate success, otherwise XST_FAILURE
*
* @note None.
*
******************************************************************************/
XStatus IntcSelfTestExample(Xuint16 DeviceId)
{
XStatus Status;
/*
* Initialize the interrupt controller driver so that it is ready to use.
*/
Status = XIntc_Initialize(&InterruptController, DeviceId);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
/*
* Perform a self-test to ensure that the hardware was built correctly
*/
Status = XIntc_SelfTest(&InterruptController);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function is used by the TestAppGen generated application to setup
* the interrupt controller.
*
* @param IntcInstancePtr is the reference to the Interrupt Controller
* instance.
* @param DeviceId is device ID of the Interrupt Controller Device , typically
* XPAR_<INTC_instance>_DEVICE_ID value from xparameters.h
*
* @return XST_SUCCESS to indicate success, otherwise XST_FAILURE
*
* @note None.
*
******************************************************************************/
XStatus IntcInterruptSetup(XIntc *IntcInstancePtr, Xuint16 DeviceId)
{
XStatus Status;
/*
* Initialize the interrupt controller driver so that it is ready to use.
*/
Status = XIntc_Initialize(IntcInstancePtr, DeviceId);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
/*
* Perform a self-test to ensure that the hardware was built correctly.
*/
Status = XIntc_SelfTest(IntcInstancePtr);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
#ifdef __MICROBLAZE__
/*
* Enable the microblaze Interrupts
*/
microblaze_enable_interrupts();
#endif
#ifdef __PPC__ /*PPC*/
/*
* Initialize the PPC405 exception table
*/
XExc_Init();
/*
* Register the interrupt controller handler with the exception table
*/
XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT,
(XExceptionHandler)XIntc_DeviceInterruptHandler,
(void*) 0);
/*
* Enable non-critical exceptions
*/
XExc_mEnableExceptions(XEXC_NON_CRITICAL);
#endif
/*
* Start the interrupt controller such that interrupts are enabled for
* all devices that cause interrupts.
*/
Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
return XST_SUCCESS;
}

View file

@ -0,0 +1,461 @@
#define TESTAPP_GEN
/* $Id: xuartlite_intr_tapp_example.c,v 1.1 2007/05/15 07:00:27 mta 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-2006 Xilinx Inc.
* All rights reserved.
*
*******************************************************************************/
/******************************************************************************/
/**
*
* @file xuartlite_intr_tapp_example.c
*
* This file contains a design example using the UartLite driver and
* hardware device using the interrupt mode for transmission of data.
*
* This example works with a PPC processor. Refer the examples of Interrupt
* controller for an example of using interrupts with the MicroBlaze processor.
*
* @note
*
* None.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ---- -------- -----------------------------------------------
* 1.00b sv 06/08/06 Created for supporting Test App Interrupt examples
* </pre>
******************************************************************************/
/***************************** Include Files *********************************/
#include "xparameters.h"
#include "xuartlite.h"
#include "xintc.h"
#ifdef __MICROBLAZE__
#include "mb_interface.h"
#else
#include "xexception_l.h"
#endif
/************************** Constant Definitions *****************************/
/*
* The following constants map to the XPAR parameters created in the
* xparameters.h file. They are defined here such that a user can easily
* change all the needed parameters in one place.
*/
#ifndef TESTAPP_GEN
#define UARTLITE_DEVICE_ID XPAR_RS232_UART_DEVICE_ID
#define INTC_DEVICE_ID XPAR_OPB_INTC_0_DEVICE_ID
#define UARTLITE_IRPT_INTR XPAR_OPB_INTC_0_RS232_UART_INTERRUPT_INTR
#endif
/*
* The following constant controls the length of the buffers to be sent
* and received with the UartLite device.
*/
#define TEST_BUFFER_SIZE 100
/**************************** Type Definitions *******************************/
/***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/
XStatus UartLiteIntrExample(XIntc *IntcInstancePtr,
XUartLite *UartLiteInstancePtr,
Xuint16 UartLiteDeviceId,
Xuint16 UartLiteIntrId);
static void UartLiteSendHandler(void *CallBackRef, unsigned int EventData);
static void UartLiteRecvHandler(void *CallBackRef, unsigned int EventData);
static XStatus UartLiteSetupIntrSystem(XIntc *IntcInstancePtr,
XUartLite *UartLiteInstancePtr,
Xuint16 UartLiteIntrId);
static void UartLiteDisableIntrSystem(XIntc *IntrInstancePtr,
Xuint16 UartLiteIntrId);
/************************** Variable Definitions *****************************/
/*
* The instances to support the device drivers are global such that the
* are initialized to zero each time the program runs.
*/
#ifndef TESTAPP_GEN
static XIntc IntcInstance; /* The instance of the Interrupt Controller */
static XUartLite UartLiteInst; /* The instance of the UartLite Device */
#endif
/*
* The following variables are shared between non-interrupt processing and
* interrupt processing such that they must be global.
*/
/*
* The following buffers are used in this example to send and receive data
* with the UartLite.
*/
Xuint8 SendBuffer[TEST_BUFFER_SIZE];
Xuint8 ReceiveBuffer[TEST_BUFFER_SIZE];
/*
* The following counter is used to determine when the entire buffer has
* been sent.
*/
static volatile int TotalSentCount;
/******************************************************************************/
/**
*
* Main function to call the UartLite interrupt example.
*
* @param None.
*
* @return XST_SUCCESS if successful, else XST_FAILURE.
*
* @note None
*
*******************************************************************************/
#ifndef TESTAPP_GEN
int main(void)
{
XStatus Status;
/*
* Run the UartLite Interrupt example , specify the Device ID that is
* generated in xparameters.h.
*/
Status = UartLiteIntrExample(&IntcInstance,
&UartLiteInst,
UARTLITE_DEVICE_ID,
UARTLITE_IRPT_INTR);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
return XST_SUCCESS;
}
#endif
/****************************************************************************/
/**
*
* This function does a minimal test on the UartLite device and driver as a
* design example. The purpose of this function is to illustrate how to use
* the XUartLite component.
*
* This function sends data and expects to receive the same data through the
* UartLite. The user must provide a physical loopback such that data which
* is transmitted will be received.
*
* This function uses the interrupt driver mode of the UartLite. The calls to
* the UartLite driver in the interrupt handlers, should only use the
* non-blocking calls.
*
* @param IntcInstancePtr is a pointer to the instance of the INTC component.
* @param UartLiteInstPtr is a pointer to the instance of UartLite component.
* @param UartLiteDeviceId is the Device ID of the UartLite Device and is the
* XPAR_<UARTLITE_instance>_DEVICE_ID value from xparameters.h.
* @param UartLiteIntrId is the Interrupt ID and is typically
* XPAR_<INTC_instance>_<UARTLITE_instance>_IP2INTC_IRPT_INTR
* value from xparameters.h.
*
* @return XST_SUCCESS if successful, otherwise XST_FAILURE.
*
* @note
*
* This function contains an infinite loop such that if interrupts are not
* working it may never return.
*
****************************************************************************/
XStatus UartLiteIntrExample(XIntc *IntcInstancePtr,
XUartLite *UartLiteInstPtr,
Xuint16 UartLiteDeviceId,
Xuint16 UartLiteIntrId)
{
XStatus Status;
Xuint32 Index;
/*
* Initialize the UartLite driver so that it's ready to use.
*/
Status = XUartLite_Initialize(UartLiteInstPtr, UartLiteDeviceId);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
/*
* Perform a self-test to ensure that the hardware was built correctly.
*/
Status = XUartLite_SelfTest(UartLiteInstPtr);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
/*
* Connect the UartLite to the interrupt subsystem such that interrupts can
* occur. This function is application specific.
*/
Status = UartLiteSetupIntrSystem(IntcInstancePtr,
UartLiteInstPtr,
UartLiteIntrId);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
/*
* Setup the handlers for the UartLite that will be called from the
* interrupt context when data has been sent and received,
* specify a pointer to the UartLite driver instance as the callback
* reference so the handlers are able to access the instance data.
*/
XUartLite_SetSendHandler(UartLiteInstPtr, UartLiteSendHandler,
UartLiteInstPtr);
XUartLite_SetRecvHandler(UartLiteInstPtr, UartLiteRecvHandler,
UartLiteInstPtr);
/*
* Enable the interrupt of the UartLite so that the interrupts will occur.
*/
XUartLite_EnableInterrupt(UartLiteInstPtr);
/*
* Initialize the send buffer bytes with a pattern to send.
*/
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++)
{
SendBuffer[Index] = Index;
}
/*
* Send the buffer using the UartLite.
*/
XUartLite_Send(UartLiteInstPtr, SendBuffer, TEST_BUFFER_SIZE);
/*
* Wait for the entire buffer to be transmitted, the function may get
* locked up in this loop if the interrupts are not working correctly.
*/
while ((TotalSentCount != TEST_BUFFER_SIZE))
{
}
UartLiteDisableIntrSystem(IntcInstancePtr, UartLiteIntrId);
return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function is the handler which performs processing to send data to the
* UartLite. It is called from an interrupt context such that the amount of
* processing performed should be minimized. It is called when the transmit
* FIFO of the UartLite is empty and more data can be sent through the UartLite.
*
* This handler provides an example of how to handle data for the UartLite, but
* is application specific.
*
* @param CallBackRef contains a callback reference from the driver.
* In this case it is the instance pointer for the UartLite driver.
* @param EventData contains the number of bytes sent or received for sent and
* receive events.
*
* @return None.
*
* @note None.
*
****************************************************************************/
static void UartLiteSendHandler(void *CallBackRef, unsigned int EventData)
{
TotalSentCount = EventData;
}
/****************************************************************************/
/**
*
* This function is the handler which performs processing to receive data from
* the UartLite. It is called from an interrupt context such that the amount of
* processing performed should be minimized. It is called when any data is
* present in the receive FIFO of the UartLite such that the data can be
* retrieved from the UartLite. The amount of data present in the FIFO is not
* known when this function is called.
*
* This handler provides an example of how to handle data for the UartLite, but
* is application specific.
*
* @param CallBackRef contains a callback reference from the driver, in this
* case it is the instance pointer for the UartLite driver.
* @param EventData contains the number of bytes sent or received for sent and
* receive events.
*
* @return None.
*
* @note None.
*
****************************************************************************/
static void UartLiteRecvHandler(void *CallBackRef, unsigned int EventData)
{
}
/****************************************************************************/
/**
*
* This function setups the interrupt system such that interrupts can occur
* for the UartLite. This function is application specific since the actual
* system may or may not have an interrupt controller. The UartLite could be
* directly connected to a processor without an interrupt controller. The
* user should modify this function to fit the application.
*
* @param IntcInstancePtr is a pointer to the instance of the INTC component.
* @param UartLiteInstPtr is a pointer to the instance of UartLite component.
* XPAR_<UARTLITE_instance>_DEVICE_ID value from xparameters.h.
* @param UartLiteIntrId is the Interrupt ID and is typically
* XPAR_<INTC_instance>_<UARTLITE_instance>_IP2INTC_IRPT_INTR
* value from xparameters.h.
*
* @return XST_SUCCESS if successful, otherwise XST_FAILURE.
*
* @note None.
*
****************************************************************************/
XStatus UartLiteSetupIntrSystem(XIntc *IntcInstancePtr,
XUartLite *UartLiteInstPtr,
Xuint16 UartLiteIntrId)
{
XStatus Status;
#ifndef TESTAPP_GEN
/*
* Initialize the interrupt controller driver so that it is ready to use.
*/
Status = XIntc_Initialize(IntcInstancePtr, INTC_DEVICE_ID);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
#endif
/*
* Connect a device driver handler that will be called when an interrupt
* for the device occurs, the device driver handler performs the specific
* interrupt processing for the device.
*/
Status = XIntc_Connect(IntcInstancePtr, UartLiteIntrId,
(XInterruptHandler)XUartLite_InterruptHandler,
(void *)UartLiteInstPtr);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
#ifndef TESTAPP_GEN
/*
* Start the interrupt controller such that interrupts are enabled for
* all devices that cause interrupts, specific real mode so that
* the UART can cause interrupts thru the interrupt controller.
*/
Status = XIntc_Start(IntcInstancePtr, XIN_REAL_MODE);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
#endif
/*
* Enable the interrupt for the UartLite.
*/
XIntc_Enable(IntcInstancePtr, UartLiteIntrId);
#ifndef TESTAPP_GEN
/*
* Initialize the PPC exception table.
*/
XExc_Init();
/*
* Register the interrupt controller handler with the exception table.
*/
XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT,
(XExceptionHandler)XIntc_InterruptHandler,
IntcInstancePtr);
/*
* Enable non-critical exceptions.
*/
XExc_mEnableExceptions(XEXC_NON_CRITICAL);
#endif /* TESTAPP_GEN */
return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function disables the interrupts that occur for the UartLite.
*
* @param IntcInstancePtr is a pointer to the instance of the INTC component.
* @param UartLiteIntrId is the Interrupt ID and is typically
* XPAR_<INTC_instance>_<UARTLITE_instance>_IP2INTC_IRPT_INTR
* value from xparameters.h.
*
* @return None.
*
* @note None.
*
******************************************************************************/
static void UartLiteDisableIntrSystem(XIntc *IntcInstancePtr,
Xuint16 UartLiteIntrId)
{
/*
* Disconnect and disable the interrupt for the UartLite
*/
XIntc_Disconnect(IntcInstancePtr, UartLiteIntrId);
}

View file

@ -0,0 +1,147 @@
#define TESTAPP_GEN
/* $Id: xuartlite_selftest_example.c,v 1.1 2007/05/15 07:00:27 mta 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 2005 Xilinx Inc.
* All rights reserved.
*
*****************************************************************************/
/****************************************************************************/
/**
*
* @file xuartlite_selftest_example.c
*
* This file contains a design example using the UartLite driver (XUartLite) and
* hardware device.
*
* @note
*
* None
*
* MODIFICATION HISTORY:
* <pre>
* Ver Who Date Changes
* ----- ---- -------- -----------------------------------------------
* 1.00a ecm 01/25/04 First Release.
* 1.00a sv 06/13/05 Minor changes to comply to Doxygen and Coding guidelines
* </pre>
******************************************************************************/
/***************************** Include Files *********************************/
#include "xparameters.h"
#include "xuartlite.h"
/************************** Constant Definitions *****************************/
/*
* The following constants map to the XPAR parameters created in the
* xparameters.h file. They are defined here such that a user can easily
* change all the needed parameters in one place.
*/
#define UARTLITE_DEVICE_ID XPAR_RS232_UART_DEVICE_ID
/**************************** Type Definitions *******************************/
/***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/
XStatus UartLiteSelfTestExample(Xuint16 DeviceId);
/************************** Variable Definitions *****************************/
XUartLite UartLite; /* Instance of the UartLite device */
/*****************************************************************************/
/**
*
* Main function to call the example. This function is not included if the
* example is generated from the TestAppGen test tool.
*
* @param None.
*
* @return XST_SUCCESS if succesful, otherwise XST_FAILURE.
*
* @note None.
*
******************************************************************************/
#ifndef TESTAPP_GEN
int main(void)
{
XStatus Status;
/*
* Run the UartLite self test example, specify the the Device ID that is
* generated in xparameters.h
*/
Status = UartLiteSelfTestExample(UARTLITE_DEVICE_ID);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
return XST_SUCCESS;
}
#endif
/*****************************************************************************/
/**
*
* This function does a minimal test on the UartLite device and driver as a
* design example. The purpose of this function is to illustrate
* how to use the XUartLite component.
*
*
* @param DeviceId is the XPAR_<uartlite_instance>_DEVICE_ID value from
* xparameters.h.
*
* @return XST_SUCCESS if succesful, otherwise XST_FAILURE.
*
* @note None.
*
****************************************************************************/
XStatus UartLiteSelfTestExample(Xuint16 DeviceId)
{
XStatus Status;
/*
* Initialize the UartLite driver so that it is ready to use.
*/
Status = XUartLite_Initialize(&UartLite, DeviceId);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
/*
* Perform a self-test to ensure that the hardware was built correctly.
*/
Status = XUartLite_SelfTest(&UartLite);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
return XST_SUCCESS;
}