HPM SDK
HPMicro Software Development Kit
hpm_sdmmc_sdio.h File Reference
#include <stdint.h>
#include "hpm_sdmmc_common.h"

Go to the source code of this file.

Data Structures

union  sdio_cmd5_arg_t
 CMD5 argument definition. More...
 
union  sdio_cmd5_resp_t
 CMD5 response definition. More...
 
union  sdio_resp_r5_t
 Response R5 definition. More...
 
union  sdio_cmd52_arg_t
 CMD5 argument definition. More...
 
union  sdio_cmd53_arg_t
 CMD53 argument definition. More...
 
struct  sdio_cccr_t
 CCCR register map. More...
 
struct  sdio_fbr_t
 FBR register map. More...
 
struct  sdio_tpl_block
 TPL block structure. More...
 
struct  sdio_common_cis_t
 SDIO Common In. More...
 
struct  ATTR_PACKED
 SDIO Function extension structure. More...
 
struct  sdio_cis_t
 SDIO CIS information. More...
 
struct  sdio_func_t
 SDIO Function information. More...
 

Macros

#define SDIO_CMD53_OP_MODE_FIXED_ADDR   0
 
#define SDIO_CMD53_OP_MODE_INCR_ADDR   1
 
#define SDIO_CMD_TIMEOUT_MS   (1000UL)
 
#define SDIO_FBR_REG_BASE(fbr)   ((fbr) * 0x100)
 
#define SDIO_MAX_FUNC_NUM   7
 
#define SDIO_SPEED_DEFAULT_SPEED   0UL
 SDIO Speed definitions. More...
 
#define SDIO_SPEED_HIGH_SPEED   1UL
 
#define SDIO_SPEED_SDR12   SDIO_SPEED_DEFAULT_SPEED
 
#define SDIO_SPEED_SDR25   SDIO_SPEED_HIGH_SPEED
 
#define SDIO_SPEED_SDR50   2UL
 
#define SDIO_SPEED_SDR104   3UL
 
#define SDIO_SPEED_DDR50   4UL
 
#define SDIO_CCCR_BUS_WIDTH_1BIT   0UL
 SDIO Bus width definitions. More...
 
#define SDIO_CCCR_BUS_WIDTH_4BIT   2UL
 
#define SDIO_CCCR_BUS_SPEED_MASK   (0x7UL << 1)
 SDIO BUS speed definitions in CCCR register. More...
 
#define SDIO_CCCR_BUS_SPEED_SUPPORT_HIGHSPEED   (1)
 
#define SDIO_CCCR_BUS_SPEED_DEFAULT   (SDIO_SPEED_DEFAULT_SPEED << 1)
 
#define SDIO_CCCR_BUS_SPEED_HIGH   (SDIO_SPEED_HIGH_SPEED << 1)
 
#define SDIO_CCCR_BUS_SPEED_SDR12   (SDIO_CCCR_BUS_SPEED_DEFAULT)
 
#define SDIO_CCCR_BUS_SPEED_SDR25   (SDIO_CCCR_BUS_SPEED_HIGH)
 
#define SDIO_CCCR_BUS_SPEED_SDR50   (SDIO_SPEED_SDR50 << 1)
 
#define SDIO_CCCR_BUS_SPEED_SDR104   (SDIO_SPEED_SDR104 << 1)
 
#define SDIO_CCCR_BUS_SPEED_DDR50   (SDIO_SPEED_DDR50 << 1)
 
#define SDIO_REG_CCCR_SDIO_REV   0
 CCCR register address. More...
 
#define SDIO_REG_CCCR_SD_REV   1
 
#define SDIO_REG_CCCR_IO_ENABLE   2
 
#define SDIO_REG_CCCR_IO_READY   3
 
#define SDIO_REG_CCCR_INT_ENABLE   4
 
#define SDIO_REG_CCCR_INT_PENDING   5
 
