| 
    ChibiOS/HAL 9.0.0
    
   | 
 
Generic SD Card Driver. More...
Generic SD Card Driver.
This module implements a generic SDC (Secure Digital Card) driver.
HAL_USE_SDC option must be enabled in halconf.h.This driver implements a state machine internally, see the Abstract I/O Block Device module documentation for details.
This driver allows to read or write single or multiple 512 bytes blocks on a SD Card.

SD card types | |
| #define | SDC_MODE_CARDTYPE_MASK 0xFU | 
| #define | SDC_MODE_CARDTYPE_SDV11 0U | 
| #define | SDC_MODE_CARDTYPE_SDV20 1U | 
| #define | SDC_MODE_CARDTYPE_MMC 2U | 
| #define | SDC_MODE_HIGH_CAPACITY 0x10U | 
SDC bus error conditions | |
| #define | SDC_NO_ERROR 0U | 
| #define | SDC_CMD_CRC_ERROR 1U | 
| #define | SDC_DATA_CRC_ERROR 2U | 
| #define | SDC_DATA_TIMEOUT 4U | 
| #define | SDC_COMMAND_TIMEOUT 8U | 
| #define | SDC_TX_UNDERRUN 16U | 
| #define | SDC_RX_OVERRUN 32U | 
| #define | SDC_STARTBIT_ERROR 64U | 
| #define | SDC_OVERFLOW_ERROR 128U | 
| #define | SDC_UNHANDLED_ERROR 0xFFFFFFFFU | 
SDC configuration options | |
| #define | SDC_INIT_RETRY 100 | 
| Number of initialization attempts before rejecting the card.   | |
| #define | SDC_MMC_SUPPORT FALSE | 
| Include support for MMC cards.   | |
| #define | SDC_NICE_WAITING TRUE | 
| Delays insertions.   | |
| #define | SDC_INIT_OCR_V20 0x50FF8000U | 
| OCR initialization constant for V20 cards.   | |
| #define | SDC_INIT_OCR 0x80100000U | 
| OCR initialization constant for non-V20 cards.   | |
Macro Functions | |
| #define | sdcIsCardInserted(sdcp) | 
| Returns the card insertion status.   | |
| #define | sdcIsWriteProtected(sdcp) | 
| Returns the write protect status.   | |
PLATFORM configuration options | |
| #define | PLATFORM_SDC_USE_SDC1 FALSE | 
| PWMD1 driver enable switch.   | |
Data Structures | |
| struct | SDCConfig | 
| Driver configuration structure.  More... | |
| struct | SDCDriverVMT | 
SDCDriver virtual methods table.  More... | |
| struct | SDCDriver | 
| Structure representing an SDC driver.  More... | |
Macros | |
| #define | _sdc_driver_methods _mmcsd_block_device_methods | 
SDCDriver specific methods.   | |
Typedefs | |
| typedef uint32_t | sdcmode_t | 
| Type of card flags.   | |
| typedef uint32_t | sdcflags_t | 
| SDC Driver condition flags type.   | |
| typedef struct SDCDriver | SDCDriver | 
| Type of a structure representing an SDC driver.   | |
Enumerations | |
| enum | mmc_switch_t { MMC_SWITCH_COMMAND_SET = 0 , MMC_SWITCH_SET_BITS = 1 , MMC_SWITCH_CLEAR_BITS = 2 , MMC_SWITCH_WRITE_BYTE = 3 } | 
| MMC switch mode.  More... | |
| enum | sd_switch_t { SD_SWITCH_CHECK = 0 , SD_SWITCH_SET = 1 } | 
| SDC switch mode.  More... | |
| enum | sd_switch_function_t { SD_SWITCH_FUNCTION_SPEED = 0 , SD_SWITCH_FUNCTION_CMD_SYSTEM = 1 , SD_SWITCH_FUNCTION_DRIVER_STRENGTH = 2 , SD_SWITCH_FUNCTION_CURRENT_LIMIT = 3 } | 
| SDC switch function.  More... | |
| enum | sdcbusmode_t { SDC_MODE_1BIT = 0 , SDC_MODE_4BIT , SDC_MODE_8BIT } | 
| Type of SDIO bus mode.  More... | |
| enum | sdcbusclk_t { SDC_CLK_25MHz = 0 , SDC_CLK_50MHz } | 
| Max supported clock.  More... | |
Functions | |
| static bool | mode_detect (SDCDriver *sdcp) | 
| Detects card mode.   | |
| static bool | mmc_init (SDCDriver *sdcp) | 
| Init procedure for MMC.   | |
| static bool | sdc_init (SDCDriver *sdcp) | 
| Init procedure for SDC.   | |
| 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.   | |
| static uint32_t | sdc_cmd6_construct (sd_switch_t mode, sd_switch_function_t function, uint32_t value) | 
| Constructs CMD6 argument for SDC.   | |
| static uint16_t | sdc_cmd6_extract_info (sd_switch_function_t function, const uint8_t *buf) | 
| Extracts information from CMD6 answer.   | |
| static bool | sdc_cmd6_check_status (sd_switch_function_t function, const uint8_t *buf) | 
| Checks status after switching using CMD6.   | |
| static bool | sdc_detect_bus_clk (SDCDriver *sdcp, sdcbusclk_t *clk) | 
| Reads supported bus clock and switch SDC to appropriate mode.   | |
| static bool | mmc_detect_bus_clk (SDCDriver *sdcp, sdcbusclk_t *clk) | 
| Reads supported bus clock and switch MMC to appropriate mode.   | |
| static bool | detect_bus_clk (SDCDriver *sdcp, sdcbusclk_t *clk) | 
| Reads supported bus clock and switch card to appropriate mode.   | |
| static bool | sdc_set_bus_width (SDCDriver *sdcp) | 
| Sets bus width for SDC.   | |
| static bool | mmc_set_bus_width (SDCDriver *sdcp) | 
| Sets bus width for MMC.   | |
| static bool | _sdc_wait_for_transfer_state_internal (SDCDriver *sdcp, bool crc_check) | 
| Wait for the card to complete pending operations.   | |
| bool | _sdc_wait_for_transfer_state (SDCDriver *sdcp) | 
| Wait for the card to complete pending operations with CRC check.   | |
| bool | _sdc_wait_for_transfer_state_nocrc (SDCDriver *sdcp) | 
| Wait for the card to complete pending operations without CRC check.   | |
| void | sdcInit (void) | 
| SDC Driver initialization.   | |
| void | sdcObjectInit (SDCDriver *sdcp) | 
Initializes the standard part of a SDCDriver structure.   | |
| msg_t | sdcStart (SDCDriver *sdcp, const SDCConfig *config) | 
| Configures and activates the SDC peripheral.   | |
| void | sdcStop (SDCDriver *sdcp) | 
| Deactivates the SDC peripheral.   | |
| bool | sdcConnect (SDCDriver *sdcp) | 
| Performs the initialization procedure on the inserted card.   | |
| bool | sdcDisconnect (SDCDriver *sdcp) | 
| Brings the driver in a state safe for card removal.   | |
| bool | sdcRead (SDCDriver *sdcp, uint32_t startblk, uint8_t *buf, uint32_t n) | 
| Reads one or more blocks.   | |
| bool | sdcWrite (SDCDriver *sdcp, uint32_t startblk, const uint8_t *buf, uint32_t n) | 
| Writes one or more blocks.   | |
| sdcflags_t | sdcGetAndClearErrors (SDCDriver *sdcp) | 
| Returns the errors mask associated to the previous operation.   | |
| bool | sdcSync (SDCDriver *sdcp) | 
| Waits for card idle condition.   | |
| bool | sdcGetInfo (SDCDriver *sdcp, BlockDeviceInfo *bdip) | 
| Returns the media info.   | |
| bool | sdcErase (SDCDriver *sdcp, uint32_t startblk, uint32_t endblk) | 
| Erases the supplied blocks.   | |
| void | sdc_lld_init (void) | 
| Low level SDC driver initialization.   | |
| void | sdc_lld_start (SDCDriver *sdcp) | 
| Configures and activates the SDC peripheral.   | |
| void | sdc_lld_stop (SDCDriver *sdcp) | 
| Deactivates the SDC peripheral.   | |
| void | sdc_lld_start_clk (SDCDriver *sdcp) | 
| Starts the SDIO clock and sets it to init mode (400kHz or less).   | |
| void | sdc_lld_set_data_clk (SDCDriver *sdcp, sdcbusclk_t clk) | 
| Sets the SDIO clock to data mode (25MHz or less).   | |
| void | sdc_lld_stop_clk (SDCDriver *sdcp) | 
| Stops the SDIO clock.   | |
| void | sdc_lld_set_bus_mode (SDCDriver *sdcp, sdcbusmode_t mode) | 
| Switches the bus to 4 bits mode.   | |
| void | sdc_lld_send_cmd_none (SDCDriver *sdcp, uint8_t cmd, uint32_t arg) | 
| Sends an SDIO command with no response expected.   | |
| 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.   | |
| 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.   | |
| 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_read (SDCDriver *sdcp, uint32_t startblk, uint8_t *buf, uint32_t n) | 
| Reads one or more blocks.   | |
| bool | sdc_lld_write (SDCDriver *sdcp, uint32_t startblk, const uint8_t *buf, uint32_t n) | 
| Writes one or more blocks.   | |
| bool | sdc_lld_sync (SDCDriver *sdcp) | 
| Waits for card idle condition.   | |
| bool | sdc_lld_read_special (SDCDriver *sdcp, uint8_t *buf, size_t bytes, uint8_t cmd, uint32_t argument) | 
| bool | sdc_lld_is_card_inserted (SDCDriver *sdcp) | 
| bool | sdc_lld_is_write_protected (SDCDriver *sdcp) | 
Variables | |
| static const struct SDCDriverVMT | sdc_vmt | 
| Virtual methods table.   | |
| SDCDriver | SDCD1 | 
| SDCD1 driver identifier.   | |
| #define SDC_MODE_CARDTYPE_MASK 0xFU | 
Definition at line 38 of file hal_sdc.h.
Referenced by detect_bus_clk(), sdc_init(), and sdcConnect().
| #define SDC_MODE_CARDTYPE_SDV11 0U | 
Definition at line 39 of file hal_sdc.h.
Referenced by mode_detect(), and sdcConnect().
| #define SDC_MODE_CARDTYPE_SDV20 1U | 
Definition at line 40 of file hal_sdc.h.
Referenced by mode_detect(), sdc_init(), and sdcConnect().
| #define SDC_MODE_CARDTYPE_MMC 2U | 
Definition at line 41 of file hal_sdc.h.
Referenced by detect_bus_clk(), mode_detect(), and sdcConnect().
| #define SDC_MODE_HIGH_CAPACITY 0x10U | 
Definition at line 42 of file hal_sdc.h.
Referenced by mmc_init(), sdc_init(), and sdcErase().
| #define SDC_NO_ERROR 0U | 
Definition at line 49 of file hal_sdc.h.
Referenced by sdcGetAndClearErrors(), and sdcObjectInit().
| #define SDC_OVERFLOW_ERROR 128U | 
Definition at line 57 of file hal_sdc.h.
Referenced by sdcRead(), and sdcWrite().
| #define SDC_INIT_RETRY 100 | 
Number of initialization attempts before rejecting the card.
Definition at line 74 of file hal_sdc.h.
Referenced by mmc_init(), and sdc_init().
| #define SDC_MMC_SUPPORT FALSE | 
| #define SDC_NICE_WAITING TRUE | 
| #define SDC_INIT_OCR_V20 0x50FF8000U | 
OCR initialization constant for V20 cards.
Definition at line 100 of file hal_sdc.h.
Referenced by sdc_init().
| #define SDC_INIT_OCR 0x80100000U | 
OCR initialization constant for non-V20 cards.
Definition at line 107 of file hal_sdc.h.
Referenced by sdc_init().
| #define sdcIsCardInserted | ( | sdcp | ) | 
Returns the card insertion status.
sdc_lld_is_card_inserted(), this function must be provided by the application because it is not part of the SDC driver.| [in] | sdcp | pointer to the SDCDriver object  | 
| false | card not inserted. | 
| true | card inserted. | 
| #define sdcIsWriteProtected | ( | sdcp | ) | 
Returns the write protect status.
sdc_lld_is_write_protected(), this function must be provided by the application because it is not part of the SDC driver.| [in] | sdcp | pointer to the SDCDriver object  | 
| false | not write protected. | 
| true | write protected. | 
| #define PLATFORM_SDC_USE_SDC1 FALSE | 
PWMD1 driver enable switch.
If set to TRUE the support for PWM1 is included. 
FALSE. Definition at line 48 of file hal_sdc_lld.h.
| #define _sdc_driver_methods _mmcsd_block_device_methods | 
SDCDriver specific methods. 
Definition at line 90 of file hal_sdc_lld.h.
| typedef uint32_t sdcmode_t | 
Type of card flags.
Definition at line 63 of file hal_sdc_lld.h.
| typedef uint32_t sdcflags_t | 
SDC Driver condition flags type.
Definition at line 68 of file hal_sdc_lld.h.
| typedef struct SDCDriver SDCDriver | 
Type of a structure representing an SDC driver.
Definition at line 73 of file hal_sdc_lld.h.
| enum mmc_switch_t | 
| enum sd_switch_t | 
| enum sd_switch_function_t | 
| enum sdcbusmode_t | 
| enum sdcbusclk_t | 
      
  | 
  static | 
