EZ-USB FX3 Technical Reference Manual, Document Number: 001-76074 Rev. *F 181
Low Performance Peripherals (LPP)
status = CyU3PSpiTransmitWords (buffer, glSpiPageSize);
if (status != CY_U3P_SUCCESS)
{
CyU3PSpiSetSsnLine (CyTrue);
}
CyU3PSpiSetSsnLine (CyTrue);
}
/* Update the parameters */
byteAddress += glSpiPageSize;
buffer += glSpiPageSize;
pageCount --;
CyU3PThreadSleep (10);
}
}
8.5.4 Reads and Writes Using DMA Transfers
A DMA channel (glSpiTxHandle) is created to transfer data to an SPI slave device, and another DMA channel
(glSpiRxHandle) is created to read data from the SPI slave device. Following is the code for performing reads and writes to an
SPI slave using DMA transfers.
CyFxSpiTransfer (uint16_t pageAddress, uint16_t byteCount, uint8_t *buffer, CyBool_t
isRead)
{
CyU3PDmaBuffer_t buf_p;
uint8_t location[4];
uint32_t byteAddress = 0;
uint16_t pageCount = (byteCount / glSpiPageSize);
if ((byteCount % glSpiPageSize) != 0)
{
pageCount ++;
}
buf_p.buffer = buffer;
buf_p.status = 0;
byteAddress = pageAddress * glSpiPageSize;
while (pageCount != 0)
{
location[1] = (byteAddress >> 16) & 0xFF; /* MS byte */
location[2] = (byteAddress >> 8) & 0xFF;
location[3] = byteAddress & 0xFF; /* LS byte */
if (isRead) /* Read */
{
location[0] = 0x03; /* Read command. */
buf_p.size = glSpiPageSize;
buf_p.count = glSpiPageSize;
status = CyFxSpiWaitForStatus ();
CyU3PSpiSetSsnLine (CyFalse);
status = CyU3PSpiTransmitWords (location, 4);
if (status != CY_U3P_SUCCESS)
{