这是最新(主)开发分支的文档。如果您正在查找以前版本的文档,使用左侧的下拉菜单选择所需的版本。

PSRAM API 参考

PSRAM

enum wm_drv_psram_mode_t

PSRAM mode.

Values:

enumerator WM_DRV_PSRAM_MODE_SPI

PSRAM WITH SPI

enumerator WM_DRV_PSRAM_MODE_QSPI

PSRAM WITH QSPI

enumerator WM_DRV_PSRAM_MODE_MAX
enum wm_drv_psram_cmd_t

PSRAM ioctrl command type.

Values:

enumerator WM_DRV_PSRAM_CMD_SET_MODE

SET PSRAM as SPI or QSPI

enumerator WM_DRV_PSRAM_CMD_ENABLE_HSM

Enable PSRAM half sleep mode

enumerator WM_DRV_PSRAM_CMD_DISABLE_HSM

Disable PSRAM half sleep mode

enumerator WM_DRV_PSRAM_CMD_MAX
wm_device_t *wm_drv_psram_init(const char *device_name)

psram drvier initialize

参数:

device_name[in] The psram controler name, defined in device table

返回:

  • !0 : psram controler handle, return previous handle if called twice

  • NULL: fail

int wm_drv_psram_deinit(wm_device_t *device)

psram drvier deinitialize

参数:

device[in] The psram controler device, wm_device_t*

返回:

  • WM_ERR_SUCCESS : deinitialize ok

  • WM_ERR_INVALID_PARAM: bad param

int wm_drv_psram_register_callback(wm_device_t *device, wm_drv_psram_callback_t callback, void *user_data)

register a callback function for the PSRAM device

参数:
  • device[in] The psram device struct, wm_device_t*

  • callback[in] The callback function to register

  • user_data[in] The user data

返回:

  • WM_ERR_SUCCESS : OK

  • WM_ERR_FAILED : FAILED

  • WM_ERR_INVALID_PARAM: bad param

int wm_drv_psram_ioctrl(wm_device_t *device, int cmd, uint32_t param, uint32_t *arg)

ioctrl

备注

cmd use as follow [cmd = WM_DRV_PSRAM_CMD_SET_MODE, param = WM_DRV_PSRAM_MODE_SPI]: SPI mode [cmd = WM_DRV_PSRAM_CMD_SET_MODE, param = WM_DRV_PSRAM_MODE_QSPI]: QSPI mode [cmd = WM_DRV_PSRAM_CMD_ENABLE_HSM ]: enable half sleep mode [cmd = WM_DRV_PSRAM_CMD_DISABLE_HSM ]: disable half sleep mode

参数:
  • device[in] The psram device struct, wm_device_t*

  • cmd[in] The command type

  • param[in] The param for the command

  • arg[in] The argument for the command

返回:

  • WM_ERR_SUCCESS : OK

  • WM_ERR_NO_SUPPORT : not support command

  • WM_ERR_INVALID_PARAM: bad param

int wm_drv_psram_get_size(wm_device_t *device, uint32_t *size)

psram drvier write api

参数:
  • device[in] The psram device struct, wm_device_t*

  • size[out] The whole psram size, Use the size configured in device table

返回:

  • WM_ERR_SUCCESS : OK

  • WM_ERR_INVALID_PARAM: bad param

int wm_drv_psram_memcpy_dma(wm_device_t *device, void *dst, const void *src, uint32_t size)

psram memcpy by DMA

备注

Calling this interface does not necessarily use DMA copy. There are three conditions for using DMA (1) Src, dst address 4-byte alignment (2) The copy length is not less than PSRAM_MIN_DMA_SIZE,default is 1024 (3) The device table configures the psram device to use DMA. When API calls, an idle DMA transmission channel is applied CPU copy: step1: memcpy step2: calling callback nodify copy done step3: return DMA copy: step1: start DMA step2: return step3: calling callback notify DMA copy done

警告

DMA and CPU access PSRAM through SPI pins, so they cannot access PSRAM at the same time. The interface will return WM_ERR_BUSY if the last access is not over.

参数:
  • device[in] The psram controler device, wm_device_t*

  • dst[in] The Destination address

  • src[out] The source address

  • size[in] The data size

返回:

  • WM_ERR_SUCCESS : OK

  • WM_ERR_FAILED : FAILED

  • WM_ERR_BUSY: The previous copy has not been completed

  • WM_ERR_INVALID_PARAM: bad param