Detects card mode.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 100 of file hal_sdc.c.
References SDCDriver::cardmode, HAL_FAILED, HAL_SUCCESS, MMCSD_CMD8_PATTERN, MMCSD_CMD_APP_CMD, MMCSD_CMD_GO_IDLE_STATE, MMCSD_CMD_SEND_IF_COND, MMCSD_R1_ERROR, sdc_lld_send_cmd_none(), sdc_lld_send_cmd_short_crc(), SDC_MODE_CARDTYPE_MMC, SDC_MODE_CARDTYPE_SDV11, and SDC_MODE_CARDTYPE_SDV20.
Referenced by sdcConnect().

      
  | 
  static | 
Init procedure for MMC.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 144 of file hal_sdc.c.
References SDCDriver::cardmode, HAL_FAILED, HAL_SUCCESS, MMCSD_CMD_INIT, osalThreadSleepMilliseconds, SDC_INIT_RETRY, sdc_lld_send_cmd_short(), and SDC_MODE_HIGH_CAPACITY.
Referenced by sdcConnect().

      
  | 
  static | 
Init procedure for SDC.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 181 of file hal_sdc.c.
References SDCDriver::cardmode, HAL_FAILED, HAL_SUCCESS, MMCSD_CMD_APP_CMD, MMCSD_CMD_APP_OP_COND, MMCSD_R1_ERROR, osalThreadSleepMilliseconds, SDC_INIT_OCR, SDC_INIT_OCR_V20, SDC_INIT_RETRY, sdc_lld_send_cmd_short(), sdc_lld_send_cmd_short_crc(), SDC_MODE_CARDTYPE_MASK, SDC_MODE_CARDTYPE_SDV20, and SDC_MODE_HIGH_CAPACITY.
Referenced by sdcConnect().

      
  | 
  static | 
