SDIO

Overview

Declares standard APIs of basic secure digital input and output (SDIO) capabilities.

You can use this module to access the SDIO and enable the driver to operate an SDIO-compliant device. These capabilities include reading and writing data based on SDIO, setting the block size, applying for and releasing interrupts, enabling and disabling devices, and occupying and releasing the bus.

Since:

1.0

Summary

Files

File Name

Description

sdio_if.h

Declares the standard SDIO APIs.

Data Structures

Data Structure Name

Description

SdioFuncInfo

Defines the SDIO capabilities.

SdioCommonInfo

Defines SDIO common information.

Typedefs

Typedef Name

Description

SdioIrqHandler(void *)

typedef void 

Defines the function type of an SDIO IRQ.

Enumerations

Enumeration Name

Description

SdioCommonInfoType { SDIO_FUNC_INFO = 0, SDIO_OTHER_INFO }

Enumerates SDIO common information types.

Functions

Function Name

Description

SdioOpen (int16_t busNum)

struct DevHandle 

Opens an SDIO controller with a specified bus number.

SdioClose (struct DevHandle handle)

void 

Closes an SDIO controller.

SdioReadBytes (struct DevHandlehandle, uint8_t data, uint32_t addr, uint32_t size, uint32_t timeOut)

int32_t 

Incrementally reads a given length of data from the specified SDIO address.

SdioWriteBytes (struct DevHandlehandle, uint8_t data, uint32_t addr, uint32_t size, uint32_t timeOut)

int32_t 

Incrementally writes a given length of data into the specified SDIO address.

SdioReadBytesFromFixedAddr (struct DevHandlehandle, uint8_t data, uint32_t addr, uint32_t size, uint32_t timeOut)

int32_t 

Reads a given length of data from the fixed SDIO address.

SdioWriteBytesToFixedAddr (struct DevHandlehandle, uint8_t data, uint32_t addr, uint32_t size, uint32_t timeOut)

int32_t 

Writes a given length of data into the fixed SDIO address.

SdioReadBytesFromFunc0 (struct DevHandlehandle, uint8_t data, uint32_t addr, uint32_t size, uint32_t timeOut)

int32_t 

Reads a given length of data from the address space of SDIO function 0.

SdioWriteBytesToFunc0 (struct DevHandlehandle, uint8_t data, uint32_t addr, uint32_t size, uint32_t timeOut)

int32_t 

Writes a given length of data into the address space of SDIO function 0.

SdioSetBlockSize (struct DevHandlehandle, uint32_t blockSize)

int32_t 

Sets the block size.

SdioGetCommonInfo (struct DevHandle handle, SdioCommonInfoinfo, SdioCommonInfoType infoType)

int32_t 

Obtains common information.

SdioSetCommonInfo (struct DevHandle handle, SdioCommonInfoinfo, SdioCommonInfoType infoType)

int32_t 

Sets common information.

SdioFlushData (struct DevHandle handle)

int32_t 

Flushes data.

SdioClaimHost (struct DevHandlehandle)

void 

Claims a host exclusively.

SdioReleaseHost (struct DevHandle handle)

void 

Releases the exclusively claimed host.

SdioEnableFunc (struct DevHandlehandle)

int32_t 

Enables the SDIO device so that its register can be accessed.

SdioDisableFunc (struct DevHandle handle)

int32_t 

Disables the SDIO device.

SdioClaimIrq (struct DevHandlehandle, SdioIrqHandlerirqHandler)

int32_t 

Claims an SDIO IRQ.

SdioReleaseIrq (struct DevHandle *handle)

int32_t 

Releases an SDIO IRQ.

Details

Typedef Documentation

SdioIrqHandler

  1. typedefvoidSdioIrqHandler(void*)

Description:

Defines the function type of an SDIO IRQ.

This function is registered when you call SdioClaimIrq to request the SDIO IRQ.

Parameters:

Name

Description

dataIndicates the private data passed to this IRQ (The data is specified when the IRQ is registered).

Enumeration Type Documentation

