T
Tobias Baumann
Guest
Hello
I'm using Xilinx EDK 11.5 with xps_spi core version 2.01b. Core is
correctly integrated in my SDK, I can see the signals on my DSO.
Everything seems to be allright. But I've got a little software problem.
In SDK I transfer my data with the function "XSpi_Transfer(&mySPI,
outBuffer, inBuffer, 2)" (see above). It works exactly one time and I
get XST_SCCUSS back. But if I call XSpi_Transfer again, I get
XST_DEVICE_BUSY back.
My program do the following steps:
1.) initalize SPI (function "XSpi_Initialize")
2.) set options (function "XSpi_SetOptions")
3.) select slave (function "XSpi_SetSlaveSelect")
4.) start SPI (function "XSpi_Start")
5.) transfer data (function "XSpi_Transfer")
Every function return XST_SUCCESS, but not Xspi_transfer when I call it
the second time.
So my question? Is there any bug in the core or have I forgot something?
I hope someone can help me. I tried to google, found a similar problem,
but no solution.
Thanks a lot,
Tobias
C-Code:
#include <stdio.h>
#include "platform.h"
#include "xbasic_types.h"
#include "xstatus.h"
#include "xparameters.h"
#include "xspi.h"
void SPIini(void);
void pause(void);
XSpi mySPI;
int main()
{
init_platform();
print("SPI Test\n\r");
pause();
Xuint8 inBuffer[4] = {0x00, 0x00, 0x00, 0x00};
Xuint8 outBuffer[4] = {0x00, 0xAA, 0xFF, 0xAA};
XStatus status = XST_SUCCESS;
SPIini();
for(Xuint8 i=0; i<100; i++) {
/* initialization */
status = XSpi_Transfer(&mySPI, outBuffer, inBuffer, 2);
switch(status)
{
case XST_SUCCESS: print("Status: Erfolgreich gesendet."); break;
case XST_DEVICE_IS_STOPPED: print("Status: Device stopped\n\r"); break;
case XST_DEVICE_BUSY: print("Status: Device busy\n\r"); break;
case XST_SPI_NO_SLAVE: print("Status: Device no slave\n\r"); break;
}
pause();
}
cleanup_platform();
return 0;
}
void SPIini(void)
{
XStatus status = XST_SUCCESS;
status = XSpi_Initialize(&mySPI, XPAR_TEST_SPI_DEVICE_ID);
switch(status)
{
case XST_SUCCESS: print("Status: Erfolgreich initialisiert\n\r"); break;
case XST_DEVICE_IS_STARTED: print("Status: Device is started\n\r"); break;
case XST_DEVICE_NOT_FOUND: print("Status: Device not found\n\r"); break;
}
Xuint32 options = XSP_MASTER_OPTION;
status = XSpi_SetOptions(&mySPI, options);
switch(status)
{
case XST_SUCCESS: print("Status: Erfolgreich option gesetzt\n\r"); break;
case XST_DEVICE_BUSY: print("Status: Device busy\n\r"); break;
case XST_SPI_SLAVE_ONLY: print("Status: Slave only\n\r"); break;
}
XSpi_SetSlaveSelect(&mySPI, 1);
XSpi_Start(&mySPI);
}
void pause(void)
{
for(int i=0; i<CPU_FREQ; i++);
}
I'm using Xilinx EDK 11.5 with xps_spi core version 2.01b. Core is
correctly integrated in my SDK, I can see the signals on my DSO.
Everything seems to be allright. But I've got a little software problem.
In SDK I transfer my data with the function "XSpi_Transfer(&mySPI,
outBuffer, inBuffer, 2)" (see above). It works exactly one time and I
get XST_SCCUSS back. But if I call XSpi_Transfer again, I get
XST_DEVICE_BUSY back.
My program do the following steps:
1.) initalize SPI (function "XSpi_Initialize")
2.) set options (function "XSpi_SetOptions")
3.) select slave (function "XSpi_SetSlaveSelect")
4.) start SPI (function "XSpi_Start")
5.) transfer data (function "XSpi_Transfer")
Every function return XST_SUCCESS, but not Xspi_transfer when I call it
the second time.
So my question? Is there any bug in the core or have I forgot something?
I hope someone can help me. I tried to google, found a similar problem,
but no solution.
Thanks a lot,
Tobias
C-Code:
#include <stdio.h>
#include "platform.h"
#include "xbasic_types.h"
#include "xstatus.h"
#include "xparameters.h"
#include "xspi.h"
void SPIini(void);
void pause(void);
XSpi mySPI;
int main()
{
init_platform();
print("SPI Test\n\r");
pause();
Xuint8 inBuffer[4] = {0x00, 0x00, 0x00, 0x00};
Xuint8 outBuffer[4] = {0x00, 0xAA, 0xFF, 0xAA};
XStatus status = XST_SUCCESS;
SPIini();
for(Xuint8 i=0; i<100; i++) {
/* initialization */
status = XSpi_Transfer(&mySPI, outBuffer, inBuffer, 2);
switch(status)
{
case XST_SUCCESS: print("Status: Erfolgreich gesendet."); break;
case XST_DEVICE_IS_STOPPED: print("Status: Device stopped\n\r"); break;
case XST_DEVICE_BUSY: print("Status: Device busy\n\r"); break;
case XST_SPI_NO_SLAVE: print("Status: Device no slave\n\r"); break;
}
pause();
}
cleanup_platform();
return 0;
}
void SPIini(void)
{
XStatus status = XST_SUCCESS;
status = XSpi_Initialize(&mySPI, XPAR_TEST_SPI_DEVICE_ID);
switch(status)
{
case XST_SUCCESS: print("Status: Erfolgreich initialisiert\n\r"); break;
case XST_DEVICE_IS_STARTED: print("Status: Device is started\n\r"); break;
case XST_DEVICE_NOT_FOUND: print("Status: Device not found\n\r"); break;
}
Xuint32 options = XSP_MASTER_OPTION;
status = XSpi_SetOptions(&mySPI, options);
switch(status)
{
case XST_SUCCESS: print("Status: Erfolgreich option gesetzt\n\r"); break;
case XST_DEVICE_BUSY: print("Status: Device busy\n\r"); break;
case XST_SPI_SLAVE_ONLY: print("Status: Slave only\n\r"); break;
}
XSpi_SetSlaveSelect(&mySPI, 1);
XSpi_Start(&mySPI);
}
void pause(void)
{
for(int i=0; i<CPU_FREQ; i++);
}