Constructs CMD6 argument for MMC.
| [in] | access | EXT_CSD access mode | 
| [in] | idx | EXT_CSD byte number | 
| [in] | value | value to be written in target field | 
| [in] | cmd_set | switch current command set | 
Definition at line 229 of file hal_sdc.c.
References osalDbgAssert.
Referenced by mmc_detect_bus_clk(), and mmc_set_bus_width().
      
  | 
  static | 
Constructs CMD6 argument for SDC.
| [in] | mode | switch/test mode | 
| [in] | function | function number to be switched | 
| [in] | value | value to be written in target function | 
Definition at line 249 of file hal_sdc.c.
References osalDbgAssert.
Referenced by sdc_detect_bus_clk().
      
  | 
  static | 
Extracts information from CMD6 answer.
| [in] | function | function number to be switched | 
| [in] | buf | buffer with answer | 
Definition at line 271 of file hal_sdc.c.
Referenced by sdc_detect_bus_clk().
      
  | 
  static | 
Checks status after switching using CMD6.
| [in] | function | function number to be switched | 
| [in] | buf | buffer with answer | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 291 of file hal_sdc.c.
References HAL_FAILED, and HAL_SUCCESS.
Referenced by sdc_detect_bus_clk().
      
  | 
  static | 
Reads supported bus clock and switch SDC to appropriate mode.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [out] | clk | pointer to clock enum | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 319 of file hal_sdc.c.
References _mmcsd_get_slice(), SDCDriver::buf, HAL_FAILED, HAL_SUCCESS, MMCSD_CMD_SWITCH, MMCSD_CSD_10_CSD_STRUCTURE_SLICE, SD_SWITCH_FUNCTION_SPEED, SD_SWITCH_SET, SDC_CLK_25MHz, SDC_CLK_50MHz, sdc_cmd6_check_status(), sdc_cmd6_construct(), sdc_cmd6_extract_info(), and sdc_lld_read_special().
Referenced by detect_bus_clk().

      
  | 
  static | 
