Hi,
I havnt had any problems with my SPI drivers, though I didnt really play with the demo so much.
Here is some code copied out of my SPI driver which is based on the example supplied
//-----------------------------------------------------------------------------------------------------------------------
//Compile time tests
#if ! BSPCFG_ENABLE_QSPI
#error This application requires BSPCFG_ENABLE_QSPI defined non-zero in user_config.h. Please recompile kernel with this option.
#endif
//Global to driver file
static FILE_PTR SPI_fd; //CDN10072009 used to store the file pointer to the QSPI driver
const char SLIC_SPI_PORT[] = "qspi:"; //CDN16072009
uchar SPI_Init(void){
uchar byte = 0;
uint_32 param = 0;
//Open SPI
SPI_fd = fopen(SLIC_SPI_PORT, (pointer)(QSPI_DEVICE_MASTER_MODE));
if (SPI_fd == NULL)
{
printf("\n Failed to open the SPI Controller: QSPI ALLOCATION ERROR...");
return FALSE;
}
// Set QSPI Baud rate
param = 4000000;
printf ("\nChanging the Baud frequency to 4000000Hz...");
ioctl(SPI_fd, IO_IOCTL_SERIAL_SET_BAUD, ¶m);
// Display current Baud
ioctl(SPI_fd, IO_IOCTL_SERIAL_GET_BAUD, ¶m);
printf (" QSPI freq is now %dHz.\n", param);
//Set transfer modes
param = (QSPI_TRANSFER_MODE_2);
ioctl(SPI_fd, IO_IOCTL_QSPI_SET_TRANSFER_MODE, ¶m);
//Start with CS in the high state as it is no preset to high.
param = QSPI_CHIP_SELECT_SET_1;
ioctl(SPI_fd, IO_IOCTL_QSPI_SET_CHIP_SELECT_STATE, ¶m);
return TRUE;
}
void SPI_Write_Byte(uchar){
//write to SPI, CS is handled automatically.
if(write(SPI_fd, &byte, 1) == IO_ERROR) printf("\nERROR: QSPI WRITE
FAILED in SPI_Init.\n");
}
byte SPI_Read_Byte(void){
if(read(SPI_fd, &byte, 1) == IO_ERROR) printf("\nERROR: QSPI WRITE FAILED.\n");
printf("SPI DOut: %X\n", byte);
return byte;
}
Also, be sure to re compilie the BSP/PSP with the BSPCFG_ENABLE_QSPI otherwise it wont work
To test that the SPI is working, you can simply tie the SDI pin to ground and the result of the above code will print 0x00, tie it to 3.3V and you will see 0xFF.
Message Edited by CarlFST60L on 2009-07-22 09:23 AM
Message Edited by CarlFST60L on 2009-07-22 09:26 AM