Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
High Speed MultiMedia Card Interface

(HSMCI) implementation

Macros

#define hsmci_debug(...)
 
#define SD_MMC_HSMCI_MEM_CNT   1
 
#define SD_MMC_HSMCI_SLOT_0_SIZE   1
 

Functions

bool hsmci_adtc_start (sdmmc_cmd_def_t cmd, uint32_t arg, uint16_t block_size, uint16_t nb_block, bool access_block)
 Send an ADTC command on the selected slot An ADTC (Addressed Data Transfer Commands) command is used for read/write access. More...
 
bool hsmci_adtc_stop (sdmmc_cmd_def_t cmd, uint32_t arg)
 Send a command to stop an ADTC command on the selected slot. More...
 
void hsmci_deselect_device (uint8_t slot)
 Deselect a slot. More...
 
uint8_t hsmci_get_bus_width (uint8_t slot)
 Return the maximum bus width of a slot. More...
 
uint32_t hsmci_get_response (void)
 Return the 32 bits response of the last command. More...
 
void hsmci_get_response_128 (uint8_t *response)
 Return the 128 bits response of the last command. More...
 
void hsmci_init (void)
 Initializes the low level driver. More...
 
bool hsmci_is_high_speed_capable (void)
 Return the high speed capability of the driver. More...
 
bool hsmci_read_word (uint32_t *value)
 Read a word on the line. More...
 
static void hsmci_reset (void)
 Reset the HSMCI interface. More...
 
void hsmci_select_device (uint8_t slot, uint32_t clock, uint8_t bus_width, bool high_speed)
 Select a slot and initialize it. More...
 
void hsmci_send_clock (void)
 Send 74 clock cycles on the line of selected slot Note: It is required after card plug and before card install. More...
 
bool hsmci_send_cmd (sdmmc_cmd_def_t cmd, uint32_t arg)
 Send a command on the selected slot. More...
 
static bool hsmci_send_cmd_execute (uint32_t cmdr, sdmmc_cmd_def_t cmd, uint32_t arg)
 Send a command. More...
 
static void hsmci_set_speed (uint32_t speed, uint32_t mck)
 Set speed of the HSMCI clock. More...
 
static bool hsmci_wait_busy (void)
 Wait the end of busy signal on data line. More...
 
bool hsmci_write_word (uint32_t value)
 Write a word on the line. More...
 

Variables

static uint16_t hsmci_block_size
 Size block requested by last hsmci_adtc_start() More...
 
static uint16_t hsmci_nb_block
 Total number of block requested by last hsmci_adtc_start() More...
 
static uint32_t hsmci_transfert_pos
 Current position (byte) of the transfer started by hsmci_adtc_start() More...
 

#define hsmci_debug (   ...)
#define SD_MMC_HSMCI_MEM_CNT   1
#define SD_MMC_HSMCI_SLOT_0_SIZE   1

Referenced by hsmci_get_bus_width().

bool hsmci_adtc_start ( sdmmc_cmd_def_t  cmd,
uint32_t  arg,
uint16_t  block_size,
uint16_t  nb_block,
bool  access_block 
)

Send an ADTC command on the selected slot An ADTC (Addressed Data Transfer Commands) command is used for read/write access.

Parameters
cmdCommand definition
argArgument of the command
block_sizeBlock size used for the transfer
nb_blockTotal number of block for this transfer
access_blockif true, the x_read_blocks() and x_write_blocks() functions must be used after this function. If false, the mci_read_word() and mci_write_word() functions must be used after this function.
Returns
true if success, otherwise false

References Assert, hsmci_block_size, hsmci_nb_block, hsmci_send_cmd_execute(), hsmci_transfert_pos, SDMMC_CMD_MULTI_BLOCK, SDMMC_CMD_SDIO_BLOCK, SDMMC_CMD_SDIO_BYTE, SDMMC_CMD_SINGLE_BLOCK, SDMMC_CMD_STREAM, and SDMMC_CMD_WRITE.

bool hsmci_adtc_stop ( sdmmc_cmd_def_t  cmd,
uint32_t  arg 
)

Send a command to stop an ADTC command on the selected slot.

Parameters
cmdCommand definition
argArgument of the command
Returns
true if success, otherwise false

References hsmci_send_cmd_execute().