Reads supported bus clock and switch MMC to appropriate mode.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [out] | clk | pointer to clock enum | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 373 of file hal_sdc.c.
References HAL_SUCCESS, mmc_cmd6_construct(), MMC_SWITCH_WRITE_BYTE, MMCSD_CMD_SWITCH, MMCSD_R1_ERROR, SDC_CLK_25MHz, SDC_CLK_50MHz, and sdc_lld_send_cmd_short_crc().
Referenced by detect_bus_clk().

      
  | 
  static | 
Reads supported bus clock and switch card to appropriate mode.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [out] | clk | pointer to clock enum | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 401 of file hal_sdc.c.
References SDCDriver::cardmode, mmc_detect_bus_clk(), sdc_detect_bus_clk(), SDC_MODE_CARDTYPE_MASK, and SDC_MODE_CARDTYPE_MMC.
Referenced by sdcConnect().

      
  | 
  static | 
Sets bus width for SDC.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 420 of file hal_sdc.c.
References SDCConfig::bus_width, SDCDriver::config, HAL_FAILED, HAL_SUCCESS, MMCSD_CMD_APP_CMD, MMCSD_CMD_SET_BUS_WIDTH, MMCSD_R1_ERROR, SDCDriver::rca, sdc_lld_send_cmd_short_crc(), sdc_lld_set_bus_mode(), SDC_MODE_1BIT, and SDC_MODE_4BIT.
Referenced by sdcConnect().

      
  | 
  static | 
