NetBurner 3.5.0
PDF Version
 
MCF5441x (QSPI)

Topics

 QSPI state
 

Classes

struct  QSPI_Record
 This struct contains the major variables/configurations used for a QSPI transfer. More...
 

Functions

uint8_t QSPIInit (uint32_t baudRateInBps=2000000, uint8_t transferSizeInBits=8, uint8_t peripheralChipSelects=0x0F, uint8_t chipSelectPolarity=1, uint8_t clockPolarity=0, uint8_t clockPhase=1, BOOL doutHiz=TRUE, uint8_t csToClockDelay=0, uint8_t delayAfterTransfer=0)
 Initialize Queued Serial Peripheral Interface (QSPI)
 
uint8_t QSPIStart (puint8_t transmitBufferPtr, volatile uint8_t *receiveBufferPtr, uint32_t byteCount, OS_SEM *finishedSem=NULL)
 Start QSPI Data Transfer.
 
BOOL QSPIdone (void)
 Can be called after QSPIStart(). Returns TRUE when transfer is complete. This is an alternative to using a semaphore.
 

Detailed Description

#include< qspi.h >

Supported platforms:

Note
The SPI interface modules (up to 4 depending on the platform) on the MCF5441x processor are termed DMA SPI (DSPI). Earlier ColdFire processors had a single SPI with a queue, and were termed QSPI. This header file is here as a guide for customers using earlier ColdFire processors to make porting code easier. However, we highly recommend using the DSPI driver instead. The calls are nearly identical.

Introduction
The Queued Serial Peripheral Interface (QSPI) is a full duplex synchronous serial data link that operates in master/slave mode. The QSPI is similar to SPI, but also provided a hardware queue for transmit data, receive data, and commands. Up to 16 transfers can be queued at one time, eliminating CPU intervention between transfers. The NetBurner QSPI driver and API provide interrupt driven QSPI communication.

The QSPI specification allows for sharing the QSPI bus with multiple devices. However, when designing your system you must consider what devices are connected and the desired throughput. For example, if you are using the Embedded Flash File System (EFFS) with external SD flash cards, or the WiFi module, they will require exclusive use of the QSPI.

The QSPI uses the following hardware signals:

Programming tip: If you are new to QSPI and require a chip select for your device, we recommend using a GPIO signal during initial development to simplify your application code. Once proper operation has been achieved, modify the code to use the QSPI chip selects.

QSPI Configuration and Initialization
Use of the QSPI requires:

  1. Identify which pins on your NetBurner device provide primary or secondary QSPI functionality. Use the NetBurner Pins class functions to configure these pins for QSPI operation.
  2. Single task applications: you can choose to call the QSPIdone() function to determine when the QSPI transfer is complete, or use a semaphore and pend for completion.
  3. Multi-task applications: If your application has more than one task that will access the QSPI, your must create a semaphore to control access to the QSPI resource.
  4. Initialize the QSPI with the QSPIInit() function.
  5. When you have data to send, or want to read data from the QSPI slave device, call the QSPIStart() function to initiate the data transfer.
  6. The semaphore will post when the data transfer is complete.

Function Documentation

◆ QSPIdone()

BOOL QSPIdone ( void )
inline

#include <qspi.h>

Can be called after QSPIStart(). Returns TRUE when transfer is complete. This is an alternative to using a semaphore.

Return values
TRUEWhen transfer is complete
FALSEOn error
See also
QSPIInit()
QSPIStart()

Can be called after QSPIStart(). Returns TRUE when transfer is complete. This is an alternative to using a semaphore.

Note that the 'Q' stands for Queued SPI

Returns
true if DSPI is finished, false if active

◆ QSPIInit()

uint8_t QSPIInit ( uint32_t baudRateInBps = 2000000,
uint8_t transferSizeInBits = 8,
uint8_t peripheralChipSelects = 0x0F,
uint8_t chipSelectPolarity = 1,
uint8_t clockPolarity = 0,
uint8_t clockPhase = 1,
BOOL doutHiz = TRUE,
uint8_t csToClockDelay = 0,
uint8_t delayAfterTransfer = 0 )
inline

#include <qspi.h>

Initialize Queued Serial Peripheral Interface (QSPI)

Notes: (3) Transfers > 8 must be word aligned (4) Select based on chipSelectPolarity (5) 0 data captured leading edge of QSPI_CLK, changed following edge. (6) 1 data changed leading edge of QSPI_CLK, captured following edge. (7) 0 default is 1/2 QSPI_CLK or see MFCXXXX reference manual (8) 0 default is 8192/(system clock / 2) see MFCXXXX reference manual

