## **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
Declares the standard SDIO APIs. |
## Data Structures
Defines the SDIO capabilities. | |
Defines SDIO common information. |
## Typedefs
SdioIrqHandler(void *) | Defines the function type of an SDIO IRQ. |
## Enumerations
SdioCommonInfoType { SDIO_FUNC_INFO = 0, SDIO_OTHER_INFO } | Enumerates SDIO common information types. |
## Functions
SdioOpen (int16_t busNum) | struct DevHandle * Opens an SDIO controller with a specified bus number. |
SdioClose (struct DevHandle *handle) | |
SdioReadBytes (struct DevHandle *handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) | Incrementally reads a given length of data from the specified SDIO address. |
SdioWriteBytes (struct DevHandle *handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) | Incrementally writes a given length of data into the specified SDIO address. |
SdioReadBytesFromFixedAddr (struct DevHandle *handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) | Reads a given length of data from the fixed SDIO address. |
SdioWriteBytesToFixedAddr (struct DevHandle *handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) | Writes a given length of data into the fixed SDIO address. |
SdioReadBytesFromFunc0 (struct DevHandle *handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) | Reads a given length of data from the address space of SDIO function 0. |
SdioWriteBytesToFunc0 (struct DevHandle *handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) | Writes a given length of data into the address space of SDIO function 0. |
SdioSetBlockSize (struct DevHandle *handle, uint32_t blockSize) | |
SdioGetCommonInfo (struct DevHandle *handle, SdioCommonInfo *info, SdioCommonInfoType infoType) | |
SdioSetCommonInfo (struct DevHandle *handle, SdioCommonInfo *info, SdioCommonInfoType infoType) | |
SdioFlushData (struct DevHandle *handle) | |
SdioClaimHost (struct DevHandle *handle) | |
SdioReleaseHost (struct DevHandle *handle) | Releases the exclusively claimed host. |
SdioEnableFunc (struct DevHandle *handle) | Enables the SDIO device so that its register can be accessed. |
SdioDisableFunc (struct DevHandle *handle) | |
SdioClaimIrq (struct DevHandle *handle, SdioIrqHandler *irqHandler) | |
SdioReleaseIrq (struct DevHandle *handle) |
## **Details**
## **Typedef Documentation**
## SdioIrqHandler
```
typedef void SdioIrqHandler(void *)
```
**Description:**
Defines the function type of an SDIO IRQ.
This function is registered when you call [SdioClaimIrq](SDIO.md#ga81f98e541845c15a632cf59cd9c263f8) to request the SDIO IRQ.
**Parameters:**
data | Indicates the private data passed to this IRQ (The data is specified when the IRQ is registered). |
## **Enumeration Type Documentation**
## SdioCommonInfoType
```
enum [SdioCommonInfoType](SDIO.md#ga4037437ac001a9848dd242e8aa632678)
```
**Description:**
Enumerates SDIO common information types.
When obtaining SDIO common information by calling [SdioGetCommonInfo](SDIO.md#gac5c6bf733ea9e4408fd1109b18741ce8) or setting the information by calling [SdioSetCommonInfo](SDIO.md#ga563b67c90fbb88075bf5a05d9b5d5706), you need to pass the information type.
SDIO_FUNC_INFO | |
SDIO_OTHER_INFO |
## **Function Documentation**
## SdioClaimHost\(\)
```
void SdioClaimHost (struct [DevHandle](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](SDIO.md#gabd2fe2d978e7fde51eba584f30dc8e7c).
**Parameters:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
## SdioClaimIrq\(\)
```
int32_t SdioClaimIrq (struct [DevHandle](DevHandle.md) * handle, [SdioIrqHandler](SDIO.md#ga858bec274683a4f50d53d1f9f43d204b) * irqHandler )
```
**Description:**
Claims an SDIO IRQ.
When there is data, commands, or events, the IRQ function is executed.
**Parameters:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
irqHandler | Indicates 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\(\)
```
void SdioClose (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Closes an SDIO controller.
After the SDIO interface is used, you can close the SDIO controller by calling [SdioClose](SDIO.md#ga15427d4b231423c6de812fedffbd61e3). This function is used in pair with [SdioOpen](SDIO.md#gadca7b0edcae3df85b3ade33704a306f8).
**Parameters:**
handle | Indicates the pointer to the device handle of the SDIO controller. |
## SdioDisableFunc\(\)
```
int32_t SdioDisableFunc (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Disables the SDIO device.
This function is used in pair with [SdioEnableFunc](SDIO.md#ga2f31cd318990db879e827e3b8f9f2393).
**Parameters:**
handle | Indicates 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\(\)
```
int32_t SdioEnableFunc (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Enables the SDIO device so that its register can be accessed.
**Parameters:**
handle | Indicates 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\(\)
```
int32_t SdioFlushData (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Flushes data.
You can call this function when an SDIO needs to be reinitialized or an unexpected error occurs.
**Parameters:**
handle | Indicates 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\(\)
```
int32_t SdioGetCommonInfo (struct [DevHandle](DevHandle.md) * handle, [SdioCommonInfo](SdioCommonInfo.md) * info, [SdioCommonInfoType](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:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
info | Indicates the pointer to the common information to be obtained. For details, see SdioCommonInfo. |
infoType | Indicates 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\(\)
```
struct [DevHandle](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](SDIO.md#gadca7b0edcae3df85b3ade33704a306f8). This function is used in pair with [SdioClose](SDIO.md#ga15427d4b231423c6de812fedffbd61e3).
**Parameters:**
busNum | Indicates the bus number. |
**Returns:**
Returns the device handle [DevHandle](DevHandle.md) of the SDIO controller if the operation is successful; returns **NULL** otherwise.
## SdioReadBytes\(\)
```
int32_t SdioReadBytes (struct [DevHandle](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:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
data | Indicates the pointer to the data to read. |
addr | Indicates the start address of the data to read. |
size | Indicates the length of the data to read. |
timeOut | Indicates 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\(\)
```
int32_t SdioReadBytesFromFixedAddr (struct [DevHandle](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:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
data | Indicates the pointer to the data to read. |
addr | Indicates the fixed address of the data to read. |
size | Indicates the length of the data to read. |
timeOut | Indicates 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\(\)
```
int32_t SdioReadBytesFromFunc0 (struct [DevHandle](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:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
data | Indicates the pointer to the data to read. |
addr | Indicates the start address of the data to read. |
size | Indicates the length of the data to read. |
timeOut | Indicates 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\(\)
```
void SdioReleaseHost (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Releases the exclusively claimed host.
This function is used in pair with [SdioClaimHost](SDIO.md#ga86e24b0480c860cfad8ff12fbc66bc9f).
**Parameters:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
## SdioReleaseIrq\(\)
```
int32_t SdioReleaseIrq (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Releases an SDIO IRQ.
This function is used in pair with [SdioClaimIrq](SDIO.md#ga81f98e541845c15a632cf59cd9c263f8).
**Parameters:**
handle | Indicates 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\(\)
```
int32_t SdioSetBlockSize (struct [DevHandle](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:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
blockSize | Indicates 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\(\)
```
int32_t SdioSetCommonInfo (struct [DevHandle](DevHandle.md) * handle, [SdioCommonInfo](SdioCommonInfo.md) * info, [SdioCommonInfoType](SDIO.md#ga4037437ac001a9848dd242e8aa632678) infoType )
```
**Description:**
Sets common information.
You can call this function to set the maximum timeout duration and private data.
**Parameters:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
info | Indicates the pointer to the common information to be set. For details, see SdioCommonInfo. |
infoType | Indicates 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\(\)
```
int32_t SdioWriteBytes (struct [DevHandle](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:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
data | Indicates the pointer to the data to write. |
addr | Indicates the start address of the data to write. |
size | Indicates the length of the data to write. |
timeOut | Indicates 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\(\)
```
int32_t SdioWriteBytesToFixedAddr (struct [DevHandle](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:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
data | Indicates the pointer to the data to write. |
addr | Indicates the fixed address of the data to write. |
size | Indicates the length of the data to write. |
timeOut | Indicates 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\(\)
```
int32_t SdioWriteBytesToFunc0 (struct [DevHandle](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:**
handle | Indicates the pointer to the device handle of the SDIO controller obtained by SdioOpen. |
data | Indicates the pointer to the data to write. |
addr | Indicates the start address of the data to write. |
size | Indicates the length of the data to write. |
timeOut | Indicates 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.