Sets bus width for MMC.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 458 of file hal_sdc.c.
References SDCConfig::bus_width, SDCDriver::config, HAL_FAILED, HAL_SUCCESS, mmc_cmd6_construct(), MMC_SWITCH_WRITE_BYTE, MMCSD_CMD_SWITCH, MMCSD_R1_ERROR, osalDbgAssert, sdc_lld_send_cmd_short_crc(), sdc_lld_set_bus_mode(), SDC_MODE_1BIT, SDC_MODE_4BIT, and SDC_MODE_8BIT.
Referenced by sdcConnect().

      
  | 
  static | 
Wait for the card to complete pending operations.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | crc_check | CRC check flag | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 498 of file hal_sdc.c.
References HAL_FAILED, HAL_SUCCESS, MMCSD_CMD_SEND_STATUS, MMCSD_R1_ERROR, MMCSD_R1_STS, MMCSD_STS_DATA, MMCSD_STS_PRG, MMCSD_STS_RCV, MMCSD_STS_TRAN, osalThreadSleepMilliseconds, SDCDriver::rca, sdc_lld_send_cmd_short(), and sdc_lld_send_cmd_short_crc().
Referenced by _sdc_wait_for_transfer_state(), and _sdc_wait_for_transfer_state_nocrc().

| bool _sdc_wait_for_transfer_state | ( | SDCDriver * | sdcp | ) | 
Wait for the card to complete pending operations with CRC check.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 548 of file hal_sdc.c.
References _sdc_wait_for_transfer_state_internal().
Referenced by sdcDisconnect(), and sdcErase().

| bool _sdc_wait_for_transfer_state_nocrc | ( | SDCDriver * | sdcp | ) | 
Wait for the card to complete pending operations without CRC check.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 564 of file hal_sdc.c.
References _sdc_wait_for_transfer_state_internal().
Referenced by sdcConnect().

| void sdcInit | ( | void | ) | 
SDC Driver initialization.
halInit(), there is no need to explicitly initialize the driver.Definition at line 576 of file hal_sdc.c.
References sdc_lld_init().
Referenced by halInit().