Parameters
baudRateInBpsMaximum requested baud rate in bits per second. The maximum possible baud rate is determined by the system clock. The function will select the highest possible baud rate if the specified value cannot be achieved.
transferSizeInBitsSize of data values to be transferred. Values can be 8, 16 or 32 bits. Note that 16 and 32 bit size values must be word (16-bit) aligned (16-bit).
peripheralChipSelectsPeripheral chip select drive level. Used to select an external device for serial data transfer. More than one chip select may be active at once, and more than one device can be connected to each chip select. Bits 3-0 map directly to QSPI_CS[3:0], respectively. For each bit:
  • 0 = Chip select is 0 during a transfer.
  • 1 = Chip select is 1 during a transfer.
chipSelectPolarityPeripheral chip select inactive level (no transfer in progress). Applies to all chip selects.
  • 0 = 0 when inactive
  • 1 = 1 when inactive
clockPolarityClock polarity:
  • 0 = The inactive state value of QSPI_CLK is logic level 0.
  • 1 = The inactive state value of QSPI_CLK is logic level 1.
clockPhaseClock phase:
  • 0 = Data captured on the leading edge of QSPI_CLK and changed on the following edge of QSPI_CLK.
  • 1 = Data changed on the leading edge of QSPI_CLK and captured on the following edge of QSPI_CLK.
doutHizData output high impedance enable. Selects QSPI_DOUT mode of operation.
  • 0 = Default value after reset. QSPI_DOUT is actively driven between transfers.
  • 1 = QSPI_DOUT is high impedance between transfers.
csToClockDelayQCD, QSPICLK delay. When the DSCK bit in the command RAM is set this field determines the length of the delay from assertion of the chip selects to valid QSPI_CLK transition.
delayAfterTransferDelay after transfer. When the DT bit in the command RAM is set this field determines the length of delay after the serial transfer.
Returns
groupQspiState
See also
QSPIInit()
QSPIStart()

Initialize Queued Serial Peripheral Interface (QSPI)

Note that the 'Q' stands for Queued SPI

Will use the default SPI module, 0.

  • If configured for 8 bits per transfer then the data must be uint8_t aligned
  • If configured for > than 8 bits per transfer then the data must be uint16_t aligned
  • If configured for > than 16 bits per transfer then the data must be uint32_t aligned
  • If either RX or TX pointer is assigned 'null' then that communication direction will not occur.
  • If DSPI_Finished points to a semaphore, then the DSPI will POST to it when the transfer is complete.
  • The semaphore is optional, but it can increase efficiency.
Parameters
baudRateInBpsMaximum baud rate requested
transferSizeInBitsNumber of bits per transfer: 8, 16 or 32
peripheralChipSelectsSPI chip selects to use for transfer
chipSelectPolarity0 = inactive logic level low, 1 = high
clockPolarity0 = inactive logic level low, 1 = high
clockPhase0 = data captured leading edge clock, changed following edge. 1 = data changed leading edge clock, captured following edge.
doutHizData output high impedance between transfers
csToClockDelayDelay from chip select to valid clock (default is 0)
delayAfterTransferChip select mode spiChipSelect
Returns
The current state of the SPI bus dspiState

◆ QSPIStart()

uint8_t QSPIStart ( puint8_t transmitBufferPtr,
volatile uint8_t * receiveBufferPtr,
uint32_t byteCount,
OS_SEM * finishedSem = NULL )
inline

#include <qspi.h>

Start QSPI Data Transfer.

Parameters
transmitBufferPtrPointer to the buffer to use in the transfer. Specify NULL for receive only.
receiveBufferPtrPointer to buffer to store received data. NULL for transmit only.
byteCountNumber of bytes to send or receive. If the data size is greater than 8-bit, you must provide the total number of bytes.
finishedSemPointer to preinitialized semaphore to post to when transfer is complete. A value of NULL disables the semaphore function.
Returns
groupQspiState
See also
QSPIInit()
QSPIdone()

Start QSPI Data Transfer.

Note that the 'Q' stands for Queued SPI

  • If configured for 8 bits per transfer then the data must be uint8_t aligned
  • If configured for > than 8 bits per transfer then the data must be uint16_t aligned
  • If configured for > than 16 bits per transfer then the data must be uint32_t aligned
  • If either RX or TX pointer is assigned 'null' then that communication direction will not occur.
  • If DSPI_Finished points to a semaphore, then the DSPI will POST to it when the transfer is complete.
  • The semaphore is optional, but it can increase efficiency.
Parameters
transmitBufferPtrPointer to the buffer containing the data to transmit
receiveBufferPtrPointer to the buffer to store the received data
byteCountNumber of bytes to transmit
finishedSemOptional semaphore to post to when finished
Returns
The current state of the SPI bus dspiState