29#if (HAL_USE_SDC == TRUE) || defined(__DOXYGEN__) 
   80  (bool (*)(
void *, uint32_t, uint8_t *, uint32_t))
sdcRead,
 
   81  (bool (*)(
void *, uint32_t, 
const uint8_t *, uint32_t))
sdcWrite,
 
 
  108    if (((resp[0] >> 8U) & 0xFU) != 1U) {
 
 
  155    if ((resp[0] & 0x80000000U) != 0U) {
 
  156      if ((resp[0] & 0x40000000U) != 0U) {
 
 
  202    if ((resp[0] & 0x80000000U) != 0U) {
 
  203      if ((resp[0] & 0x40000000U) != 0U) {
 
 
  230                                   uint32_t value, uint32_t cmd_set) {
 
  235  return ((uint32_t)access << 24U) | (idx << 16U) | (value << 8U) | cmd_set;
 
 
  252  uint32_t ret = 0xFFFFFF;
 
  256  ret &= ~((uint32_t)0xFU << ((uint32_t)function * 4U));
 
  257  ret |= value << ((uint32_t)function * 4U);
 
  258  return ret | ((uint32_t)mode << 31U);
 
 
  272                                      const uint8_t *buf) {
 
  274  unsigned start = 12U - ((unsigned)function * 2U);
 
  276  return ((uint16_t)buf[start] << 8U) | (uint16_t)buf[start + 1U];
 
 
  292                                 const uint8_t *buf) {
 
  297  tmp = ((uint32_t)buf[14] << 16U) |
 
  298        ((uint32_t)buf[15] << 8U) |
 
  300  status = (tmp >> ((uint32_t)function * 4U)) & 0xFU;
 
  301  if (0xFU != status) {
 
 
  322  uint8_t *tmp = sdcp->
buf;
 
 
  521#if SDC_NICE_WAITING == TRUE 
 
  619#if defined(SDC_LLD_ENHANCED_API) 
 
  722                                sdcp->
rca, sdcp->csd)) {
 
  749      uint8_t *ext_csd = sdcp->
buf;
 
 
  861  osalDbgCheck((sdcp != NULL) && (buf != NULL) && (n > 0U));
 
  864  if ((startblk + n - 1U) > sdcp->capacity) {
 
 
  896              const uint8_t *buf, uint32_t n) {
 
  899  osalDbgCheck((sdcp != NULL) && (buf != NULL) && (n > 0U));
 
  902  if ((startblk + n - 1U) > sdcp->capacity) {
 
 
  988  bdip->
blk_num = sdcp->capacity;
 
 
#define HAL_SUCCESS
HAL operation success.
 
#define HAL_FAILED
HAL operation failed.
 
#define MMCSD_CMD_ERASE_RW_BLK_END
 
#define MMCSD_R1_ERROR(r1)
Evaluates to true if the R1 response contains error flags.
 
#define MMCSD_CMD_SEND_EXT_CSD
 
#define MMCSD_CSD_MMC_CSD_STRUCTURE_SLICE
 
#define MMCSD_CMD_APP_OP_COND
 
#define MMCSD_R1_STS(r1)
Returns the status field of an R1 response.
 
#define MMCSD_CMD_SEND_STATUS
 
uint32_t _mmcsd_get_slice(const uint32_t *data, uint32_t end, uint32_t start)
Gets a bit field from a words array.
 
#define MMCSD_CMD_SEND_RELATIVE_ADDR
 
#define MMCSD_CMD_APP_CMD
 
#define MMCSD_CMD_SET_BUS_WIDTH
 
uint32_t _mmcsd_get_capacity(const uint32_t *csd)
Extract card capacity from a CSD.
 
#define MMCSD_CMD8_PATTERN
Fixed pattern for CMD8.
 
#define MMCSD_BLOCK_SIZE
Fixed block size for MMC/SD block devices.
 
#define MMCSD_CMD_SEND_CSD
 
#define MMCSD_CMD_SEND_IF_COND
 
#define MMCSD_CMD_SET_BLOCKLEN
 
#define MMCSD_CMD_ALL_SEND_CID
 
uint32_t _mmcsd_get_capacity_ext(const uint8_t *ext_csd)
Extract MMC card capacity from EXT_CSD.
 
#define MMCSD_CMD_GO_IDLE_STATE
 
#define MMCSD_CSD_10_CSD_STRUCTURE_SLICE
 
#define MMCSD_CMD_SEL_DESEL_CARD
 
#define MMCSD_CMD_ERASE_RW_BLK_START
 
static void osalSysLock(void)
Enters a critical zone from thread context.
 
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
 
int32_t msg_t
Type of a message.
 
#define osalDbgAssert(c, remark)
Condition assertion.
 
#define osalDbgCheck(c)
Function parameters check.
 
#define osalThreadSleepMilliseconds(msecs)
Delays the invoking thread for the specified number of milliseconds.
 
void sdcObjectInit(SDCDriver *sdcp)
Initializes the standard part of a SDCDriver structure.
 
bool sdc_lld_is_write_protected(SDCDriver *sdcp)
 
void sdc_lld_set_data_clk(SDCDriver *sdcp, sdcbusclk_t clk)
Sets the SDIO clock to data mode (25MHz or less).
 
static uint32_t sdc_cmd6_construct(sd_switch_t mode, sd_switch_function_t function, uint32_t value)
Constructs CMD6 argument for SDC.
 
void sdcStop(SDCDriver *sdcp)
Deactivates the SDC peripheral.
 
#define SDC_OVERFLOW_ERROR
 
bool sdc_lld_sync(SDCDriver *sdcp)
Waits for card idle condition.
 
void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg)
Sends an SDIO command with no response expected.
 
static bool sdc_init(SDCDriver *sdcp)
Init procedure for SDC.
 
void sdc_lld_stop_clk(SDCDriver *sdcp)
Stops the SDIO clock.
 
bool sdc_lld_read(SDCDriver *sdcp, uint32_t startblk, uint8_t *buf, uint32_t n)
Reads one or more blocks.
 
msg_t sdcStart(SDCDriver *sdcp, const SDCConfig *config)
Configures and activates the SDC peripheral.
 
#define SDC_MODE_CARDTYPE_MASK
 
#define SDC_INIT_OCR_V20
OCR initialization constant for V20 cards.
 
#define SDC_MODE_CARDTYPE_MMC
 
bool sdcRead(SDCDriver *sdcp, uint32_t startblk, uint8_t *buf, uint32_t n)
Reads one or more blocks.
 
bool sdcConnect(SDCDriver *sdcp)
Performs the initialization procedure on the inserted card.
 
bool sdcWrite(SDCDriver *sdcp, uint32_t startblk, const uint8_t *buf, uint32_t n)
Writes one or more blocks.
 
void sdc_lld_stop(SDCDriver *sdcp)
Deactivates the SDC peripheral.
 
static bool mmc_detect_bus_clk(SDCDriver *sdcp, sdcbusclk_t *clk)
Reads supported bus clock and switch MMC to appropriate mode.
 
#define SDC_MODE_CARDTYPE_SDV11
 
static bool mmc_set_bus_width(SDCDriver *sdcp)
Sets bus width for MMC.
 
static bool mmc_init(SDCDriver *sdcp)
Init procedure for MMC.
 
#define SDC_INIT_OCR
OCR initialization constant for non-V20 cards.
 
#define SDC_MODE_CARDTYPE_SDV20
 
void sdc_lld_start(SDCDriver *sdcp)
Configures and activates the SDC peripheral.
 
bool sdc_lld_read_special(SDCDriver *sdcp, uint8_t *buf, size_t bytes, uint8_t cmd, uint32_t argument)
 
#define SDC_MODE_HIGH_CAPACITY
 
bool sdcDisconnect(SDCDriver *sdcp)
Brings the driver in a state safe for card removal.
 
static bool sdc_set_bus_width(SDCDriver *sdcp)
Sets bus width for SDC.
 
#define SDC_INIT_RETRY
Number of initialization attempts before rejecting the card.
 
bool sdc_lld_write(SDCDriver *sdcp, uint32_t startblk, const uint8_t *buf, uint32_t n)
Writes one or more blocks.
 
static uint16_t sdc_cmd6_extract_info(sd_switch_function_t function, const uint8_t *buf)
Extracts information from CMD6 answer.
 
bool sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg, uint32_t *resp)
Sends an SDIO command with a long response expected and CRC.
 
bool sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg, uint32_t *resp)
Sends an SDIO command with a short response expected and CRC.
 
sdcbusclk_t
Max supported clock.
 
static bool mode_detect(SDCDriver *sdcp)
Detects card mode.
 
void sdcInit(void)
SDC Driver initialization.
 
void sdc_lld_start_clk(SDCDriver *sdcp)
Starts the SDIO clock and sets it to init mode (400kHz or less).
 
static bool sdc_cmd6_check_status(sd_switch_function_t function, const uint8_t *buf)
Checks status after switching using CMD6.
 
sdcflags_t sdcGetAndClearErrors(SDCDriver *sdcp)
Returns the errors mask associated to the previous operation.
 
void sdc_lld_set_bus_mode(SDCDriver *sdcp, sdcbusmode_t mode)
Switches the bus to 4 bits mode.
 
static uint32_t mmc_cmd6_construct(mmc_switch_t access, uint32_t idx, uint32_t value, uint32_t cmd_set)
Constructs CMD6 argument for MMC.
 
bool _sdc_wait_for_transfer_state(SDCDriver *sdcp)
Wait for the card to complete pending operations with CRC check.
 
static const struct SDCDriverVMT sdc_vmt
Virtual methods table.
 
void sdc_lld_init(void)
Low level SDC driver initialization.
 
sd_switch_t
SDC switch mode.
 
sd_switch_function_t
SDC switch function.
 
bool sdcSync(SDCDriver *sdcp)
Waits for card idle condition.
 
static bool _sdc_wait_for_transfer_state_internal(SDCDriver *sdcp, bool crc_check)
Wait for the card to complete pending operations.
 
bool sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg, uint32_t *resp)
Sends an SDIO command with a short response expected.
 
static bool sdc_detect_bus_clk(SDCDriver *sdcp, sdcbusclk_t *clk)
Reads supported bus clock and switch SDC to appropriate mode.
 
bool sdc_lld_is_card_inserted(SDCDriver *sdcp)
 
mmc_switch_t
MMC switch mode.
 
uint32_t sdcflags_t
SDC Driver condition flags type.
 
bool _sdc_wait_for_transfer_state_nocrc(SDCDriver *sdcp)
Wait for the card to complete pending operations without CRC check.
 
bool sdcGetInfo(SDCDriver *sdcp, BlockDeviceInfo *bdip)
Returns the media info.
 
static bool detect_bus_clk(SDCDriver *sdcp, sdcbusclk_t *clk)
Reads supported bus clock and switch card to appropriate mode.
 
bool sdcErase(SDCDriver *sdcp, uint32_t startblk, uint32_t endblk)
Erases the supplied blocks.
 
@ SD_SWITCH_FUNCTION_DRIVER_STRENGTH
 
@ SD_SWITCH_FUNCTION_CURRENT_LIMIT
 
@ SD_SWITCH_FUNCTION_SPEED
 
@ SD_SWITCH_FUNCTION_CMD_SYSTEM
 
uint32_t blk_num
Total number of blocks.
 
uint32_t blk_size
Block size in bytes.
 
Driver configuration structure.
 
sdcbusmode_t bus_width
Bus width.
 
Structure representing an SDC driver.
 
sdcmode_t cardmode
Various flags regarding the mounted card.
 
_mmcsd_block_device_data const SDCConfig * config
Current configuration data.
 
uint8_t buf[MMCSD_BLOCK_SIZE]
Buffer for internal operations.
 
const struct SDCDriverVMT * vmt
Virtual Methods Table.
 
sdcflags_t errors
Errors flags.
 
SDCDriver virtual methods table.