| void sdcObjectInit | ( | SDCDriver * | sdcp | ) | 
Initializes the standard part of a SDCDriver structure. 
| [out] | sdcp | pointer to the SDCDriver object | 
Definition at line 588 of file hal_sdc.c.
References BLK_STOP, SDCDriver::config, SDCDriver::errors, SDC_NO_ERROR, sdc_vmt, and SDCDriver::vmt.
Referenced by sdc_lld_init().
Configures and activates the SDC peripheral.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | config | pointer to the SDCConfig object, can be NULL if the driver supports a default configuration or requires no configuration  | 
Definition at line 608 of file hal_sdc.c.
References BLK_ACTIVE, BLK_STOP, SDCDriver::config, HAL_RET_SUCCESS, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and sdc_lld_start().

| void sdcStop | ( | SDCDriver * | sdcp | ) | 
Deactivates the SDC peripheral.
| [in] | sdcp | pointer to the SDCDriver object | 
Definition at line 645 of file hal_sdc.c.
References BLK_ACTIVE, BLK_STOP, SDCDriver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and sdc_lld_stop().

| bool sdcConnect | ( | SDCDriver * | sdcp | ) | 
Performs the initialization procedure on the inserted card.
This function should be invoked when a card is inserted and brings the driver in the BLK_READY state where it is possible to perform read and write operations.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 675 of file hal_sdc.c.
References _mmcsd_get_capacity(), _mmcsd_get_capacity_ext(), _mmcsd_get_slice(), _sdc_wait_for_transfer_state_nocrc(), BLK_ACTIVE, BLK_CONNECTING, BLK_READY, SDCDriver::buf, SDCDriver::cardmode, detect_bus_clk(), HAL_FAILED, HAL_SUCCESS, mmc_init(), mmc_set_bus_width(), MMCSD_BLOCK_SIZE, MMCSD_CMD_ALL_SEND_CID, MMCSD_CMD_GO_IDLE_STATE, MMCSD_CMD_SEL_DESEL_CARD, MMCSD_CMD_SEND_CSD, MMCSD_CMD_SEND_EXT_CSD, MMCSD_CMD_SEND_RELATIVE_ADDR, MMCSD_CMD_SET_BLOCKLEN, MMCSD_CSD_MMC_CSD_STRUCTURE_SLICE, MMCSD_R1_ERROR, mode_detect(), osalDbgAssert, osalDbgCheck, SDCDriver::rca, SDC_CLK_25MHz, sdc_init(), sdc_lld_read_special(), sdc_lld_send_cmd_long_crc(), sdc_lld_send_cmd_none(), sdc_lld_send_cmd_short_crc(), sdc_lld_set_data_clk(), sdc_lld_start_clk(), sdc_lld_stop_clk(), SDC_MODE_CARDTYPE_MASK, SDC_MODE_CARDTYPE_MMC, SDC_MODE_CARDTYPE_SDV11, SDC_MODE_CARDTYPE_SDV20, and sdc_set_bus_width().

| bool sdcDisconnect | ( | SDCDriver * | sdcp | ) | 
Brings the driver in a state safe for card removal.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 815 of file hal_sdc.c.
References _sdc_wait_for_transfer_state(), BLK_ACTIVE, BLK_DISCONNECTING, BLK_READY, HAL_FAILED, HAL_SUCCESS, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and sdc_lld_stop_clk().

| bool sdcRead | ( | SDCDriver * | sdcp, | 
| uint32_t | startblk, | ||
| uint8_t * | buf, | ||
| uint32_t | n ) | 
Reads one or more blocks.
BLK_READY state after a successful sdcConnect() invocation.| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | startblk | first block to read | 
| [out] | buf | pointer to the read buffer | 
| [in] | n | number of blocks to read | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 858 of file hal_sdc.c.
References BLK_READING, BLK_READY, SDCDriver::errors, HAL_FAILED, osalDbgAssert, osalDbgCheck, sdc_lld_read(), and SDC_OVERFLOW_ERROR.

