ChibiOS 21.11.4
hal_sdc.c File Reference

SDC Driver code. More...

#include <string.h>
#include "hal.h"

Go to the source code of this file.

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...

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.

Variables

static const struct SDCDriverVMT sdc_vmt
 Virtual methods table.

Detailed Description

SDC Driver code.

Definition in file hal_sdc.c.