QSPI

[English]

QSPI API Reference

Header File

Functions

bk_err_t bk_qspi_driver_init(void)

Init the QSPI driver.

This API init the resoure common:

  • Init QSPI driver control memory

Attention

1. This API should be called before any other QSPI APIs.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_driver_deinit(void)

Deinit the QSPI driver.

This API free all resource related to QSPI and disable QSPI.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_init(qspi_id_t id, const qspi_config_t *config)

Init the QSPI.

This API init the QSPI:

  • Power up the QSPI

  • Configure the QSPI clock

  • Map the QSPI to dedicated GPIO port

  • Enabel QSPI interrupt

Parameters

config – QSPI parameter settings

Returns

  • BK_OK: succeed

  • BK_ERR_QSPI_NOT_INIT: QSPI driver not init

  • BK_ERR_NULL_PARAM: QSPI config parameter is NULL

  • others: other errors.

bk_err_t bk_qspi_deinit(qspi_id_t id)

Deinit the QSPI.

This API deinit the QSPI:

  • Disable the QSPI interrupt

  • Power down the QSPI

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_command(qspi_id_t id, const qspi_cmd_t *cmd)

Init the QSPI command.

Parameters

cmd – QSPI device command

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_write(qspi_id_t id, const void *data, uint32_t size)

QSPI indirect mode write.

Parameters
  • base_addr – QSPI write address

  • data – QSPI write data

  • size – the size of QSPI write data

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_read(qspi_id_t id, void *data, uint32_t size)

QSPI indirect mode read.

Parameters
  • base_addr – QSPI read address

  • data – QSPI read data

  • size – the size of QSPI read data

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_register_tx_isr(qspi_isr_t isr, void *param)

Register the TX interrupt service routine for QSPI.

Parameters
  • isr – QSPI TX callback

  • param – QSPI TX callback parameter

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_register_rx_isr(qspi_isr_t isr, void *param)

Register the RX interrupt service routine for QSPI.

Parameters
  • isr – QSPI RX callback

  • param – QSPI RX callback parameter

Returns

  • BK_OK: succeed

  • others: other errors.

QSPI PSRAM API Reference

Header File

Functions

bk_err_t bk_qspi_psram_init(qspi_id_t id)

Init the QSPI psram.

Returns

  • BK_OK: succeed

  • BK_ERR_QSPI_NOT_INIT: QSPI driver not init

  • others: other errors.

bk_err_t bk_qspi_psram_deinit(qspi_id_t id)

Deinit the QSPI psram.

Returns

  • BK_OK: succeed

  • BK_ERR_QSPI_NOT_INIT: QSPI driver not init

  • others: other errors.

bk_err_t bk_qspi_psram_enter_quad_mode(qspi_id_t id)

QSPI psram enter quad mode.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_psram_exit_quad_mode(qspi_id_t id)

QSPI psram exit quad mode.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_psram_quad_write(qspi_id_t id)

QSPI psram init quad write.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_psram_single_write(qspi_id_t id)

QSPI psram init single write.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_psram_quad_read(qspi_id_t id)

QSPI psram init quad read.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_psram_single_read(qspi_id_t id)

QSPI psram init single read.

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_psram_write(qspi_id_t id, uint32_t base_addr, const void *data, uint32_t size)

QSPI psram write data.

Parameters
  • base_addr – QSPI write address

  • data – QSPI write data

  • size – the size of QSPI write data

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_qspi_psram_read(qspi_id_t id, uint32_t base_addr, void *data, uint32_t size)

QSPI psram read data.

Parameters
  • base_addr – QSPI read address

  • data – QSPI read data

  • size – the size of QSPI read data

Returns

  • BK_OK: succeed

  • others: other errors.

QSPI API Typedefs

Header File

Structures

struct qspi_driver_t
struct qspi_callback_t

Macros

BK_ERR_QSPI_NOT_INIT

QSPI driver not init

BK_ERR_QSPI_ID_NOT_INIT

QSPI id not init

Type Definitions

typedef void (*qspi_isr_t)(qspi_id_t id, void *param)

QSPI interrupt service routine.

Header File

Structures

struct qspi_config_t

Public Members

qspi_src_clk_t src_clk

QSPI source clock

uint32_t src_clk_div

QSPI source clock divide number

uint32_t clk_div

QSPI controller clock divide number

struct qspi_cmd_t

Public Members

qspi_wire_mode_t wire_mode

wire mode

qspi_work_mode work_mode

work mode

qspi_op_t op

QSPI operation

uint32_t cmd

QSPI command

uint32_t addr

QSPI address

uint32_t dummy_cycle

QSPI dummy cycle

uint32_t data_len

QSPI data length

qspi_device_t device

QSPI slave device

Type Definitions

typedef uint8_t qspi_unit_t

QSPI uint id

Enumerations

enum qspi_id_t

Values:

enumerator QSPI_ID_0

QSPI id 1

enumerator QSPI_ID_MAX

QSPI id max

enum qspi_op_t

Values:

enumerator QSPI_READ

QSPI read operation

enumerator QSPI_WRITE

QSPI write operation

enum qspi_src_clk_t

Values:

enumerator QSPI_SCLK_320M

QSPI source clock 320M

enumerator QSPI_SCLK_480M

QSPI source clock 480M

enum qspi_work_mode

Values:

enumerator MEMORY_MAPPED_MODE
enumerator INDIRECT_MODE
enum qspi_wire_mode_t

Values:

enumerator QSPI_1WIRE

QSPI 1_wire mode, standard SPI

enumerator QSPI_2WIRE

QSPI 2_wire mode, DUAL SPI

enumerator QSPI_4WIRE

QSPI 4_wire mode, QUAD SPI

enum qspi_device_t

Values:

enumerator QSPI_PSRAM

QSPI PSRAM

enumerator QSPI_FLASH

QSPI FLASH

enumerator QSPI_OLED

QSPI OLED