#define SDIO_REG_CCCR_IO_ABORT   6
 
#define SDIO_REG_CCCR_BUS_IF_CTRL   7
 
#define SDIO_REG_CCCR_CARD_CAP   8
 
#define SDIO_REG_CCCR_COM_CIS_PTR   9
 
#define SDIO_REG_CCCR_BUS_SUSPEND   0xC
 
#define SDIO_REG_CCCR_FUNC_SEL   0xD
 
#define SDIO_REG_CCCR_EXEC_FLAGS   0xE
 
#define SDIO_REG_CCCR_READY_FLAGS   0xF
 
#define SDIO_REG_CCCR_FN0_BLK_SIZE   0x10
 
#define SDIO_REG_CCCR_POWER_CTRL   0x12
 
#define SDIO_REG_CCCR_BUS_SPEED_SEL   0x13
 
#define SDIO_REG_CCCR_UHS_SUPPORT   0x14
 
#define SDIO_REG_CCCR_DRV_STRENGTH   0x15
 
#define SDIO_REG_CCCR_INT_EXT   0x16
 
#define SDIO_REG_CCCR_START   SDIO_REG_CCCR_SDIO_REV
 CCCR register range definitions. More...
 
#define SDIO_REG_CCCR_END   SDIO_REG_CCCR_INT_EXT
 
#define SDIO_REG_FBR_CIS_PTR_OFFSET   0x9
 
#define SDIO_REG_FBR_CSR_PTR_OFFSET   0xC
 
#define SDIO_REG_FBR_MAX_BLK_SIZE_OFFSET   0x10
 
#define CISTPL_NULL   (0)
 CISTPL type definitions. More...
 
#define CISTPL_CHECKSUM   (0x10)
 
#define CISTPL_VERS_1   (0x15)
 
#define CISTPL_ALTSTR   (0x16)
 
#define CISTPL_MANFID   (0x20)
 
#define CISTPL_FUNCID   (0x21)
 
#define CISTPL_FUNCE   (0x22)
 
#define CISTPL_SDIO_STD   (0x91)
 
#define CISTPL_SDIO_EXT   (0x92)
 
#define CISTPL_END   (0xFF)
 
#define STD_SDIO_FUNC_IF_CODE_NON_STD   0
 Standard SDIO Function Interface Code Definitions. More...
 
#define STD_SDIO_FUNC_IF_CODE_UART   1
 
#define STD_SDIO_FUNC_IF_CODE_BT_TYPEA   2
 
#define STD_SDIO_FUNC_IF_CODE_BT_TYPEB   3
 
#define STD_SDIO_FUNC_IF_CODE_GPS   4
 
#define STD_SDIO_FUNC_IF_CODE_CAMERA   5
 
#define STD_SDIO_FUNC_IF_CODE_PHS   6
 
#define STD_SDIO_FUNC_IF_CODE_WLAN   7
 
#define STD_SDIO_FUNC_IF_CODE_ATA   8
 
#define STD_SDIO_FUNC_IF_CODE_BT_TYPEA_AMP   9
 
#define STD_SDIO_FUNC_IF_CODE_ISDIO   0xE
 
#define STD_SDIO_FUNC_IF_CODE_EXT_STD   0xF
 

Typedefs

typedef struct sdio_tpl_blocksdio_tpl_blk_t
 TPL block structure. More...
 
typedef struct _sdmmc_sdio sdio_card_t
 

Functions

static uint32_t sdio_cis_csr_addr (const uint8_t *reg_ptr)
 Get the CIS register address from raw register value. More...
 
hpm_stat_t sdio_init (sdio_card_t *card)
 Initialize SDIO device. More...
 
void sdio_deinit (sdio_card_t *card)
 De-initialize SDIO device. More...
 
hpm_stat_t sdio_card_init (sdio_card_t *card)
 Initialize SDIO card. More...
 
hpm_stat_t sdio_card_deinit (sdio_card_t *card)
 De-Initialize SDIO card. More...
 
