同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Figure 1 illustrates the process of using an SDIO.
Figure 1 Process of using an SDIO
Before performing SDIO communication, obtain the device handle of an SDIO controller by calling SdioOpen. This function returns the device handle of the SDIO controller with a specified bus number.
DevHandle SdioOpen(int16_t busNum);
Table 1 Parameters and return values of SdioOpen
The following example shows how to open an SDIO controller.
DevHandle handle = NULL;
int16_t busNum = 1;
/* Open an SDIO controller whose bus number is 1. */
handle = SdioOpen(busNum);
if (handle == NULL) {
HDF_LOGE("SdioOpen: failed!\n");
}
After obtaining the device handle of an SDIO controller, exclusively claim the host before performing subsequent operations on the SDIO device.
void SdioClaimHost(DevHandle handle);
Table 2 Parameter description of SdioClaimHost
The following example shows how to exclusively claim a host.
SdioClaimHost(handle); /* Claim a host exclusively. */
Before accessing a register, enable the SDIO device.
int32_t SdioEnableFunc(DevHandle handle);
Table 3 Parameters and return values of SdioEnableFunc
The following example shows how to enable the SDIO device.
int32_t ret;
/* Enable the SDIO device. */
ret = SdioEnableFunc(handle);
if (ret != 0) {
HDF_LOGE("SdioEnableFunc: failed, ret %d\n", ret);
}
Before SDIO communication, claim an SDIO IRQ.
int32_t SdioClaimIrq(DevHandle handle, SdioIrqHandler *handler);
Table 4 Parameters and return values of SdioClaimIrq
The following example shows how to claim an SDIO IRQ.
/* Implement the SDIO IRQ function based on the application. */
static void SdioIrqFunc(void *data)
{
if (data == NULL) {
HDF_LOGE("SdioIrqFunc: data is NULL.\n");
return;
}
/* You need to add specific implementations. */
}
int32_t ret;
/* Claim an SDIO IRQ. */
ret = SdioClaimIrq(handle, SdioIrqFunc);
if (ret != 0) {
HDF_LOGE("SdioClaimIrq: failed, ret %d\n", ret);
}
The corresponding function is as follows:
int32_t SdioWriteBytes(DevHandle handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut);
Table 5 Parameters and return values of SdioWriteBytes
Timeout duration for writing data, in milliseconds. If the value is 0, the default value is used. |
|
The following example shows how to incrementally write a given length of data into the SDIO device.
int32_t ret;
uint8_t wbuff[] = {1,2,3,4,5};
uint32_t addr = 0x100 + 0x09;
/* Incrementally write 5-byte data into the start address 0x109 of the SDIO device. */
ret = SdioWriteBytes(handle, wbuff, addr, sizeof(wbuff) / sizeof(wbuff[0]), 0);
if (ret != 0) {
HDF_LOGE("SdioWriteBytes: failed, ret %d\n", ret);
}
The corresponding function is as follows:
int32_t SdioReadBytes(DevHandle handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut);
Table 6 Parameters and return values of SdioReadBytes
Timeout duration for reading data, in milliseconds. If the value is 0, the default value is used. |
|
The following example shows how to incrementally read a given length of data from the SDIO device.
int32_t ret;
uint8_t rbuff[5] = {0};
uint32_t addr = 0x100 + 0x09;
/* Incrementally read 5-byte data from the start address 0x109 of the SDIO device. */
ret = SdioReadBytes(handle, rbuff, addr, 5, 0);
if (ret != 0) {
HDF_LOGE("SdioReadBytes: failed, ret %d\n", ret);
}
Write a given length of data into the fixed address of an SDIO device.
The corresponding function is as follows:
int32_t SdioWriteBytesToFixedAddr(DevHandle handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut);
Table 7 Parameters and return values of SdioWriteBytesToFixedAddr
Timeout duration for writing data, in milliseconds. If the value is 0, the default value is used. |
|
The following example shows how to write a given length of data into the fixed address of an SDIO device.
int32_t ret;
uint8_t wbuff[] = {1, 2, 3, 4, 5};
uint32_t addr = 0x100 + 0x09;
/* Write 5-byte data into the fixed address 0x109 of the SDIO device. */
ret = SdioWriteBytesToFixedAddr(handle, wbuff, addr, sizeof(wbuff) / sizeof(wbuff[0]), 0);
if (ret != 0) {
HDF_LOGE("SdioWriteBytesToFixedAddr: failed, ret %d\n", ret);
}
Read a given length of data from the fixed address of an SDIO device.
The corresponding function is as follows:
int32_t SdioReadBytesFromFixedAddr(DevHandle handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut);
Table 8 Parameters and return values of SdioReadBytesFromFixedAddr
Timeout duration for reading data, in milliseconds. If the value is 0, the default value is used. |
|
The following example shows how to read a given length of data from the fixed address of an SDIO device.
int32_t ret;
uint8_t rbuff[5] = {0};
uint32_t addr = 0x100 + 0x09;
/* Read 5-byte data from the fixed address 0x109 of the SDIO device. */
ret = SdioReadBytesFromFixedAddr(handle, rbuff, addr, 5, 0);
if (ret != 0) {
HDF_LOGE("SdioReadBytesFromFixedAddr: failed, ret %d\n", ret);
}
Write a given length of data into the address space of SDIO function 0.
Currently, only 1-byte data can be written. The corresponding function is as follows:
int32_t SdioWriteBytesToFunc0(DevHandle handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut);
Table 9 Parameters and return values of SdioWriteBytesToFunc0
Timeout duration for writing data, in milliseconds. If the value is 0, the default value is used. |
|
The following example shows how to write a given length of data into the address space of SDIO function 0.
int32_t ret;
uint8_t wbuff = 1;
/* Write 1-byte data into the address 0x2 of SDIO function 0. */
ret = SdioWriteBytesToFunc0(handle, &wbuff, 0x2, 1, 0);
if (ret != 0) {
HDF_LOGE("SdioWriteBytesToFunc0: failed, ret %d\n", ret);
}
Currently, only 1-byte data can be read. The corresponding function is as follows:
int32_t SdioReadBytesFromFunc0(DevHandle handle, uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut);
Table 10 Parameters and return values of SdioReadBytesFromFunc0
Timeout duration for reading data, in milliseconds. If the value is 0, the default value is used. |
|
The following example shows how to read a given length of data from the address space of SDIO function 0.
int32_t ret;
uint8_t rbuff;
/* Read 1-byte data from the address 0x2 of SDIO function 0. */
ret = SdioReadBytesFromFunc0(handle, &rbuff, 0x2, 1, 0);
if (ret != 0) {
HDF_LOGE("SdioReadBytesFromFunc0: failed, ret %d\n", ret);
}
After the SDIO communication, release the SDIO IRQ.
int32_t SdioReleaseIrq(DevHandle handle);
Table 11 Parameters and return values of SdioReleaseIrq
The following example shows how to release the SDIO IRQ.
int32_t ret;
/* Release the SDIO IRQ. */
ret = SdioReleaseIrq(handle);
if (ret != 0) {
HDF_LOGE("SdioReleaseIrq: failed, ret %d\n", ret);
}
After the SDIO communication, disable the SDIO device.
int32_t SdioDisableFunc(DevHandle handle);
Table 12 Parameters and return values of SdioDisableFunc
The following example shows how to disable the SDIO device.
int32_t ret;
/* Disable the SDIO device. */
ret = SdioDisableFunc(handle);
if (ret != 0) {
HDF_LOGE("SdioDisableFunc: failed, ret %d\n", ret);
}
After the SDIO communication, release the exclusively claimed host.
void SdioReleaseHost(DevHandle handle);
Table 13 Parameter description of SdioReleaseHost
The following example shows how to release the exclusively claimed host.
SdioReleaseHost(handle); /* Release the exclusively claimed host. */
After the SDIO communication, close the SDIO controller.
void SdioClose(DevHandle handle);
This function releases the resources requested.
Table 14 Parameter description of SdioClose
The following example shows how to close an SDIO controller.
SdioClose(handle); /* Close an SDIO controller. */
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。