void hsmci_deselect_device ( uint8_t  slot)

Deselect a slot.

Parameters
slotSelected slot

References UNUSED.

uint8_t hsmci_get_bus_width ( uint8_t  slot)

Return the maximum bus width of a slot.

Parameters
slotSelected slot
Returns
1, 4 or 8 lines.

References SD_MMC_HSMCI_SLOT_0_SIZE.

uint32_t hsmci_get_response ( void  )

Return the 32 bits response of the last command.

Returns
32 bits response
void hsmci_get_response_128 ( uint8_t *  response)

Return the 128 bits response of the last command.

Parameters
responsePointer on the array to fill with the 128 bits response
void hsmci_init ( void  )

Initializes the low level driver.

This enable the clock required and the hardware interface.

References pmc_enable_periph_clk().

bool hsmci_is_high_speed_capable ( void  )

Return the high speed capability of the driver.

Returns
true, if the high speed is supported
bool hsmci_read_word ( uint32_t *  value)

Read a word on the line.

Parameters
valuePointer on a word to fill
Returns
true if success, otherwise false

References Assert, hsmci_block_size, hsmci_debug, hsmci_nb_block, hsmci_reset(), and hsmci_transfert_pos.

static void hsmci_reset ( void  )
static

Reset the HSMCI interface.

Referenced by hsmci_read_word(), hsmci_send_cmd_execute(), hsmci_wait_busy(), and hsmci_write_word().

void hsmci_select_device ( uint8_t  slot,
uint32_t  clock,
uint8_t  bus_width,
bool  high_speed 
)

Select a slot and initialize it.

Parameters
slotSelected slot
clockMaximum clock to use (Hz)
bus_widthBus width to use (1, 4 or 8)
high_speedtrue, to enable high speed mode

References Assert, hsmci_set_speed(), and sysclk_get_peripheral_hz().

void hsmci_send_clock ( void  )

Send 74 clock cycles on the line of selected slot Note: It is required after card plug and before card install.

bool hsmci_send_cmd ( sdmmc_cmd_def_t  cmd,
uint32_t  arg 
)

Send a command on the selected slot.

Parameters
cmdCommand definition
argArgument of the command
Returns
true if success, otherwise false

References hsmci_send_cmd_execute().

static bool hsmci_send_cmd_execute ( uint32_t  cmdr,
sdmmc_cmd_def_t  cmd,
uint32_t  arg 
)
static

Send a command.

Parameters
cmdrCMDR register bit to use for this command
cmdCommand definition
argArgument of the command
Returns
true if success, otherwise false

References hsmci_debug, hsmci_reset(), hsmci_wait_busy(), SDMMC_CMD_OPENDRAIN, SDMMC_RESP_136, SDMMC_RESP_BUSY, SDMMC_RESP_CRC, and SDMMC_RESP_PRESENT.

Referenced by hsmci_adtc_start(), hsmci_adtc_stop(), and hsmci_send_cmd().

static void hsmci_set_speed ( uint32_t  speed,
uint32_t  mck 
)
static

Set speed of the HSMCI clock.

Parameters
speedHSMCI clock speed in Hz.
mckMCK clock speed in Hz.

Referenced by hsmci_select_device().

static bool hsmci_wait_busy ( void  )
static

Wait the end of busy signal on data line.

Returns
true if success, otherwise false

References hsmci_debug, and hsmci_reset().

Referenced by hsmci_send_cmd_execute().

bool hsmci_write_word ( uint32_t  value)

Write a word on the line.

Parameters
valueWord to send
Returns
true if success, otherwise false

References Assert, hsmci_block_size, hsmci_debug, hsmci_nb_block, hsmci_reset(), and hsmci_transfert_pos.

uint16_t hsmci_block_size
static

Size block requested by last hsmci_adtc_start()

Referenced by hsmci_adtc_start(), hsmci_read_word(), and hsmci_write_word().

uint16_t hsmci_nb_block
static

Total number of block requested by last hsmci_adtc_start()

Referenced by hsmci_adtc_start(), hsmci_read_word(), and hsmci_write_word().

uint32_t hsmci_transfert_pos
static

Current position (byte) of the transfer started by hsmci_adtc_start()

Referenced by hsmci_adtc_start(), hsmci_read_word(), and hsmci_write_word().