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 |
Memory copy function.
dst | Pointer to destination buffer. |
src | Pointer to source buffer. |
count | Bytes to be copied. |
Referenced by qspi_flash_access_memory(), and qspi_flash_execute_command().
|
inlinestatic |
Disable waiting RX_EMPTY before transfer starts.
qspi | Pointer to an QSPI instance. |
Referenced by qspi_set_config().
|
inlinestatic |
Enable waiting RX_EMPTY before transfer starts.
qspi | Pointer to an QSPI instance. |
Referenced by qspi_set_config().
|
inlinestatic |
Ends ongoing transfer by releasing CS of QSPI peripheral.
qspi | Pointer 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.
qspid | Pointer to an Qspi instance. |
read_write | Flag to indicate read/write QSPI memory access |
scramble_flag | Enable or disable scramble on QSPI |
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 | ||
) |
Send instruction over QSPI with data.
Functionality API – Serial Memory Mode.
qspid | Pointer to an Qspi instance. |
read_write | Flag to indicate read/write QSPI memory access |
References _qspi_memcpy(), qspi_inst_frame_t::addr, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_addr_en, qspi_inst_frame_t::_qspiinst_frame::bm, 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_READ_ACCESS, qspi_set_instruction_addr(), qspi_set_instruction_code(), qspi_set_instruction_frame(), 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_exec_command().
void qspi_get_config_default | ( | struct qspi_config_t * | qspi_config | ) |
Get default config.
qspi_config | Pointer to an qspi_config_t struct. |
References qspi_config_t::baudrate, qspi_config_t::bits_per_transfer, qspi_config_t::clock_phase, qspi_config_t::clock_polarity, qspi_config_t::csmode, qspi_config_t::delay_between_ct, qspi_config_t::loopback_en, mem_mode, qspi_config_t::min_delay_qcs, QSPI_LASTXFER, qspi_config_t::scrambling_en, qspi_config_t::scrambling_random_value_dis, qspi_config_t::scrambling_user_key, qspi_config_t::serial_memory_mode, qspi_config_t::transfer_delay, and qspi_config_t::wait_data_for_transfer.
Referenced by s25fl1xx_initialize().
enum status_code qspi_initialize | ( | Qspi * | qspi, |
struct qspi_config_t * | qspi_config | ||
) |
Config qspi according the config struct.
pQspi | Pointer to an Qspi instance. |
qspi_config | Pointer to an qspi_config_t struct. |
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.
qspi | Pointer to a Qspi instance. |
us_data | Pointer to read data. |
num_of_bytes | Read data numbers. |
References ERR_TIMEOUT, OPERATION_IN_PROGRESS, qspi_read_spi(), qspi_write_spi(), status, STATUS_ERR_BUSY, and STATUS_OK.
|
inlinestatic |
Read QSPI RDR register for SPI mode.
qspi | Pointer to an Qspi instance. |
Referenced by qspi_read().
|
inlinestatic |
Set the number of data bits transferred.
qspi | Pointer to an QSPI instance. |
bits | Bits per transfer. |
Referenced by qspi_set_config().
|
inlinestatic |
Set Chip Select Mode.
qspi | Pointer to an QSPI instance. |
csmode | Chip select mode to be set. |
Referenced by qspi_set_config().
|
static |
Config qspi according the config struct.
pQspi | Pointer to an Qspi instance. |
qspi_config | Pointer to an qspi_config_t struct. |
References qspi_config_t::baudrate, qspi_config_t::bits_per_transfer, qspi_config_t::clock_phase, qspi_config_t::clock_polarity, qspi_config_t::csmode, qspi_config_t::delay_between_ct, qspi_config_t::loopback_en, mem_mode, qspi_config_t::min_delay_qcs, qspi_disable_loopback(), qspi_disable_wait_data_read_before_transfer(), qspi_enable_loopback(), qspi_enable_wait_data_read_before_transfer(), qspi_set_baudrate(), qspi_set_bits_per_transfer(), qspi_set_chip_select_mode(), qspi_set_clock_phase(), qspi_set_clock_polarity(), qspi_set_delay_between_consecutive_transfers(), qspi_set_memory_mode(), qspi_set_minimum_inactive_qcs_delay(), qspi_set_scrambing_key(), qspi_set_scrambling_mode(), qspi_set_spi_mode(), qspi_set_transfer_delay(), qspi_config_t::scrambling_en, qspi_config_t::scrambling_random_value_dis, qspi_config_t::scrambling_user_key, qspi_config_t::serial_memory_mode, status, STATUS_OK, qspi_config_t::transfer_delay, and qspi_config_t::wait_data_for_transfer.
Referenced by qspi_initialize().
|
inlinestatic |
Set qspi delay between consecutive transfers.
qspi | Pointer to a Qspi instance. |
uc_dlycs | Time to be delay. |
Referenced by qspi_set_config().
void qspi_set_instruction_frame | ( | Qspi * | qspi, |
struct qspi_inst_frame_t | instruction_frame | ||
) |
Set qspi instruction frame.
qspi | Pointer to a Qspi instance. |
instruction_frame | Frame to be set. |
References qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_addr_en, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_addr_len, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_continues_read, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_data_en, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_dummy_cycles, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_inst_en, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_opt_en, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_opt_len, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_tfr_type, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_width, qspi_inst_frame_t::_qspiinst_frame::bm, and qspi_inst_frame_t::inst_frame.
Referenced by qspi_flash_access_memory(), and qspi_flash_execute_command().
|
inlinestatic |
Set QSPI to Memory mode.
qspi | Pointer to an QSPI instance. |
Referenced by qspi_set_config().
|
inlinestatic |
Set qspi minimum inactive QCS delay.
qspi | Pointer to a Qspi instance. |
uc_dlybct | Time to be delay. |
Referenced by qspi_set_config().
|
inlinestatic |
Set QSPI to SPI mode (Master mode only).
qspi | Pointer to an QSPI instance. |
Referenced by qspi_set_config().
|
inlinestatic |
Set qspi clock transfer delay.
qspi | Pointer to a Qspi instance. |
uc_dlybs | Delay 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.
qspi | Pointer to a Qspi instance. |
us_data | Pointer to data to be written. |
num_of_bytes | Write data numbers. |
References ERR_TIMEOUT, OPERATION_IN_PROGRESS, qspi_write_spi(), status, STATUS_ERR_BUSY, and STATUS_OK.
|
inlinestatic |
Write to QSPI Tx register in SPI mode.
qspi | Pointer to an Qspi instance. |
w_data | Data to transmit |
Send data
Referenced by qspi_read(), and qspi_write().