| bool sdcWrite | ( | SDCDriver * | sdcp, | 
| uint32_t | startblk, | ||
| const uint8_t * | buf, | ||
| uint32_t | n ) | 
Writes one or more blocks.
BLK_READY state after a successful sdcConnect() invocation.| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | startblk | first block to write | 
| [out] | buf | pointer to the write buffer | 
| [in] | n | number of blocks to write | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 895 of file hal_sdc.c.
References BLK_READY, BLK_WRITING, SDCDriver::errors, HAL_FAILED, osalDbgAssert, osalDbgCheck, sdc_lld_write(), and SDC_OVERFLOW_ERROR.

| sdcflags_t sdcGetAndClearErrors | ( | SDCDriver * | sdcp | ) | 
Returns the errors mask associated to the previous operation.
| [in] | sdcp | pointer to the SDCDriver object  | 
Definition at line 925 of file hal_sdc.c.
References BLK_READY, SDCDriver::errors, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and SDC_NO_ERROR.

| bool sdcSync | ( | SDCDriver * | sdcp | ) | 
Waits for card idle condition.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | the operation succeeded. | 
| HAL_FAILED | the operation failed. | 
Definition at line 949 of file hal_sdc.c.
References BLK_READY, BLK_SYNCING, HAL_FAILED, osalDbgCheck, and sdc_lld_sync().

| bool sdcGetInfo | ( | SDCDriver * | sdcp, | 
| BlockDeviceInfo * | bdip ) | 
Returns the media info.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [out] | bdip | pointer to a BlockDeviceInfo structure | 
| HAL_SUCCESS | the operation succeeded. | 
| HAL_FAILED | the operation failed. | 
Definition at line 980 of file hal_sdc.c.
References BlockDeviceInfo::blk_num, BLK_READY, BlockDeviceInfo::blk_size, HAL_FAILED, HAL_SUCCESS, MMCSD_BLOCK_SIZE, and osalDbgCheck.
| bool sdcErase | ( | SDCDriver * | sdcp, | 
| uint32_t | startblk, | ||
| uint32_t | endblk ) | 
Erases the supplied blocks.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | startblk | starting block number | 
| [in] | endblk | ending block number | 
| HAL_SUCCESS | the operation succeeded. | 
| HAL_FAILED | the operation failed. | 
Definition at line 1007 of file hal_sdc.c.
References _sdc_wait_for_transfer_state(), BLK_READY, BLK_WRITING, SDCDriver::cardmode, HAL_FAILED, HAL_SUCCESS, MMCSD_BLOCK_SIZE, MMCSD_CMD_ERASE, MMCSD_CMD_ERASE_RW_BLK_END, MMCSD_CMD_ERASE_RW_BLK_START, MMCSD_R1_ERROR, osalDbgAssert, osalDbgCheck, sdc_lld_send_cmd_short_crc(), and SDC_MODE_HIGH_CAPACITY.

| void sdc_lld_init | ( | void | ) | 
Low level SDC driver initialization.
Definition at line 65 of file hal_sdc_lld.c.
References SDCD1, and sdcObjectInit().
Referenced by sdcInit().