hpm_stat_t sdio_host_init (sdio_card_t *card)
 Initialize SDIO host. More...
 
hpm_stat_t sdio_host_deinit (sdio_card_t *card)
 De-initialize SDIO host. More...
 
hpm_stat_t sdio_io_rw_direct (sdio_card_t *card, bool write, uint32_t func_idx, uint32_t reg_addr, uint8_t *pdata, bool read_after_write)
 Execute SDIO_IO_RW_DIRECT command (CMD52) More...
 
hpm_stat_t sdio_set_block_size (sdio_card_t *card, uint32_t func_idx, uint32_t block_size)
 Set the Block size for specified Function. More...
 
hpm_stat_t sdio_io_rw_extend (sdio_card_t *card, bool write, uint32_t func_idx, uint32_t reg_addr, uint32_t op_code, uint8_t *pbuf, uint32_t blocks, uint32_t block_size)
 Execute SDIO_IO_RW_EXTEND command (CMD53) More...
 
hpm_stat_t sdio_io_write_multi_bytes_to_fifo (sdio_card_t *card, uint32_t func_idx, uint32_t reg_addr, uint8_t *pbuf, uint32_t length)
 Write multiple bytes to the FIFO address for specified SDIO Function. More...
 
hpm_stat_t sdio_io_read_multi_bytes_from_fifo (sdio_card_t *card, uint32_t func_idx, uint32_t reg_addr, uint8_t *pbuf, uint32_t length)
 Read multiple bytes from the FIFO address for specified SDIO Function. More...
 
hpm_stat_t sdio_io_write_incr_multi_bytes (sdio_card_t *card, uint32_t func_idx, uint32_t reg_addr, uint8_t *pbuf, uint32_t length)
 Write multiple bytes to the address for specified SDIO Function. More...
 
hpm_stat_t sdio_io_read_incr_multi_bytes (sdio_card_t *card, uint32_t func_idx, uint32_t reg_addr, uint8_t *pbuf, uint32_t length)
 Read multiple bytes from the address for specified SDIO Function. More...
 
hpm_stat_t sdio_io_read_byte (sdio_card_t *card, uint32_t func_idx, uint32_t reg_addr, uint8_t *pdata)
 Read 1 byte from the address for specified SDIO Function. More...
 
hpm_stat_t sdio_io_write_byte (sdio_card_t *card, uint32_t func_idx, uint32_t reg_addr, uint8_t byte_data)
 Write 1 byte to the address for specified SDIO Function. More...
 
const char * sdio_get_func_if_code_str (uint8_t std_func_if_code)
 Get the string for specified function interface code. More...
 
hpm_stat_t sdio_read_fbr (sdio_card_t *card, uint32_t func_idx, sdio_fbr_t *fbr)
 Read the specified Function Basic Register. More...
 
hpm_stat_t sdio_read_cis (sdio_card_t *card, uint32_t cis_ptr, sdio_cis_t *cis, bool keep_tpl_raw_data)
 Read Card Information Structure (CIS) More...
 
hpm_stat_t sdio_get_max_transfer_speed (sdio_card_t *card)
 Get the maximum transfer speed. More...
 
hpm_stat_t sdio_init_funcs (sdio_card_t *card)
 Initialize SDIO functions. More...
 
hpm_stat_t sdio_deinit_funcs (sdio_card_t *card)
 De-Initialize SDIO functions. More...
 
hpm_stat_t sdio_enable_interrupt (sdio_card_t *card)
 Enables SDIO interrupts for the specified card. More...
 
hpm_stat_t sdio_disable_interrupt (sdio_card_t *card)
 Disables SDIO interrupts for the specified card. More...
 
hpm_stat_t sdio_register_irq_callback (sdio_card_t *card, void(*sdio_irq_callback)(void *param), void *sdio_irq_param)
 Registers an interrupt callback function for an SDIO card. More...