Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
MultiMedia Card Interface (MCI)

This driver interfaces the MCI (MultiMedia Card Interface) module.

It will add functions for SD/MMC card reading, writing and management.

Modules

 MultiMedia Card Interface (MCI)
 implementation
 

Functions

bool mci_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 mci_adtc_stop (sdmmc_cmd_def_t cmd, uint32_t arg)
 Send a command to stop an ADTC command on the selected slot. More...
 
void mci_deselect_device (uint8_t slot)
 Deselect a slot. More...
 
uint8_t mci_get_bus_width (uint8_t slot)
 Return the maximum bus width of a slot. More...
 
uint32_t mci_get_response (void)
 Return the 32 bits response of the last command. More...
 
void mci_get_response_128 (uint8_t *response)
 Return the 128-bits response of the last command. More...
 
void mci_init (void)
 Initialize the low level driver. More...
 
bool mci_is_high_speed_capable (void)
 Return the high speed capability of the driver. More...
 
bool mci_read_word (uint32_t *value)
 Read a word on the line. More...
 
void mci_select_device (uint8_t slot, uint32_t clock, uint8_t bus_width, bool high_speed)
 Select a slot and initialize it. More...
 
void mci_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 mci_send_cmd (sdmmc_cmd_def_t cmd, uint32_t arg)
 Send a command on the selected slot. More...
 
bool mci_start_read_blocks (void *dest, uint16_t nb_block)
 Start a read blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer. More...
 
bool mci_start_write_blocks (const void *src, uint16_t nb_block)
 Start a write blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer. More...
 
bool mci_wait_end_of_read_blocks (void)
 Wait the end of transfer started by mci_start_read_blocks() More...
 
bool mci_wait_end_of_write_blocks (void)
 Wait the end of transfer started by mci_start_write_blocks() More...
 
bool mci_write_word (uint32_t value)
 Write a word on the line. More...
 

bool mci_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, AVR32_MCI_CMDR_TRCMD_START_TRANS_MASK, AVR32_MCI_CMDR_TRDIR_READ_MASK, AVR32_MCI_CMDR_TRTYP_BLOCK_MASK, AVR32_MCI_CMDR_TRTYP_MULTI_BLOCK_MASK, AVR32_MCI_CMDR_TRTYP_SDIO_BLOCK_MASK, AVR32_MCI_CMDR_TRTYP_SDIO_BYTE_MASK, AVR32_MCI_CMDR_TRTYP_STREAM_MASK, AVR32_MCI_MR_FBYTE_MASK, mci_block_size, mci_nb_block, mci_send_cmd_execute(), mci_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 mci_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 mci_send_cmd_execute(), and mci_wait_busy_on_line().

void mci_deselect_device ( uint8_t  slot)

Deselect a slot.

Parameters
slotSelected slot

References AVR32_MCI_SDCR_SDCBUS_1_BIT_MASK, and UNUSED.

uint8_t mci_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_MCI_SLOT_0_SIZE, and SD_MMC_MCI_SLOT_1_SIZE.

uint32_t mci_get_response ( void  )

Return the 32 bits response of the last command.

Returns
32 bits response
void mci_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
bool mci_is_high_speed_capable ( void  )

Return the high speed capability of the driver.

Returns
true, if the high speed mode is supported
bool mci_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, le32_to_cpu, mci_block_size, mci_debug, mci_nb_block, mci_reset(), and mci_transfert_pos.

void mci_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, AVR32_MCI_SDCR_SDCBUS_1_BIT_MASK, AVR32_MCI_SDCR_SDCBUS_4_BIT_MASK, AVR32_MCI_SDCR_SDCBUS_8_BIT_MASK, AVR32_MCI_SDCR_SDCSEL_0_MASK, AVR32_MCI_SDCR_SDCSEL_1_MASK, mci_set_speed(), and sysclk_get_pbb_hz().

void mci_send_clock ( void  )

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

References AVR32_MCI_MR_FBYTE_MASK.

bool mci_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 AVR32_MCI_MR_FBYTE_MASK, and mci_send_cmd_execute().

bool mci_start_read_blocks ( void *  dest,
uint16_t  nb_block 
)

Start a read blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer.

Parameters
destPointer on the buffer to fill
nb_blockNumber of block to transfer
Returns
true if started, otherwise false

References Assert, AVR32_MCI_MR_FBYTE_MASK, mci_block_size, mci_nb_block, and mci_transfert_pos.

bool mci_start_write_blocks ( const void *  src,
uint16_t  nb_block 
)

Start a write blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer.

Parameters
srcPointer on the buffer to send
nb_blockNumber of block to transfer
Returns
true if started, otherwise false

References Assert, AVR32_MCI_MR_FBYTE_MASK, mci_block_size, mci_nb_block, and mci_transfert_pos.

bool mci_wait_end_of_read_blocks ( void  )

Wait the end of transfer started by mci_start_read_blocks()

Returns
true if success, otherwise false

References mci_block_size, mci_debug, mci_nb_block, mci_reset(), and mci_transfert_pos.

bool mci_wait_end_of_write_blocks ( void  )

Wait the end of transfer started by mci_start_write_blocks()

Returns
true if success, otherwise false

References Assert, mci_block_size, mci_debug, mci_nb_block, mci_reset(), and mci_transfert_pos.

bool mci_write_word ( uint32_t  value)

Write a word on the line.

Parameters
valueWord to send
Returns
true if success, otherwise false

References Assert, cpu_to_le32, mci_block_size, mci_debug, mci_nb_block, mci_reset(), and mci_transfert_pos.