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

SPI master API 参考

SPI Master

SPI_TRANS_RX_INVALID_BITS
SPI_TRANS_CS_KEEP_ACTIVE
struct transceive_t

Public Members

uint32_t flags

[input]transceive flasg

uint8_t *tx_buf

[input]pointer to transmit buffer, or NULL no data to be transmit

uint32_t tx_len

[input]total transmit length

uint8_t *rx_buf

[output]pointer to transmit buffer, or NULL no data receive

uint32_t rx_len

[intput]total receive length

uint8_t dummy_bits

[input] the dummy lenght in this transeceive, unit is bit

typedef void (*wm_spim_callback_t)(int result, void *data)
int wm_drv_spim_transceive_sync(wm_device_t *dev, const wm_dt_hw_spim_dev_cfg_t *config, transceive_t *desc, uint32_t ms_to_wait)

transceive data synchronously, the api return until synchronously done or timeout

参数:
  • dev[in] SPI device pointer

  • config[in] Pointer to a valid wm_hw_spi_device_config_t structure instance.

  • desc[in] transceive descrption about tx and rx

  • ms_to_wait[in] the max wait time for transeceive done, unit is millisecon

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_spim_transceive_async(wm_device_t *dev, const wm_dt_hw_spim_dev_cfg_t *config, transceive_t *desc, wm_spim_callback_t callback, void *usr_data)

transceive data asynchronously, callback will be trigger after transceive done

参数:
  • dev[in] SPI device pointer

  • config[in] Pointer to a valid wm_hw_spi_device_config_t structure instance.

  • desc[in] transceive descrption about tx and rx

  • callback[in] the function will be trigger after transceive done

  • usr_data[in] the argument for callback function

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

wm_device_t *wm_drv_spim_init(const char *dev_name)

Initialize SPI master driver.

参数:

dev_name[in] spi master device name

返回:

  • spi master device pointer: succeed

  • NULL : failed

int wm_drv_spim_deinit(wm_device_t *dev)

deinit SPI master driver

参数:

dev[in] SPI master device pointer

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed