27 #if (HAL_USE_MMC_SPI == TRUE) || (HAL_USE_SDC == TRUE) || defined(__DOXYGEN__) 64 unsigned startidx, endidx, startoff;
69 startidx = start / 32U;
70 startoff = start % 32U;
72 endmask = ((uint32_t)1U << ((end % 32U) + 1U)) - 1U;
75 if (startidx < endidx) {
76 return (data[startidx] >> startoff) |
77 ((data[endidx] & endmask) << (32U - startoff));
79 return (data[startidx] & endmask) >> startoff;
104 return ((a + 1U) << (b + 2U)) << (c - 9U);
129 return ((uint32_t)ext_csd[215] << 24U) +
130 ((uint32_t)ext_csd[214] << 16U) +
131 ((uint32_t)ext_csd[213] << 8U) +
132 (uint32_t)ext_csd[212];
151 cidsdc->mdt_y = (uint16_t)
_mmcsd_get_slice(cid, MMCSD_CID_SDC_MDT_Y_SLICE) +
182 cidmmc->mdt_y = (uint16_t)
_mmcsd_get_slice(cid, MMCSD_CID_MMC_MDT_Y_SLICE) +
213 csdmmc->c_size = (uint16_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_C_SIZE_SLICE);
214 csdmmc->c_size_mult = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_C_SIZE_MULT_SLICE);
219 csdmmc->dsr_imp = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_DSR_IMP_SLICE);
221 csdmmc->erase_grp_mult = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_ERASE_GRP_MULT_SLICE);
222 csdmmc->erase_grp_size = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_ERASE_GRP_SIZE_SLICE);
223 csdmmc->file_format = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_FILE_FORMAT_SLICE);
224 csdmmc->file_format_grp = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_FILE_FORMAT_GRP_SLICE);
226 csdmmc->perm_write_protect = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_PERM_WRITE_PROTECT_SLICE);
227 csdmmc->r2w_factor = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_R2W_FACTOR_SLICE);
228 csdmmc->read_bl_len = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_READ_BL_LEN_SLICE);
229 csdmmc->read_bl_partial = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_READ_BL_PARTIAL_SLICE);
230 csdmmc->read_blk_misalign = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_READ_BLK_MISALIGN_SLICE);
231 csdmmc->spec_vers = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_SPEC_VERS_SLICE);
233 csdmmc->tmp_write_protect = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_TMP_WRITE_PROTECT_SLICE);
234 csdmmc->tran_speed = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_TRAN_SPEED_SLICE);
235 csdmmc->vdd_r_curr_max = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_VDD_R_CURR_MAX_SLICE);
236 csdmmc->vdd_r_curr_min = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_VDD_R_CURR_MIN_SLICE);
237 csdmmc->vdd_w_curr_max = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_VDD_W_CURR_MAX_SLICE);
238 csdmmc->vdd_w_curr_min = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_VDD_W_CURR_MIN_SLICE);
239 csdmmc->wp_grp_enable = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_WP_GRP_ENABLE_SLICE);
240 csdmmc->wp_grp_size = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_WP_GRP_SIZE_SLICE);
241 csdmmc->write_bl_len = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_WRITE_BL_LEN_SLICE);
242 csdmmc->write_bl_partial = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_WRITE_BL_PARTIAL_SLICE);
243 csdmmc->write_blk_misalign = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_MMC_WRITE_BLK_MISALIGN_SLICE);
262 csd10->c_size_mult = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_C_SIZE_MULT_SLICE);
266 csd10->csd_structure = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_CSD_STRUCTURE_SLICE);
267 csd10->dsr_imp = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_DSR_IMP_SLICE);
268 csd10->erase_blk_en = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_ERASE_BLK_EN_SLICE);
269 csd10->erase_sector_size = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_ERASE_SECTOR_SIZE_SLICE);
270 csd10->file_format = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_FILE_FORMAT_SLICE);
271 csd10->file_format_grp = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_FILE_FORMAT_GRP_SLICE);
273 csd10->perm_write_protect = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_PERM_WRITE_PROTECT_SLICE);
274 csd10->r2w_factor = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_R2W_FACTOR_SLICE);
275 csd10->read_bl_len = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_READ_BL_LEN_SLICE);
276 csd10->read_bl_partial = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_READ_BL_PARTIAL_SLICE);
277 csd10->read_blk_misalign = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_READ_BLK_MISALIGN_SLICE);
279 csd10->tmp_write_protect = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_TMP_WRITE_PROTECT_SLICE);
280 csd10->tran_speed = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_TRANS_SPEED_SLICE);
281 csd10->wp_grp_enable = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_WP_GRP_ENABLE_SLICE);
282 csd10->wp_grp_size = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_WP_GRP_SIZE_SLICE);
283 csd10->write_bl_len = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_WRITE_BL_LEN_SLICE);
284 csd10->write_bl_partial = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_WRITE_BL_PARTIAL_SLICE);
285 csd10->write_blk_misalign = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_10_WRITE_BLK_MISALIGN_SLICE);
307 csd20->csd_structure = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_CSD_STRUCTURE_SLICE);
308 csd20->dsr_imp = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_DSR_IMP_SLICE);
309 csd20->erase_blk_en = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_ERASE_BLK_EN_SLICE);
310 csd20->file_format = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_FILE_FORMAT_SLICE);
311 csd20->file_format_grp = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_FILE_FORMAT_GRP_SLICE);
313 csd20->perm_write_protect = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_PERM_WRITE_PROTECT_SLICE);
314 csd20->r2w_factor = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_R2W_FACTOR_SLICE);
315 csd20->read_bl_len = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_READ_BL_LEN_SLICE);
316 csd20->read_bl_partial = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_READ_BL_PARTIAL_SLICE);
317 csd20->read_blk_misalign = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_READ_BLK_MISALIGN_SLICE);
318 csd20->erase_sector_size = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_ERASE_SECTOR_SIZE_SLICE);
320 csd20->tmp_write_protect = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_TMP_WRITE_PROTECT_SLICE);
321 csd20->tran_speed = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_TRANS_SPEED_SLICE);
322 csd20->wp_grp_enable = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_WP_GRP_ENABLE_SLICE);
323 csd20->wp_grp_size = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_WP_GRP_SIZE_SLICE);
324 csd20->write_bl_len = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_WRITE_BL_LEN_SLICE);
325 csd20->write_bl_partial = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_WRITE_BL_PARTIAL_SLICE);
326 csd20->write_blk_misalign = (uint8_t)
_mmcsd_get_slice(csd, MMCSD_CSD_20_WRITE_BLK_MISALIGN_SLICE);
MCC/SD block device class.
uint32_t _mmcsd_get_capacity_ext(const uint8_t *ext_csd)
Extract MMC card capacity from EXT_CSD.
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.
void _mmcsd_unpack_sdc_cid(const MMCSDBlockDevice *sdcp, unpacked_sdc_cid_t *cidsdc)
Unpacks SDC CID array in structure.
#define osalDbgCheck(c)
Function parameters check.
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.
#define MMCSD_CSD_MMC_CSD_STRUCTURE_SLICE
Slice position of values in CSD register.
uint32_t _mmcsd_get_capacity(const uint32_t *csd)
Extract card capacity from a CSD.
#define MMCSD_CID_SDC_CRC_SLICE
Slice position of values in CID register.