Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Quad Serial Peripheral Interface (QSPI)

See sam_qspi_quickstart.

The Quad SPI Interface (QSPI) is a synchronous serial data link that provides communication with external devices in Master mode. The QSPI can be used in SPI mode to interface to serial peripherals (such as ADCs, DACs, LCD controllers, CAN controllers and sensors), or in Serial Memory mode to interface to serial Flash memories. The QSPI allows the system to execute code directly from a serial Flash memory (XIP) without code shadowing to RAM. The serial Flash memory mapping is seen in the system as other memories (ROM, SRAM, DRAM, embedded Flash memory, etc.). With the support of the Quad SPI protocol, the QSPI allows the system to use high-performance serial Flash memories which are small and inexpensive, in place of larger and more expensive parallel Flash memories.

Modules

 Quick Start Guide(s)
 In this section you can find a list of all Quick Start guides related to the Quad Serial Peripheral Interface (QSPI).
 

Functions

static void _qspi_memcpy (uint8_t *dst, uint8_t *src, uint32_t count)
 Memory copy function. More...
 
static void qspi_disable_wait_data_read_before_transfer (Qspi *qspi)
 Disable waiting RX_EMPTY before transfer starts. More...
 
static void qspi_enable_wait_data_read_before_transfer (Qspi *qspi)
 Enable waiting RX_EMPTY before transfer starts. More...
 
static void qspi_end_transfer (Qspi *qspi)
 Ends ongoing transfer by releasing CS of QSPI peripheral. More...
 
enum status_code qspi_flash_access_memory (struct qspid_t *qspid, enum qspi_access read_write, uint8_t scramble_flag)
 Writes or reads the QSPI memory (0x80000000) to trasmit or receive data from Flash memory. More...
 
enum status_code qspi_flash_execute_command (struct qspid_t *qspid, enum qspi_access read_write)
 Send instruction over QSPI with data. More...
 
void qspi_get_config_default (struct qspi_config_t *qspi_config)
 Get default config. More...
 
enum status_code qspi_initialize (Qspi *qspi, struct qspi_config_t *qspi_config)
 Config qspi according the config struct. More...
 
enum status_code qspi_read (Qspi *qspi, uint16_t *us_data, uint32_t num_of_bytes)
 Qspi read data. More...
 
static uint16_t qspi_read_spi (Qspi *qspi)
 Read QSPI RDR register for SPI mode. More...
 
static void qspi_set_bits_per_transfer (Qspi *qspi, uint32_t bits)
 Set the number of data bits transferred. More...
 
static void qspi_set_chip_select_mode (Qspi *qspi, uint32_t csmode)
 Set Chip Select Mode. More...
 
static enum status_code qspi_set_config (Qspi *qspi, struct qspi_config_t *qspi_config)
 Config qspi according the config struct. More...
 
static void qspi_set_delay_between_consecutive_transfers (Qspi *qspi, uint32_t uc_dlycs)
 Set qspi delay between consecutive transfers. More...
 
void qspi_set_instruction_frame (Qspi *qspi, struct qspi_inst_frame_t instruction_frame)
 Set qspi instruction frame. More...
 
static void qspi_set_memory_mode (Qspi *qspi)
 Set QSPI to Memory mode. More...
 
static void qspi_set_minimum_inactive_qcs_delay (Qspi *qspi, uint8_t uc_dlybct)
 Set qspi minimum inactive QCS delay. More...
 
static void qspi_set_spi_mode (Qspi *qspi)
 Set QSPI to SPI mode (Master mode only). More...
 
static void qspi_set_transfer_delay (Qspi *qspi, uint8_t uc_dlybs)
 Set qspi clock transfer delay. More...
 
enum status_code qspi_write (Qspi *qspi, uint16_t *us_data, uint32_t num_of_bytes)
 Qspi write data. More...
 
static void qspi_write_spi (Qspi *qspi, uint16_t w_data)
 Write to QSPI Tx register in SPI mode. More...
 

static void _qspi_memcpy ( uint8_t *  dst,
uint8_t *  src,
uint32_t  count 
)
static

Memory copy function.

Parameters
dstPointer to destination buffer.
srcPointer to source buffer.
countBytes to be copied.

Referenced by qspi_flash_access_memory(), and qspi_flash_execute_command().

static void qspi_disable_wait_data_read_before_transfer ( Qspi *  qspi)
inlinestatic

Disable waiting RX_EMPTY before transfer starts.

Parameters
qspiPointer to an QSPI instance.

Referenced by qspi_set_config().

static void qspi_enable_wait_data_read_before_transfer ( Qspi *  qspi)
inlinestatic

Enable waiting RX_EMPTY before transfer starts.

Parameters
qspiPointer to an QSPI instance.

Referenced by qspi_set_config().

static void qspi_end_transfer ( Qspi *  qspi)
inlinestatic

Ends ongoing transfer by releasing CS of QSPI peripheral.

Parameters
qspiPointer to an Qspi instance.

Referenced by qspi_flash_access_memory(), and qspi_flash_execute_command().

enum status_code qspi_flash_access_memory ( struct qspid_t qspid,
enum qspi_access  read_write,
uint8_t  scramble_flag 
)

