API Reference#

This library can be used to instantiate and read from a Quad SPI flash I/O interface on XCORE.

Initialization API#

The following structures and functions are used to initialize a qspi_flash_fast_read peripheral instance.

void qspi_flash_fast_read_init(qspi_fast_flash_read_ctx_t *ctx, xclock_t clock_block, port_t cs_port, port_t sclk_port, port_t sio_port, qspi_fast_flash_read_transfer_mode_t mode, uint8_t divide)#

Implements a qspi_flash_fast_read device.

Only supported for use with flash parts with 0xEB Fast Quad read instruction with: Cycles Data Transfer IO 8 0xEB SPI 6 3 byte address QSPI 6 Dummy QSPI (note may be mode byte + 2 dummy bytes) x Data read QSPI

Parameters:
  • ctx – A pointer to the qspi_flash_fast_read context to initialize.

  • clock_block – The clock block that will get configured for use with sclk.

  • cs_port – The chip select port. Must be a 1-bit port.

  • sclk_port – The SCLK port. Must be a 1-bit port.

  • sio_port – The SIO port. Must be a 4-bit port.

  • mode – The transfer mode to use for port reads. Invalid values will default to qspi_fast_flash_read_transfer_raw

  • divide – The divisor to use for QSPI SCLK. Must be between 3 and 6 inclusive. SCLK frequency will be set to CORE_CLOCK / (2 * divide) CORE CLOCK 600MHz 800MHz CLK_DIVIDE SCLK FREQ 3 100MHz 133MHz 4 75MHz 100MHz 5 60MHz 80MHz 6 50MHz 66MHz Values less than 3 will be implicity set to 3. Values greater than 6 will be implicity set to 6

Core API#

The following functions are the core qspi_flash_fast_read driver functions that are used after it has been initialized.

enum qspi_fast_flash_read_transfer_mode_t#

Transfer modes for fast read operations.

Values:

enumerator qspi_fast_flash_read_transfer_raw#

Do not nibble swap port ins

enumerator qspi_fast_flash_read_transfer_nibble_swap#

Nibble swap port ins

typedef struct qspi_flash_fast_read_struct qspi_fast_flash_read_ctx_t#

Type representing a qspi_flash_fast_read context.

uint32_t qspi_flash_fast_read_pattern_expect_default[QFFR_DEFAULT_CAL_PATTERN_BUF_SIZE_WORDS]#

Declaration of array which holds the default calibration pattern.

This pattern was selected to maximize potential EMI and crosstalk.

void qspi_flash_fast_read_setup_resources(qspi_fast_flash_read_ctx_t *ctx)#

Setup and initialize XCORE resources for a qspi_flash_fast_read device.

Parameters:
  • ctx – A pointer to the qspi_flash_fast_read context to use.

int32_t qspi_flash_fast_read_calibrate(qspi_fast_flash_read_ctx_t *ctx, uint32_t addr, uint32_t *expect_buf, uint32_t *scratch_buf, size_t len_words)#

Calibrate port delays and timings for a qspi_flash_fast_read device.

This must be called after qspi_flash_fast_read_init() and qspi_flash_fast_read_setup_resources().

On success qspi_flash_fast_read_apply_calibration() is called implicitly.

Parameters:
  • ctx – A pointer to the qspi_flash_fast_read context to use.

  • addr – The address of the calibration pattern.

  • expect_buf – A pointer to the byte array with the expected calibration pattern.

  • scratch_buf – A pointer to an application provided scratch buffer. This buffer must be at least len_words words. Contents will be overwritten. After this function call the buffer is owned by the application and no longer needed.

  • len_words – The length in words of the calibration pattern

Returns:

0 on success -1 on failure

void qspi_flash_fast_read_apply_calibration(qspi_fast_flash_read_ctx_t *ctx)#

Apply calibration for a qspi_flash_fast_read device.

Parameters:
  • ctx – A pointer to the qspi_flash_fast_read context to use.

void qspi_flash_fast_read(qspi_fast_flash_read_ctx_t *ctx, uint32_t addr, uint8_t *buf, size_t len)#

Perform a flash read with a qspi_flash_fast_read device.

Parameters:
  • ctx – A pointer to the qspi_flash_fast_read context to use.

  • addr – The address to read.

  • buf – A pointer to the byte array to save the received data. This must begin on a 4-byte boundary.

  • len – The number of bytes to input.

void qspi_flash_fast_read_mode_set(qspi_fast_flash_read_ctx_t *ctx, qspi_fast_flash_read_transfer_mode_t mode)#

Set read mode for a qspi_flash_fast_read device.

Parameters:
  • ctx – A pointer to the qspi_flash_fast_read context to use.

  • mode – The transfer mode to set.

qspi_fast_flash_read_transfer_mode_t qspi_flash_fast_read_mode_get(qspi_fast_flash_read_ctx_t *ctx)#

Get read mode for a qspi_flash_fast_read device.

Parameters:
  • ctx – A pointer to the qspi_flash_fast_read context to use.

Returns:

The current configured transfer mode.

void qspi_flash_fast_read_shutdown(qspi_fast_flash_read_ctx_t *ctx)#

Shutdown a qspi_flash_fast_read device.

Resets the XCORE resources for application to use.

Calibration is stored internally for future use.

Parameters:
  • ctx – A pointer to the qspi_flash_fast_read context to use.

QFFR_DEFAULT_CAL_PATTERN_BUF_SIZE_WORDS#

Size in words of the default calibration pattern.

struct qspi_flash_fast_read_struct#
#include <qspi_flash_fast_read.h>

Struct to hold a qspi_flash_fast_read context.

The members in this struct should not be accessed directly.