SdioCommonInfoType

  1. enum[SdioCommonInfoType]($api-api-SmartVision-Devices-SDIO.md#ga4037437ac001a9848dd242e8aa632678)

Description:

Enumerates SDIO common information types.

When obtaining SDIO common information by calling SdioGetCommonInfo or setting the information by calling SdioSetCommonInfo, you need to pass the information type.

Enumerator

Description

SDIO_FUNC_INFO 

Functionality information

SDIO_OTHER_INFO 

Other information

Function Documentation

SdioClaimHost()

  1. voidSdioClaimHost(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle)

Description:

Claims a host exclusively.

You can call this function to enable the SDIO module to exclusively claim a host and then perform operations on the devices connected to the host. After performing required operations, release the host by calling SdioReleaseHost.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.

SdioClaimIrq()

  1. int32_tSdioClaimIrq(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle,[SdioIrqHandler]($api-api-SmartVision-Devices-SDIO.md#ga858bec274683a4f50d53d1f9f43d204b) * irqHandler )

Description:

Claims an SDIO IRQ.

When there is data, commands, or events, the IRQ function is executed.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.
irqHandlerIndicates the pointer to the SDIO IRQ function. For details, see SdioIrqHandler.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioClose()

  1. voidSdioClose(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle)

Description:

Closes an SDIO controller.

After the SDIO interface is used, you can close the SDIO controller by calling SdioClose. This function is used in pair with SdioOpen.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller.

SdioDisableFunc()

  1. int32_tSdioDisableFunc(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle)

Description:

Disables the SDIO device.

This function is used in pair with SdioEnableFunc.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioEnableFunc()

  1. int32_tSdioEnableFunc(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle)

Description:

Enables the SDIO device so that its register can be accessed.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioFlushData()

  1. int32_tSdioFlushData(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle)

Description:

Flushes data.

You can call this function when an SDIO needs to be reinitialized or an unexpected error occurs.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioGetCommonInfo()

  1. int32_tSdioGetCommonInfo(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle,[SdioCommonInfo]($api-api-SmartVision-Devices-SdioCommonInfo.md)* info,[SdioCommonInfoType]($api-api-SmartVision-Devices-SDIO.md#ga4037437ac001a9848dd242e8aa632678) infoType )

Description:

Obtains common information.

You can call this function to obtain the capabilities and private data of the I/O function.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.
infoIndicates the pointer to the common information to be obtained. For details, see SdioCommonInfo.
infoTypeIndicates the type of the common information to be obtained. For details, see SdioCommonInfoType.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioOpen()

  1. struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)*SdioOpen(int16_t busNum)

Description:

Opens an SDIO controller with a specified bus number.

Before using the SDIO interface, you can obtain the device handle of the SDIO controller by calling SdioOpen. This function is used in pair with SdioClose.

Parameters:

Name

Description

busNumIndicates the bus number.

Returns:

Returns the device handle DevHandle of the SDIO controller if the operation is successful; returns NULL otherwise.

SdioReadBytes()

  1. int32_tSdioReadBytes(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle,uint8_t* data,uint32_t addr,uint32_t size,uint32_t timeOut )

Description:

Incrementally reads a given length of data from the specified SDIO address.

If the length of the data to read is greater than the size of a block, the data is read by block, and the remaining data that is smaller than one block is read by byte. Otherwise, data is read by byte.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.
dataIndicates the pointer to the data to read.
addrIndicates the start address of the data to read.
sizeIndicates the length of the data to read.
timeOutIndicates the timeout duration for reading data, in milliseconds. If the value is 0,the default value is used. The default value varies according to the application. Generally, the default value is 1 second.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioReadBytesFromFixedAddr()

  1. int32_tSdioReadBytesFromFixedAddr(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle,uint8_t* data,uint32_t addr,uint32_t size,uint32_t timeOut )

Description:

Reads a given length of data from the fixed SDIO address.

If the length of the data to read is greater than the size of a block, the data is read by block, and the remaining data that is smaller than one block is read by byte. Otherwise, data is read by byte.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.
dataIndicates the pointer to the data to read.
addrIndicates the fixed address of the data to read.
sizeIndicates the length of the data to read.
timeOutIndicates the timeout duration for reading data, in milliseconds. If the value is 0, the default value is used. The default value varies according to the application. Generally, the default value is 1 second.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioReadBytesFromFunc0()

  1. int32_tSdioReadBytesFromFunc0(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle,uint8_t* data,uint32_t addr,uint32_t size,uint32_t timeOut )

Description:

Reads a given length of data from the address space of SDIO function 0.

Currently, only one byte of data can be read.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.
dataIndicates the pointer to the data to read.
addrIndicates the start address of the data to read.
sizeIndicates the length of the data to read.
timeOutIndicates the timeout duration for reading data, in milliseconds. If the value is 0, the default value is used. The default value varies according to the application. Generally, the default value is 1 second.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioReleaseHost()

  1. voidSdioReleaseHost(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle)

Description:

Releases the exclusively claimed host.

This function is used in pair with SdioClaimHost.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.

SdioReleaseIrq()

  1. int32_tSdioReleaseIrq(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle)

Description:

Releases an SDIO IRQ.

This function is used in pair with SdioClaimIrq.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioSetBlockSize()

  1. int32_tSdioSetBlockSize(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle,uint32_t blockSize )

Description:

Sets the block size.

If data to read or write is performed, use this function to set the block size.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.
blockSizeIndicates the block size to be set. If the value is 0, the default value is used. The value ranges from 1 to 2048 bytes.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioSetCommonInfo()

  1. int32_tSdioSetCommonInfo(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle,[SdioCommonInfo]($api-api-SmartVision-Devices-SdioCommonInfo.md)* info,[SdioCommonInfoType]($api-api-SmartVision-Devices-SDIO.md#ga4037437ac001a9848dd242e8aa632678) infoType )

Description:

Sets common information.

You can call this function to set the maximum timeout duration and private data.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.
infoIndicates the pointer to the common information to be set. For details, see SdioCommonInfo.
infoTypeIndicates the type of the common information to be set. For details, see SdioCommonInfoType.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioWriteBytes()

  1. int32_tSdioWriteBytes(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle,uint8_t* data,uint32_t addr,uint32_t size,uint32_t timeOut )

Description:

Incrementally writes a given length of data into the specified SDIO address.

If the length of the data to write is greater than the size of a block, the data is written by block first, and the remaining data that is smaller than one block is written by byte. Otherwise, data is written by byte.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.
dataIndicates the pointer to the data to write.
addrIndicates the start address of the data to write.
sizeIndicates the length of the data to write.
timeOutIndicates the timeout duration for writing data, in milliseconds. If the value is 0, the default value is used. The default value varies according to the application. Generally, the default value is 1 second.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioWriteBytesToFixedAddr()

  1. int32_tSdioWriteBytesToFixedAddr(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle,uint8_t* data,uint32_t addr,uint32_t size,uint32_t timeOut )

Description:

Writes a given length of data into the fixed SDIO address.

If the length of the data to write is greater than the size of a block, the data is written by block first, and the remaining data that is smaller than one block is written by byte. Otherwise, data is written by byte.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.
dataIndicates the pointer to the data to write.
addrIndicates the fixed address of the data to write.
sizeIndicates the length of the data to write.
timeOutIndicates the timeout duration for writing data, in milliseconds. If the value is 0, the default value is used. The default value varies according to the application. Generally, the default value is 1 second.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.

SdioWriteBytesToFunc0()

  1. int32_tSdioWriteBytesToFunc0(struct[DevHandle]($api-api-SmartVision-Devices-DevHandle.md)* handle,uint8_t* data,uint32_t addr,uint32_t size,uint32_t timeOut )

Description:

Writes a given length of data into the address space of SDIO function 0.

Currently, only one byte of data can be written.

Parameters:

Name

Description

handleIndicates the pointer to the device handle of the SDIO controller obtained by SdioOpen.
dataIndicates the pointer to the data to write.
addrIndicates the start address of the data to write.
sizeIndicates the length of the data to write.
timeOutIndicates the timeout duration for writing data, in milliseconds. If the value is 0, the default value is used. The default value varies according to the application. Generally, the default value is 1 second.

Returns:

Returns 0 if the operation is successful; returns a negative value if the operation fails.