| void sdc_lld_start | ( | SDCDriver * | sdcp | ) | 
Configures and activates the SDC peripheral.
| [in] | sdcp | pointer to the SDCDriver object | 
Definition at line 79 of file hal_sdc_lld.c.
References BLK_STOP.
Referenced by sdcStart().
| void sdc_lld_stop | ( | SDCDriver * | sdcp | ) | 
Deactivates the SDC peripheral.
| [in] | sdcp | pointer to the SDCDriver object | 
Definition at line 93 of file hal_sdc_lld.c.
References BLK_STOP.
Referenced by sdcStop().
| void sdc_lld_start_clk | ( | SDCDriver * | sdcp | ) | 
Starts the SDIO clock and sets it to init mode (400kHz or less).
| [in] | sdcp | pointer to the SDCDriver object | 
Definition at line 107 of file hal_sdc_lld.c.
Referenced by sdcConnect().
| void sdc_lld_set_data_clk | ( | SDCDriver * | sdcp, | 
| sdcbusclk_t | clk ) | 
Sets the SDIO clock to data mode (25MHz or less).
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | clk | the clock mode | 
Definition at line 120 of file hal_sdc_lld.c.
Referenced by sdcConnect().
| void sdc_lld_stop_clk | ( | SDCDriver * | sdcp | ) | 
Stops the SDIO clock.
| [in] | sdcp | pointer to the SDCDriver object | 
Definition at line 133 of file hal_sdc_lld.c.
Referenced by sdcConnect(), and sdcDisconnect().
| void sdc_lld_set_bus_mode | ( | SDCDriver * | sdcp, | 
| sdcbusmode_t | mode ) | 
Switches the bus to 4 bits mode.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | mode | bus mode | 
Definition at line 146 of file hal_sdc_lld.c.
References osalDbgAssert, SDC_MODE_1BIT, SDC_MODE_4BIT, and SDC_MODE_8BIT.
Referenced by mmc_set_bus_width(), and sdc_set_bus_width().
| void sdc_lld_send_cmd_none | ( | SDCDriver * | sdcp, | 
| uint8_t | cmd, | ||
| uint32_t | arg ) | 
Sends an SDIO command with no response expected.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | cmd | card command | 
| [in] | arg | command argument | 
Definition at line 175 of file hal_sdc_lld.c.
Referenced by mode_detect(), and sdcConnect().
| 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.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | cmd | card command | 
| [in] | arg | command argument | 
| [out] | resp | pointer to the response buffer (one word) | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 197 of file hal_sdc_lld.c.
References HAL_SUCCESS.
Referenced by _sdc_wait_for_transfer_state_internal(), mmc_init(), and sdc_init().
| 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.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | cmd | card command | 
| [in] | arg | command argument | 
| [out] | resp | pointer to the response buffer (one word) | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 222 of file hal_sdc_lld.c.
References HAL_SUCCESS.
Referenced by _sdc_wait_for_transfer_state_internal(), mmc_detect_bus_clk(), mmc_set_bus_width(), mode_detect(), sdc_init(), sdc_set_bus_width(), sdcConnect(), and sdcErase().
| 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.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | cmd | card command | 
| [in] | arg | command argument | 
| [out] | resp | pointer to the response buffer (four words) | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 247 of file hal_sdc_lld.c.
References HAL_SUCCESS.
Referenced by sdcConnect().
| bool sdc_lld_read | ( | SDCDriver * | sdcp, | 
| uint32_t | startblk, | ||
| uint8_t * | buf, | ||
| uint32_t | n ) | 
Reads one or more blocks.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | startblk | first block to read | 
| [out] | buf | pointer to the read buffer | 
| [in] | n | number of blocks to read | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 272 of file hal_sdc_lld.c.
References HAL_SUCCESS.
Referenced by sdcRead().
| bool sdc_lld_write | ( | SDCDriver * | sdcp, | 
| uint32_t | startblk, | ||
| const uint8_t * | buf, | ||
| uint32_t | n ) | 
Writes one or more blocks.
| [in] | sdcp | pointer to the SDCDriver object  | 
| [in] | startblk | first block to write | 
| [out] | buf | pointer to the write buffer | 
| [in] | n | number of blocks to write | 
| HAL_SUCCESS | operation succeeded. | 
| HAL_FAILED | operation failed. | 
Definition at line 297 of file hal_sdc_lld.c.
References HAL_SUCCESS.
Referenced by sdcWrite().
| bool sdc_lld_sync | ( | SDCDriver * | sdcp | ) | 
Waits for card idle condition.
| [in] | sdcp | pointer to the SDCDriver object | 
| HAL_SUCCESS | the operation succeeded. | 
| HAL_FAILED | the operation failed. | 
Definition at line 319 of file hal_sdc_lld.c.
References HAL_SUCCESS.
Referenced by sdcSync().
| bool sdc_lld_read_special | ( | SDCDriver * | sdcp, | 
| uint8_t * | buf, | ||
| size_t | bytes, | ||
| uint8_t | cmd, | ||
| uint32_t | argument ) | 
Referenced by sdc_detect_bus_clk(), and sdcConnect().
| bool sdc_lld_is_card_inserted | ( | SDCDriver * | sdcp | ) | 
| bool sdc_lld_is_write_protected | ( | SDCDriver * | sdcp | ) | 
      
  | 
  static | 
Virtual methods table.
Definition at line 74 of file hal_sdc.c.
Referenced by sdcObjectInit().
| SDCDriver SDCD1 |