Writes or reads the QSPI memory (0x80000000) to trasmit or receive data from Flash memory.

Parameters
qspidPointer to an Qspi instance.
read_writeFlag to indicate read/write QSPI memory access
scramble_flagEnable or disable scramble on QSPI
Returns
Returns 1 if At least one instruction end has been detected since the last read of QSPI_SR.; otherwise returns 0.

References _qspi_memcpy(), qspi_inst_frame_t::addr, qspi_buffer_t::data_rx, qspi_buffer_t::data_tx, qspi_inst_frame_t::inst_frame, OPERATION_IN_PROGRESS, qspid_t::qspi_buffer, QSPI_CMD_ACCESS, qspid_t::qspi_command, qspi_end_transfer(), qspid_t::qspi_frame, qspi_get_inst_frame(), qspid_t::qspi_hw, qspi_set_instruction_code(), qspi_set_instruction_frame(), qspi_set_scrambling_mode(), QSPI_WRITE_ACCESS, qspi_buffer_t::rx_data_size, status, STATUS_OK, qspi_buffer_t::tx_data_size, and qspi_inst_frame_t::_qspiinst_frame::val.

Referenced by s25fl1xx_memory_access().

enum status_code qspi_flash_execute_command ( struct qspid_t qspid,
enum qspi_access  read_write 
)
enum status_code qspi_initialize ( Qspi *  qspi,
struct qspi_config_t qspi_config 
)

Config qspi according the config struct.

Parameters
pQspiPointer to an Qspi instance.
qspi_configPointer to an qspi_config_t struct.
Returns
status QSPI initialize result.

Configure an QSPI peripheral.

References qspi_disable(), qspi_enable(), qspi_reset(), qspi_set_config(), status, and STATUS_OK.

Referenced by s25fl1xx_initialize().

enum status_code qspi_read ( Qspi *  qspi,
uint16_t *  us_data,
uint32_t  num_of_bytes 
)

Qspi read data.

Parameters
qspiPointer to a Qspi instance.
us_dataPointer to read data.
num_of_bytesRead data numbers.
Returns
status Read option result.

References ERR_TIMEOUT, OPERATION_IN_PROGRESS, qspi_read_spi(), qspi_write_spi(), status, STATUS_ERR_BUSY, and STATUS_OK.

static uint16_t qspi_read_spi ( Qspi *  qspi)
inlinestatic

Read QSPI RDR register for SPI mode.

Parameters
qspiPointer to an Qspi instance.
Returns
status Data value read from QSPI.

Referenced by qspi_read().

static void qspi_set_bits_per_transfer ( Qspi *  qspi,
uint32_t  bits 
)
inlinestatic

Set the number of data bits transferred.

Parameters
qspiPointer to an QSPI instance.
bitsBits per transfer.

Referenced by qspi_set_config().

static void qspi_set_chip_select_mode ( Qspi *  qspi,
uint32_t  csmode 
)
inlinestatic

Set Chip Select Mode.

Parameters
qspiPointer to an QSPI instance.
csmodeChip select mode to be set.

Referenced by qspi_set_config().

static void qspi_set_delay_between_consecutive_transfers ( Qspi *  qspi,
uint32_t  uc_dlycs 
)
inlinestatic

Set qspi delay between consecutive transfers.

Parameters
qspiPointer to a Qspi instance.
uc_dlycsTime to be delay.

Referenced by qspi_set_config().

static void qspi_set_memory_mode ( Qspi *  qspi)
inlinestatic

Set QSPI to Memory mode.

Parameters
qspiPointer to an QSPI instance.

Referenced by qspi_set_config().

static void qspi_set_minimum_inactive_qcs_delay ( Qspi *  qspi,
uint8_t  uc_dlybct 
)
inlinestatic

Set qspi minimum inactive QCS delay.

Parameters
qspiPointer to a Qspi instance.
uc_dlybctTime to be delay.

Referenced by qspi_set_config().

static void qspi_set_spi_mode ( Qspi *  qspi)
inlinestatic

Set QSPI to SPI mode (Master mode only).

Parameters
qspiPointer to an QSPI instance.

Referenced by qspi_set_config().

static void qspi_set_transfer_delay ( Qspi *  qspi,
uint8_t  uc_dlybs 
)
inlinestatic

Set qspi clock transfer delay.

Parameters
qspiPointer to a Qspi instance.
uc_dlybsDelay before QSCK.

Referenced by qspi_set_config().

enum status_code qspi_write ( Qspi *  qspi,
uint16_t *  us_data,
uint32_t  num_of_bytes 
)

Qspi write data.

Parameters
qspiPointer to a Qspi instance.
us_dataPointer to data to be written.
num_of_bytesWrite data numbers.
Returns
status Write option result.

References ERR_TIMEOUT, OPERATION_IN_PROGRESS, qspi_write_spi(), status, STATUS_ERR_BUSY, and STATUS_OK.

static void qspi_write_spi ( Qspi *  qspi,
uint16_t  w_data 
)
inlinestatic

Write to QSPI Tx register in SPI mode.

Parameters
qspiPointer to an Qspi instance.
w_dataData to transmit

Send data

Referenced by qspi_read(), and qspi_write().