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 Slave API Reference

SPI Slave

enum WM_SPIS_TRANS_FLAG

Values:

enumerator SPIS_TRANS_DUMMY_BITS

dummy bit valid bit

enumerator SPIS_TRANS_CS_KEEP_ACTIVE

if set, CS will keep active after transceive done

enumerator SPIS_TRANS_BIG_ENDIAN

if set, transmit high address byte first in a word

enumerator SPIS_TRANS_VARIABLE_CMD

if set, cmd and cmd_len will valid in spis_transceive_ex_t

enumerator SPIS_TRANS_VARIABLE_ADDR

if set, addr and addr_len will valid in spis_transceive_ex_t

struct spis_transceive_t
struct spis_transceive_ex_t
typedef void (*wm_spis_callback_t)(int result, void *data)
int wm_drv_spis_transceive_sync(wm_device_t *dev, const wm_dt_hw_spis_dev_cfg_t *config, spis_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_spis_transceive_async(wm_device_t *dev, const wm_dt_hw_spis_dev_cfg_t *config, spis_transceive_t *desc, wm_spis_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_spis_init(const char *dev_name)

Initialize SPI slave driver.

Parameters:

dev_name[in] spi slave device name

Returns:

  • spi slave device pointer: succeed

  • NULL : failed

int wm_drv_spis_deinit(wm_device_t *dev)

deinit SPI slave driver

Parameters:

dev[in] SPI slave device pointer

Returns:

  • WM_ERR_SUCCESS: succeed

  • others: failed