/****************************************************************************** * * Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * Use of the Software is limited solely to applications: * (a) running on a Xilinx device, or * (b) that interact with a Xilinx device through a bus or interconnect. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of the Xilinx shall not be used * in advertising or otherwise to promote the sale, use or other dealings in * this Software without prior written authorization from Xilinx. * ******************************************************************************/ /* * helloworld.c: simple test application * * This application configures UART 16550 to baud rate 9600. * PS7 UART (Zynq) is not initialized by this application, since * bootrom/bsp configures it to baud rate 115200 * * ------------------------------------------------ * | UART TYPE BAUD RATE | * ------------------------------------------------ * uartns550 9600 * uartlite Configurable only in HW design * ps7_uart 115200 (configured by bootrom/bsp) */ #include #include "platform.h" #include "xspi.h" #include "xparameters.h" #include "PmodSF3.h" #include "intc.h" //#include "microblaze_sleep.h" #ifdef XPAR_INTC_0_DEVICE_ID #define XPAR_AXI_INTC_0_PMODSF3_0_QSPI_INTERRUPT_INTR #else #define INT_ADDR XPAR_FABRIC_PMODSF3_0_QSPI_INTERRUPT_INTR #endif PmodSF3 mySF3; //XSpi mySPI; //void print(char *str); const ivt_t ivt[] = { {XPAR_INTC_SINGLE_BASEADDR, (XInterruptHandler) XSpi_InterruptHandler, &mySF3.SF3Spi} }; int main() { XStatus Status; u32 BaseAddress = 0x000000; u32 ByteCount = 256; u8 WriteCmd = 0x02; u8 ReadCmd = 0x03; init_platform(); u32 Index; xil_printf("running test\r\n"); SF3_begin(&mySF3, &ivt[0], XPAR_PMODSF3_0_AXI_LITE_SPI_BASEADDR); SF3_SpiInit(&mySF3.SF3Spi); SF3_FlashWriteEnable(&mySF3); mySF3.WriteBuffer[5] = 100; Status = SF3_FlashWrite(&mySF3, BaseAddress , ByteCount, WriteCmd); for (Index = 0; Index < PAGE_SIZE + READ_WRITE_EXTRA_BYTES + DUAL_READ_DUMMY_BYTES; Index++) { xil_printf("\r\n read val = %d", mySF3.WriteBuffer[Index]); } xil_printf("\r\n write done\r\n"); // Clear the read buffer for (Index = 0; Index < PAGE_SIZE + READ_WRITE_EXTRA_BYTES + DUAL_READ_DUMMY_BYTES; Index++) { mySF3.ReadBuffer[Index] = 0x0; } Status = SF3_FlashRead(&mySF3, BaseAddress, ByteCount, ReadCmd); for (Index = 0; Index < PAGE_SIZE + READ_WRITE_EXTRA_BYTES + DUAL_READ_DUMMY_BYTES; Index++) { xil_printf("\r\n read val = %d", mySF3.ReadBuffer[Index]); } if (Status != XST_SUCCESS) { xil_printf("\r\nError running test"); } else{ xil_printf("\r\nTest successful!"); } cleanup_platform(); return 0; }