30 #if (HAL_USE_MMC_SPI == TRUE) || (HAL_USE_SDC == TRUE) || defined(__DOXYGEN__) 39 #define MMCSD_BLOCK_SIZE 512U 44 #define MMCSD_R1_ERROR_MASK 0xFDFFE008U 49 #define MMCSD_CMD8_PATTERN 0x000001AAU 55 #define MMCSD_STS_IDLE 0U 56 #define MMCSD_STS_READY 1U 57 #define MMCSD_STS_IDENT 2U 58 #define MMCSD_STS_STBY 3U 59 #define MMCSD_STS_TRAN 4U 60 #define MMCSD_STS_DATA 5U 61 #define MMCSD_STS_RCV 6U 62 #define MMCSD_STS_PRG 7U 63 #define MMCSD_STS_DIS 8U 70 #define MMCSD_CMD_GO_IDLE_STATE 0U 71 #define MMCSD_CMD_INIT 1U 72 #define MMCSD_CMD_ALL_SEND_CID 2U 73 #define MMCSD_CMD_SEND_RELATIVE_ADDR 3U 74 #define MMCSD_CMD_SET_BUS_WIDTH 6U 75 #define MMCSD_CMD_SWITCH MMCSD_CMD_SET_BUS_WIDTH 76 #define MMCSD_CMD_SEL_DESEL_CARD 7U 77 #define MMCSD_CMD_SEND_IF_COND 8U 78 #define MMCSD_CMD_SEND_EXT_CSD MMCSD_CMD_SEND_IF_COND 79 #define MMCSD_CMD_SEND_CSD 9U 80 #define MMCSD_CMD_SEND_CID 10U 81 #define MMCSD_CMD_STOP_TRANSMISSION 12U 82 #define MMCSD_CMD_SEND_STATUS 13U 83 #define MMCSD_CMD_SET_BLOCKLEN 16U 84 #define MMCSD_CMD_READ_SINGLE_BLOCK 17U 85 #define MMCSD_CMD_READ_MULTIPLE_BLOCK 18U 86 #define MMCSD_CMD_SET_BLOCK_COUNT 23U 87 #define MMCSD_CMD_WRITE_BLOCK 24U 88 #define MMCSD_CMD_WRITE_MULTIPLE_BLOCK 25U 89 #define MMCSD_CMD_ERASE_RW_BLK_START 32U 90 #define MMCSD_CMD_ERASE_RW_BLK_END 33U 91 #define MMCSD_CMD_ERASE 38U 92 #define MMCSD_CMD_APP_OP_COND 41U 93 #define MMCSD_CMD_LOCK_UNLOCK 42U 94 #define MMCSD_CMD_APP_CMD 55U 95 #define MMCSD_CMD_READ_OCR 58U 105 #define MMCSD_CSD_MMC_CSD_STRUCTURE_SLICE 127U,126U 106 #define MMCSD_CSD_MMC_SPEC_VERS_SLICE 125U,122U 107 #define MMCSD_CSD_MMC_TAAC_SLICE 119U,112U 108 #define MMCSD_CSD_MMC_NSAC_SLICE 111U,104U 109 #define MMCSD_CSD_MMC_TRAN_SPEED_SLICE 103U,96U 110 #define MMCSD_CSD_MMC_CCC_SLICE 95U,84U 111 #define MMCSD_CSD_MMC_READ_BL_LEN_SLICE 83U,80U 112 #define MMCSD_CSD_MMC_READ_BL_PARTIAL_SLICE 79U,79U 113 #define MMCSD_CSD_MMC_WRITE_BLK_MISALIGN_SLICE 78U,78U 114 #define MMCSD_CSD_MMC_READ_BLK_MISALIGN_SLICE 77U,77U 115 #define MMCSD_CSD_MMC_DSR_IMP_SLICE 76U,76U 116 #define MMCSD_CSD_MMC_C_SIZE_SLICE 73U,62U 117 #define MMCSD_CSD_MMC_VDD_R_CURR_MIN_SLICE 61U,59U 118 #define MMCSD_CSD_MMC_VDD_R_CURR_MAX_SLICE 58U,56U 119 #define MMCSD_CSD_MMC_VDD_W_CURR_MIN_SLICE 55U,53U 120 #define MMCSD_CSD_MMC_VDD_W_CURR_MAX_SLICE 52U,50U 121 #define MMCSD_CSD_MMC_C_SIZE_MULT_SLICE 49U,47U 122 #define MMCSD_CSD_MMC_ERASE_GRP_SIZE_SLICE 46U,42U 123 #define MMCSD_CSD_MMC_ERASE_GRP_MULT_SLICE 41U,37U 124 #define MMCSD_CSD_MMC_WP_GRP_SIZE_SLICE 36U,32U 125 #define MMCSD_CSD_MMC_WP_GRP_ENABLE_SLICE 31U,31U 126 #define MMCSD_CSD_MMC_DEFAULT_ECC_SLICE 30U,29U 127 #define MMCSD_CSD_MMC_R2W_FACTOR_SLICE 28U,26U 128 #define MMCSD_CSD_MMC_WRITE_BL_LEN_SLICE 25U,22U 129 #define MMCSD_CSD_MMC_WRITE_BL_PARTIAL_SLICE 21U,21U 130 #define MMCSD_CSD_MMC_CONTENT_PROT_APP_SLICE 16U,16U 131 #define MMCSD_CSD_MMC_FILE_FORMAT_GRP_SLICE 15U,15U 132 #define MMCSD_CSD_MMC_COPY_SLICE 14U,14U 133 #define MMCSD_CSD_MMC_PERM_WRITE_PROTECT_SLICE 13U,13U 134 #define MMCSD_CSD_MMC_TMP_WRITE_PROTECT_SLICE 12U,12U 135 #define MMCSD_CSD_MMC_FILE_FORMAT_SLICE 11U,10U 136 #define MMCSD_CSD_MMC_ECC_SLICE 9U,8U 137 #define MMCSD_CSD_MMC_CRC_SLICE 7U,1U 140 #define MMCSD_CSD_20_CRC_SLICE 7U,1U 141 #define MMCSD_CSD_20_FILE_FORMAT_SLICE 11U,10U 142 #define MMCSD_CSD_20_TMP_WRITE_PROTECT_SLICE 12U,12U 143 #define MMCSD_CSD_20_PERM_WRITE_PROTECT_SLICE 13U,13U 144 #define MMCSD_CSD_20_COPY_SLICE 14U,14U 145 #define MMCSD_CSD_20_FILE_FORMAT_GRP_SLICE 15U,15U 146 #define MMCSD_CSD_20_WRITE_BL_PARTIAL_SLICE 21U,21U 147 #define MMCSD_CSD_20_WRITE_BL_LEN_SLICE 25U,12U 148 #define MMCSD_CSD_20_R2W_FACTOR_SLICE 28U,26U 149 #define MMCSD_CSD_20_WP_GRP_ENABLE_SLICE 31U,31U 150 #define MMCSD_CSD_20_WP_GRP_SIZE_SLICE 38U,32U 151 #define MMCSD_CSD_20_ERASE_SECTOR_SIZE_SLICE 45U,39U 152 #define MMCSD_CSD_20_ERASE_BLK_EN_SLICE 46U,46U 153 #define MMCSD_CSD_20_C_SIZE_SLICE 69U,48U 154 #define MMCSD_CSD_20_DSR_IMP_SLICE 76U,76U 155 #define MMCSD_CSD_20_READ_BLK_MISALIGN_SLICE 77U,77U 156 #define MMCSD_CSD_20_WRITE_BLK_MISALIGN_SLICE 78U,78U 157 #define MMCSD_CSD_20_READ_BL_PARTIAL_SLICE 79U,79U 158 #define MMCSD_CSD_20_READ_BL_LEN_SLICE 83U,80U 159 #define MMCSD_CSD_20_CCC_SLICE 95U,84U 160 #define MMCSD_CSD_20_TRANS_SPEED_SLICE 103U,96U 161 #define MMCSD_CSD_20_NSAC_SLICE 111U,104U 162 #define MMCSD_CSD_20_TAAC_SLICE 119U,112U 163 #define MMCSD_CSD_20_CSD_STRUCTURE_SLICE 127U,126U 166 #define MMCSD_CSD_10_CRC_SLICE MMCSD_CSD_20_CRC_SLICE 167 #define MMCSD_CSD_10_FILE_FORMAT_SLICE MMCSD_CSD_20_FILE_FORMAT_SLICE 168 #define MMCSD_CSD_10_TMP_WRITE_PROTECT_SLICE MMCSD_CSD_20_TMP_WRITE_PROTECT_SLICE 169 #define MMCSD_CSD_10_PERM_WRITE_PROTECT_SLICE MMCSD_CSD_20_PERM_WRITE_PROTECT_SLICE 170 #define MMCSD_CSD_10_COPY_SLICE MMCSD_CSD_20_COPY_SLICE 171 #define MMCSD_CSD_10_FILE_FORMAT_GRP_SLICE MMCSD_CSD_20_FILE_FORMAT_GRP_SLICE 172 #define MMCSD_CSD_10_WRITE_BL_PARTIAL_SLICE MMCSD_CSD_20_WRITE_BL_PARTIAL_SLICE 173 #define MMCSD_CSD_10_WRITE_BL_LEN_SLICE MMCSD_CSD_20_WRITE_BL_LEN_SLICE 174 #define MMCSD_CSD_10_R2W_FACTOR_SLICE MMCSD_CSD_20_R2W_FACTOR_SLICE 175 #define MMCSD_CSD_10_WP_GRP_ENABLE_SLICE MMCSD_CSD_20_WP_GRP_ENABLE_SLICE 176 #define MMCSD_CSD_10_WP_GRP_SIZE_SLICE MMCSD_CSD_20_WP_GRP_SIZE_SLICE 177 #define MMCSD_CSD_10_ERASE_SECTOR_SIZE_SLICE MMCSD_CSD_20_ERASE_SECTOR_SIZE_SLICE 178 #define MMCSD_CSD_10_ERASE_BLK_EN_SLICE MMCSD_CSD_20_ERASE_BLK_EN_SLICE 179 #define MMCSD_CSD_10_C_SIZE_MULT_SLICE 49U,47U 180 #define MMCSD_CSD_10_VDD_W_CURR_MAX_SLICE 52U,50U 181 #define MMCSD_CSD_10_VDD_W_CURR_MIN_SLICE 55U,53U 182 #define MMCSD_CSD_10_VDD_R_CURR_MAX_SLICE 58U,56U 183 #define MMCSD_CSD_10_VDD_R_CURR_MIX_SLICE 61U,59U 184 #define MMCSD_CSD_10_C_SIZE_SLICE 73U,62U 185 #define MMCSD_CSD_10_DSR_IMP_SLICE MMCSD_CSD_20_DSR_IMP_SLICE 186 #define MMCSD_CSD_10_READ_BLK_MISALIGN_SLICE MMCSD_CSD_20_READ_BLK_MISALIGN_SLICE 187 #define MMCSD_CSD_10_WRITE_BLK_MISALIGN_SLICE MMCSD_CSD_20_WRITE_BLK_MISALIGN_SLICE 188 #define MMCSD_CSD_10_READ_BL_PARTIAL_SLICE MMCSD_CSD_20_READ_BL_PARTIAL_SLICE 189 #define MMCSD_CSD_10_READ_BL_LEN_SLICE 83U,80U 190 #define MMCSD_CSD_10_CCC_SLICE MMCSD_CSD_20_CCC_SLICE 191 #define MMCSD_CSD_10_TRANS_SPEED_SLICE MMCSD_CSD_20_TRANS_SPEED_SLICE 192 #define MMCSD_CSD_10_NSAC_SLICE MMCSD_CSD_20_NSAC_SLICE 193 #define MMCSD_CSD_10_TAAC_SLICE MMCSD_CSD_20_TAAC_SLICE 194 #define MMCSD_CSD_10_CSD_STRUCTURE_SLICE MMCSD_CSD_20_CSD_STRUCTURE_SLICE 204 #define MMCSD_CID_SDC_CRC_SLICE 7U,1U 205 #define MMCSD_CID_SDC_MDT_M_SLICE 11U,8U 206 #define MMCSD_CID_SDC_MDT_Y_SLICE 19U,12U 207 #define MMCSD_CID_SDC_PSN_SLICE 55U,24U 208 #define MMCSD_CID_SDC_PRV_M_SLICE 59U,56U 209 #define MMCSD_CID_SDC_PRV_N_SLICE 63U,60U 210 #define MMCSD_CID_SDC_PNM0_SLICE 71U,64U 211 #define MMCSD_CID_SDC_PNM1_SLICE 79U,72U 212 #define MMCSD_CID_SDC_PNM2_SLICE 87U,80U 213 #define MMCSD_CID_SDC_PNM3_SLICE 95U,88U 214 #define MMCSD_CID_SDC_PNM4_SLICE 103U,96U 215 #define MMCSD_CID_SDC_OID_SLICE 119U,104U 216 #define MMCSD_CID_SDC_MID_SLICE 127U,120U 219 #define MMCSD_CID_MMC_CRC_SLICE 7U,1U 220 #define MMCSD_CID_MMC_MDT_Y_SLICE 11U,8U 221 #define MMCSD_CID_MMC_MDT_M_SLICE 15U,12U 222 #define MMCSD_CID_MMC_PSN_SLICE 47U,16U 223 #define MMCSD_CID_MMC_PRV_M_SLICE 51U,48U 224 #define MMCSD_CID_MMC_PRV_N_SLICE 55U,52U 225 #define MMCSD_CID_MMC_PNM0_SLICE 63U,56U 226 #define MMCSD_CID_MMC_PNM1_SLICE 71U,64U 227 #define MMCSD_CID_MMC_PNM2_SLICE 79U,72U 228 #define MMCSD_CID_MMC_PNM3_SLICE 87U,80U 229 #define MMCSD_CID_MMC_PNM4_SLICE 95U,88U 230 #define MMCSD_CID_MMC_PNM5_SLICE 103U,96U 231 #define MMCSD_CID_MMC_OID_SLICE 119U,104U 232 #define MMCSD_CID_MMC_MID_SLICE 127U,120U 250 #define _mmcsd_block_device_methods \ 251 _base_block_device_methods 258 #define _mmcsd_block_device_data \ 259 _base_block_device_data \ 322 uint8_t csd_structure;
328 uint8_t read_bl_partial;
329 uint8_t write_blk_misalign;
330 uint8_t read_blk_misalign;
333 uint8_t vdd_r_curr_min;
334 uint8_t vdd_r_curr_max;
335 uint8_t vdd_w_curr_min;
336 uint8_t vdd_w_curr_max;
338 uint8_t erase_blk_en;
339 uint8_t erase_sector_size;
341 uint8_t wp_grp_enable;
343 uint8_t write_bl_len;
344 uint8_t write_bl_partial;
345 uint8_t file_format_grp;
347 uint8_t perm_write_protect;
348 uint8_t tmp_write_protect;
357 uint8_t csd_structure;
363 uint8_t read_bl_partial;
364 uint8_t write_blk_misalign;
365 uint8_t read_blk_misalign;
368 uint8_t erase_blk_en;
369 uint8_t erase_sector_size;
371 uint8_t wp_grp_enable;
373 uint8_t write_bl_len;
374 uint8_t write_bl_partial;
375 uint8_t file_format_grp;
377 uint8_t perm_write_protect;
378 uint8_t tmp_write_protect;
387 uint8_t csd_structure;
394 uint8_t read_bl_partial;
395 uint8_t write_blk_misalign;
396 uint8_t read_blk_misalign;
399 uint8_t vdd_r_curr_min;
400 uint8_t vdd_r_curr_max;
401 uint8_t vdd_w_curr_min;
402 uint8_t vdd_w_curr_max;
404 uint8_t erase_grp_size;
405 uint8_t erase_grp_mult;
407 uint8_t wp_grp_enable;
410 uint8_t write_bl_len;
411 uint8_t write_bl_partial;
412 uint8_t content_prot_app;
413 uint8_t file_format_grp;
415 uint8_t perm_write_protect;
416 uint8_t tmp_write_protect;
435 #define MMCSD_R1_ERROR(r1) (((r1) & MMCSD_R1_ERROR_MASK) != 0U) 442 #define MMCSD_R1_STS(r1) (((r1) >> 9U) & 15U) 449 #define MMCSD_R1_IS_CARD_LOCKED(r1) ((((r1) >> 21U) & 1U) != 0U) 465 #define mmcsdGetCardCapacity(ip) ((ip)->capacity) MCC/SD block device class.
uint32_t _mmcsd_get_capacity_ext(const uint8_t *ext_csd)
Extract MMC card capacity from EXT_CSD.
#define _mmcsd_block_device_data
MMCSDBlockDevice specific data.
void _mmcsd_unpack_csd_mmc(const MMCSDBlockDevice *sdcp, unpacked_mmc_csd_t *csdmmc)
Unpacks MMC CSD array in structure.
Unpacked CSD v1.0 register from SDC.
Unpacked CSD register from MMC.
void _mmcsd_unpack_csd_v20(const MMCSDBlockDevice *sdcp, unpacked_sdc_csd_20_t *csd20)
Unpacks SDC CSD v2.0 array in structure.
Unpacked CID register from MMC.
MMCSDBlockDevice virtual methods table.
const struct MMCSDBlockDeviceVMT * vmt
Virtual Methods Table.
void _mmcsd_unpack_sdc_cid(const MMCSDBlockDevice *sdcp, unpacked_sdc_cid_t *cidsdc)
Unpacks SDC CID array in structure.
#define _base_block_device_methods
BaseBlockDevice specific methods.
uint32_t _mmcsd_get_slice(const uint32_t *data, uint32_t end, uint32_t start)
Gets a bit field from a words array.
Unpacked CID register from SDC.
void _mmcsd_unpack_csd_v10(const MMCSDBlockDevice *sdcp, unpacked_sdc_csd_10_t *csd10)
Unpacks SDC CSD v1.0 array in structure.
void _mmcsd_unpack_mmc_cid(const MMCSDBlockDevice *sdcp, unpacked_mmc_cid_t *cidmmc)
Unpacks MMC CID array in structure.
Unpacked CSD v2.0 register from SDC.
uint32_t _mmcsd_get_capacity(const uint32_t *csd)
Extract card capacity from a CSD.