Read or write a card register
#include <hw/dcmd_sim_sdmmc.h> #define DCMD_SDMMC_CARD_REGISTER __DIOTF(_DCMD_CAM, _SIM_SDMMC + 4, struct _sdmmc_card_register)
Argument | Value |
---|---|
filedes | A file descriptor that you obtained by opening the device |
dcmd | DCMD_SDMMC_CARD_REGISTER |
dev_data_ptr | A pointer to a SDMMC_CARD_REGISTER structure that's followed by a data buffer |
n_bytes | sizeof(SDMMC_CARD_REGISTER) plus the size of the data buffer |
dev_info_ptr | NULL |
This command reads or writes a card register. It uses two data structures to input and output information:
SDMMC_CARD_REGISTER:
The SDMMC_CARD_REGISTER structure is defined as follows:
typedef struct _sdmmc_card_register { uint32_t action; uint32_t type; uint32_t address; uint32_t length; uint32_t rsvd[2]; /* uint8_t data[ length ]; variable length data */ } SDMMC_CARD_REGISTER;
The members include:
It's set to one of the following on return:
The register data buffer is used to store the register data in a read or write operation. If the action field of the SDMMC_CARD_REGISTER structure is set to SDMMC_CR_ACTION_READ, the read data will be returned in the data buffer that follows this structure. If the action field is set to SDMMC_CR_ACTION_WRITE, the write data should be stored in the data buffer that follows the structure.
Each register type requires a different data buffer size to store the read or write data without data cropping. You must ensure that your application uses the correct literal value to set the data buffer size. If the data buffer is too small to fit the full register, the driver will not overflow the buffer but will only return a subset of the read data.
Register Type | Data Buffer Size |
---|---|
SDMMC_REG_TYPE_CID | 16 |
SDMMC_REG_TYPE_CSD | 16 |
SDMMC_REG_TYPE_EXT_CSD (Read) | 512 |
SDMMC_REG_TYPE_EXT_CSD (Write) | 1 |
SDMMC_REG_TYPE_SCR | 8 |
Set the action and type members. If using SDMMC_CR_ACTION_WRITE, fill the register data buffer with the value you would like to write to the register.
The filled-in structure. If using SDMMC_CR_ACTION_READ, the register data buffer will be filled with the register read data.
devctl() in the QNX Neutrino C Library Reference