SDIO API

[中文]

SDIO (Secure Digital Input/Output) API interface.

Header File

Functions

bk_err_t bk_sdio_host_driver_init(void)

Init the sdio host driver.

This API init the resoure common:

  • Init sdio host driver control memory

Attention

1. This API should be called before any other sdio host APIs

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_sdio_host_driver_deinit(void)

Deinit the sdio host driver.

This API free all resource related to sdio host and disable sdio host

Returns

  • BK_OK: succeed

  • others: other errors.

bk_err_t bk_sdio_host_init(const sdio_host_config_t *config)

Init the sdio host.

This API init the sdio host:

  • Power up the sdio

  • Configure the sdio clock soure to 26M

  • Enable sdio host interrupt

  • Map the sdio to dedicated GPIO port

  • Set the clock frequency and bus width

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_NOT_INIT: sdio host driver not init

  • BK_ERR_NULL_PARAM: config is NULL

  • others: other errors.

bk_err_t bk_sdio_host_deinit(void)

Deinit the sdio host.

This API deinit the sdio host:

  • Reset all configuration of sdio host to default value

  • Clear sdio host interrupt status

  • Power down the sdio host

  • Disable sdio host interrupt

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_NOT_INIT: sdio host driver not init

  • others: other errors.

bk_err_t bk_sdio_host_set_clock_freq(sdio_host_clock_freq_t clock_freq)

Set the sdio host clock frequency.

Parameters

clock_freq – clock frequency

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_NOT_INIT: sdio host driver not init

  • others: other errors.

bk_err_t bk_sdio_host_send_command(const sdio_host_cmd_cfg_t *command)

Send the command from host to slave.

Parameters

command – the configuration information for the command

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_NOT_INIT: sdio host driver not init

  • BK_ERR_NULL_PARAM: command is NULL

  • others: other errors.

bk_err_t bk_sdio_host_wait_cmd_response(uint32_t cmd_index)

Host wait for salve command response.

Parameters

cmd_index – the command index

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_NOT_INIT: sdio host driver not init

  • BK_ERR_SDIO_HOST_CMD_RSP_TIMEOUT: sdio host wait slave command over time

  • BK_ERR_SDIO_HOST_CMD_RSP_CRC_FAIL: sdio host wait slave command crc fail

  • others: other errors.

uint32_t bk_sdio_host_get_cmd_rsp_argument(sdio_host_response_t argument_index)

Get the command response.

Parameters

argument_index – the command argument index

Returns

the response register value

bk_err_t bk_sdio_host_config_data(const sdio_host_data_config_t *data_config)

Config the data.

Parameters

data_config – the configuration information for the data

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_NOT_INIT: sdio host driver not init

  • BK_ERR_NULL_PARAM: data_config is NULL

  • others: other errors.

bk_err_t bk_sdio_host_set_data_timeout(uint32_t timeout)

Set the data timeout.

Parameters

timeout – the data timeout

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_NOT_INIT: sdio host driver not init

  • others: other errors.

bk_err_t bk_sdio_host_write_fifo(const uint8_t *write_data, uint32_t data_size)

Write data to tx fifo.

Parameters
  • write_data – pointer to data to write

  • data_size – size of data to be sent, the data_size value should be aligned with 512 bytes.

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_NOT_INIT: sdio host driver not init

  • BK_ERR_NULL_PARAM: write_data is NULL

  • BK_ERR_SDIO_HOST_DATA_TIMEOUT: sdio host wait slave data timeout

  • BK_ERR_SDIO_HOST_DATA_CRC_FAIL: sdio host receive slave data crc fail

  • others: other errors.

bk_err_t bk_sdio_host_wait_receive_data(void)

Host wait slave data.

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_NOT_INIT: sdio host driver not init

  • BK_ERR_SDIO_HOST_DATA_TIMEOUT: sdio host wait slave data timeout

  • BK_ERR_SDIO_HOST_DATA_CRC_FAIL: sdio host receive slave data crc fail

  • others: other errors.

bk_err_t bk_sdio_host_read_fifo(uint32_t *save_v_p)

Read data from rx fifo with timeout mode.

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_READ_DATA_FAIL: sdio host read data from FIFO timeout

  • *save_v_p:if success, will save read value to this pointer.

bk_err_t bk_sdio_host_read_blks_fifo(uint8_t *read_data, uint32_t blk_cnt)

Read many blocks data from rx fifo with timeout mode.

Parameters

blk_cnt:read – how many blocks data out from SDIO FIFO. the block_size is 512 bytes.

Returns

  • BK_OK: succeed

  • BK_ERR_SDIO_HOST_READ_DATA_FAIL: sdio host read data from FIFO timeout

  • *read_data:if success, will save read value to this pointer.