Solved! Go to Solution.
I found the answer, you have to use the IO_IOCTL_QSPI_SET_TRANSFER_MODE.
Try setting the transfer mode:
/*
** QSPI Transfer modes
*/
#define QSPI_TRANSFER_MODE_1 1 // Active low; QSPI_CLK transitions middle of bit timing
#define QSPI_TRANSFER_MODE_2 2 // Active high; QSPI_CLK transitions middle of bit timing
#define QSPI_TRANSFER_MODE_3 3 // Active low; QSPI_CLK transitions begining of bit timing
#define QSPI_TRANSFER_MODE_4 4 // Active high; QSPI_CLK transitions begining of bit timing
This is clearly the wrong way of modifiying the transfer modes, whats the correct way?
How do I find out exactly how to set / clear all the bits in the qspi header? Obviously most of them are not flags as they overlap, so there must be various ways of setting those bits... I know if I wrote the header file i would say how each bit is actually used (although I am sure its obvious to some)...
Pa
...
//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);
//Show Baud rate setting
ioctl(SPI_fd, IO_IOCTL_SERIAL_GET_BAUD, ¶m);
printf (" QSPI freq is no %dHz.\n", param);
//Get the current flags
param = 0;
ioctl(SPI_fd, IO_IOCTL_GET_FLAGS, ¶m);
printf("IO_CTLFLAGS = %X\n", param); //param = 0x21B
//Mask out any current transfer modes (As it turns out MASTER_MODE has bit 0 and 1 set which are the transfer mode bits
param &= (~(QSPI_TRANSFER_MODE_1 | QSPI_TRANSFER_MODE_2 | QSPI_TRANSFER_MODE_3 | QSPI_TRANSFER_MODE_4));
printf("Param with no modes = %X\n", param); //Param 0x218
param |= (QSPI_TRANSFER_MODE_1); //Tried this with _1, _2, _3 and 4, and nothing changes
printf("Param single = %X\n", param); //Param 0x219
ioctl(SPI_fd, IO_IOCTL_SET_FLAGS, ¶m);
//Read out the Paramters to make sure they are what we expect
param = 0;
ioctl(SPI_fd, IO_IOCTL_GET_FLAGS, ¶m);
printf("IO_CTLFLAGS returned = %X\n", param); //PAram 0x219
//This line needs to spit data out with CS asserted to reset the slaves SPI state machine!
if(write(SPI_fd, &byte, 1) == IO_ERROR) printf("\nERROR: QSPI WRITE FAILED in SPI_Init.\n");
..
Thanks in advance
Carl
I found the answer, you have to use the IO_IOCTL_QSPI_SET_TRANSFER_MODE.