This is the documentation for the latest (main) development branch. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.

SPI master API Reference

SPI Master

SPI_TRANS_RX_INVALID_BITS
SPI_TRANS_CS_KEEP_ACTIVE
struct transceive_t
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

Parameters:
  • 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

Returns:

  • 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

Parameters:
  • 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

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed

wm_device_t *wm_drv_spim_init(const char *dev_name)

Initialize SPI master driver.

Parameters:

dev_name[in] spi master device name

Returns:

  • spi master device pointer: succeed

  • NULL : failed

int wm_drv_spim_deinit(wm_device_t *dev)

deinit SPI master driver

Parameters:

dev[in] SPI master device pointer

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed